1  /* jcorso::nb - gr_opengl_mip.c */
 2
 3  int texname;  /* id for the texture we'll be using 
 4                 * the mipmap still only has one texture name... */
 5
 6  ...
 7
 8    glGenTextures(1,&texname);  /* ask gl to generate a valid texture name (id) */
 9    glBindTexture(GL_TEXTURE_2D, texname);  /* select the current texture */
10    glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);  /* set the environment */
11    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
12    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
13    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
14    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
15
16    /* use the glu call to generate the mipmaps for the texture */
17    gluBuild2DMipmaps(GL_TEXTURE_2D,3,width,height,GL_RGB,GL_UNSIGNED_BYTE,tex);
18
19    free(tex);  /* we no longer need this memory lying around */
20    glEnable(GL_TEXTURE_2D);  /* tell gl to use the texture */
21
22  ...