/* * 2D texturing demo using squares. Based on an original demo by Michael * Sweet. * * Written by Scott D. Anderson, Fall 2001 */ #include #include #include #include /* * Globals... */ int win_width = 500; /* Width of window */ int win_height = 500; /* Height of window */ GLint tex_width; /* Width of texture */ GLint tex_height; /* Height of texture */ GLint interpolation_mode; // GL_NEAREST or GL_LINEAR void checkError() { int err = glGetError(); if( err == GL_NO_ERROR ) return; printf("error = 0x%4x\n",err); } /* Builds a 2d checkerboard of red and green squares, with whatever number of pixels per square you want. */ /* Function to create an array of pixels, alternating green and red, with the given number of pixels per square. Returns the array. */ GLubyte* init_checkerboard(int pixels_per_square) { int i,j; int pps = pixels_per_square; int bytes = pps*pps*64*3; GLubyte* checkerboard = (GLubyte*) malloc(bytes); /* The following is a red&green checkerboard. It's done using a 1D array alternating colors. We change colors every pps. */ int count=0; for(i=0;i