glut/progs/examples/mjksift.c
/* Setup display list with "frozen" 3D texture coordinates. */
Setup display list with "frozen" 3D texture coordinates.
Setup display list with " frozen " 3D texture coordinates .
void
generateTexturedSurface(void)
{
  static GLfloat data[8] =
  {0, 1, 0, -1};
  int i, j;
#define COLS 12
#define ROWS 12
#define TILE_TEX_W (1.0/COLS)
#define TILE_TEX_H (1.0/ROWS)
  glNewList(1, GL_COMPILE);
  glTranslatef(-COLS / 2.0 + .5, -ROWS / 2.0 + .5, 0);
  for (j = 0; j < ROWS; j++) {
    glBegin(GL_QUAD_STRIP);
    for (i = 0; i < COLS; i++) {
      glTexCoord3f(i * TILE_TEX_W, j * TILE_TEX_H, data[(i + j) % 4]);
      glVertex2f(i - .5, j - .5);
      glTexCoord3f(i * TILE_TEX_W, (j + 1) * TILE_TEX_H, data[(i + j + 1) % 4]);
      glVertex2f(i - .5, j + .5);
    }
    glTexCoord3f((i + 1) * TILE_TEX_W, j * TILE_TEX_H, data[(i + j) % 4]);
    glVertex2f(i + .5, j - .5);
    glTexCoord3f((i + 1) * TILE_TEX_W, (j + 1) * TILE_TEX_H, data[(i + j + 1) % 4]);
    glVertex2f(i + .5, j + .5);
    glEnd();
  }
  glEndList();
}
void generateTexturedSurface ( void ) { static GLfloat data [ 8 ] = { 0 , 1 , 0 , -1 } ; int i , j ; #define COLS  12
 #define ROWS  12
 #define TILE_TEX_W  (1.0/COLS)
 #define TILE_TEX_H  (1.0/ROWS)
 glNewList ( 1 , GL_COMPILE ) ; glTranslatef ( - COLS / 2.0 + .5 , - ROWS / 2.0 + .5 , 0 ) ; for ( j = 0 ; j < ROWS ; j ++ ) { glBegin ( GL_QUAD_STRIP ) ; for ( i = 0 ; i < COLS ; i ++ ) { glTexCoord3f ( i * TILE_TEX_W , j * TILE_TEX_H , data [ ( i + j ) % 4 ] ) ; glVertex2f ( i - .5 , j - .5 ) ; glTexCoord3f ( i * TILE_TEX_W , ( j + 1 ) * TILE_TEX_H , data [ ( i + j + 1 ) % 4 ] ) ; glVertex2f ( i - .5 , j + .5 ) ; } glTexCoord3f ( ( i + 1 ) * TILE_TEX_W , j * TILE_TEX_H , data [ ( i + j ) % 4 ] ) ; glVertex2f ( i + .5 , j - .5 ) ; glTexCoord3f ( ( i + 1 ) * TILE_TEX_W , ( j + 1 ) * TILE_TEX_H , data [ ( i + j + 1 ) % 4 ] ) ; glVertex2f ( i + .5 , j + .5 ) ; glEnd ( ) ; } glEndList ( ) ; }
Setup display list with "frozen" 3D texture coordinates.
Setup display list with " frozen " 3D texture coordinates .