-/* int moves[MOVES][4] = */
-/* { {3, 2, 6, 2}, */
-/* {7, 0, 6, 1}, */
-/* {6, 2, 6, 6}, */
-/* {0, 5, 0, 4}, */
-/* {6, 6, 0, 6}, */
-/* {0, 4, 1, 3}, */
-/* {2, 7, 1, 5}, */
-/* {2, 2, 3, 2}, */
-/* {0, 6, 0, 3}, */
-/* {1, 3, 2, 2}, */
-/* {0, 3, 6, 3}, */
-/* {3, 2, 4, 2}, /\* pawn to bishop 5 *\/ */
-/* {1, 5, 0, 3}, /\* check *\/ */
-/* {2, 2, 3, 2}, */
-/* {0, 3, 2, 4}, /\* takes pawn *\/ */
-/* {3, 2, 2, 2}, */
-/* {2, 4, 0, 3}, */
-/* {2, 2, 3, 2}, */
-/* {6, 3, 6, 1}, /\* rook takes bishop *\/ */
-/* {6, 0, 7, 0}, */
-/* {6, 1, 3, 1}, */
-/* {3, 2, 2, 3}, */
-/* {3, 1, 3, 3}, */
-/* {0, 0, 2, 3}, */
-/* }; */
+/* 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]);
+}
+
+/* build board texture (uniform noise in [180,180+50]) */
+void make_board_texture(void) {
+ int i, j, c;
+
+ for (i = 0; i < checkImageWidth; i++) {
+ for (j = 0; j < checkImageHeight; j++) {
+ c = 180 + random()%51;
+ checkImage[i][j][0] = (GLubyte) c;
+ checkImage[i][j][1] = (GLubyte) c;
+ checkImage[i][j][2] = (GLubyte) c;
+ }
+ }
+
+ glGenTextures(1, &boardtexture);
+ glBindTexture(GL_TEXTURE_2D, boardtexture);
+
+ 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]);
+}