+
+ /* find new white */
+ int newwhite = oldwhite;
+ while(newwhite == oldwhite)
+ newwhite = random()%WHITES;
+ oldwhite = newwhite;
+
+ colors[0][0] = whites[oldwhite][0];
+ colors[0][1] = whites[oldwhite][1];
+ colors[0][2] = whites[oldwhite][2];
+}
+
+/* road texture */
+#define checkImageWidth 16
+#define checkImageHeight 16
+GLubyte checkImage[checkImageWidth][checkImageHeight][3];
+GLuint piecetexture, boardtexture;
+
+/* build piece texture */
+void make_piece_texture(void) {
+ int i, j, c;
+
+ for (i = 0; i < checkImageWidth; i++) {
+ for (j = 0; j < checkImageHeight; j++) {
+ c = ((j%2) == 0 || i%2 == 0) ? 240 : 180+random()%16;
+ checkImage[i][j][0] = (GLubyte) c;
+ checkImage[i][j][1] = (GLubyte) c;
+ checkImage[i][j][2] = (GLubyte) c;
+ }
+ }
+
+ glGenTextures(1, &piecetexture);
+ glBindTexture(GL_TEXTURE_2D, piecetexture);
+
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth,
+ checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
+ &checkImage[0][0]);