#include
#include
#include
#include
#include
const GLint screenWidth = 640;
const GLint screenHeight = 480;
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble)screenWidth, 0.0, (GLdouble)screenHeight);
}
void checkerboard(void)
{
for(GLint i = 0; i < 8; i++)
{
for(GLint j = 0; j < 8; j++)
{
if((i+j)%2 == 0)
{
glColor3f(0.0f, 0.0f, 0.0f);
}
else
{
glColor3f(1.0f, 1.0f, 1.0f);
}
glRecti(30*j, 30*i, 30*(j+1), 30*(i+1));
}
}
glFlush();
}
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
checkerboard();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(screenWidth, screenHeight);
glutInitWindowPosition(0, 0);
glutCreateWindow("chess");
glutDisplayFunc(myDisplay);
myInit();
glutMainLoop();
}