glut/progs/examples/glpuzzle.c
/* Draw a box.  Bevel as desired. */
Draw a box.  Bevel as desired.
Draw a box . Bevel as desired .
void
drawBox(int piece, float xoff, float yoff)
{
  int xlen, ylen;
  int i, k;
  float x, y, z;
  float zlen;
  float *v;
  xlen = xsize[piece];
  ylen = ysize[piece];
  zlen = zsize[piece];
  glColor3ubv(colors[piece]);
  glBegin(GL_QUADS);
  for (i = 0; i < 18; i++) {
    glNormal3fv(boxnormals[i]);
    for (k = 0; k < 4; k++) {
      if (boxfaces[i][k] == -1)
        continue;
      v = boxcoords[boxfaces[i][k]];
      x = v[0] + OFFSETX;
      if (v[0] > 0.5)
        x += xlen - 1;
      y = v[1] + OFFSETY;
      if (v[1] > 0.5)
        y += ylen - 1;
      z = v[2] + OFFSETZ;
      if (v[2] > 0.5)
        z += zlen - 1;
      glVertex3f(xoff + x, yoff + y, z);
    }
  }
  glEnd();
  glBegin(GL_TRIANGLES);
  for (i = 18; i < NBOXFACES; i++) {
    glNormal3fv(boxnormals[i]);
    for (k = 0; k < 3; k++) {
      if (boxfaces[i][k] == -1)
        continue;
      v = boxcoords[boxfaces[i][k]];
      x = v[0] + OFFSETX;
      if (v[0] > 0.5)
        x += xlen - 1;
      y = v[1] + OFFSETY;
      if (v[1] > 0.5)
        y += ylen - 1;
      z = v[2] + OFFSETZ;
      if (v[2] > 0.5)
        z += zlen - 1;
      glVertex3f(xoff + x, yoff + y, z);
    }
  }
  glEnd();
}
void drawBox ( int piece , float xoff , float yoff ) { int xlen , ylen ; int i , k ; float x , y , z ; float zlen ; float * v ; xlen = xsize [ piece ] ; ylen = ysize [ piece ] ; zlen = zsize [ piece ] ; glColor3ubv ( colors [ piece ] ) ; glBegin ( GL_QUADS ) ; for ( i = 0 ; i < 18 ; i ++ ) { glNormal3fv ( boxnormals [ i ] ) ; for ( k = 0 ; k < 4 ; k ++ ) { if ( boxfaces [ i ] [ k ] == -1 ) continue ; v = boxcoords [ boxfaces [ i ] [ k ] ] ; x = v [ 0 ] + OFFSETX ; if ( v [ 0 ] > 0.5 ) x += xlen - 1 ; y = v [ 1 ] + OFFSETY ; if ( v [ 1 ] > 0.5 ) y += ylen - 1 ; z = v [ 2 ] + OFFSETZ ; if ( v [ 2 ] > 0.5 ) z += zlen - 1 ; glVertex3f ( xoff + x , yoff + y , z ) ; } } glEnd ( ) ; glBegin ( GL_TRIANGLES ) ; for ( i = 18 ; i < NBOXFACES ; i ++ ) { glNormal3fv ( boxnormals [ i ] ) ; for ( k = 0 ; k < 3 ; k ++ ) { if ( boxfaces [ i ] [ k ] == -1 ) continue ; v = boxcoords [ boxfaces [ i ] [ k ] ] ; x = v [ 0 ] + OFFSETX ; if ( v [ 0 ] > 0.5 ) x += xlen - 1 ; y = v [ 1 ] + OFFSETY ; if ( v [ 1 ] > 0.5 ) y += ylen - 1 ; z = v [ 2 ] + OFFSETZ ; if ( v [ 2 ] > 0.5 ) z += zlen - 1 ; glVertex3f ( xoff + x , yoff + y , z ) ; } } glEnd ( ) ; }
Draw a box.
Draw a box .