#include "stdafx.h"
#include <gl/glut.h>
void Myinit (void)
{
Glclearcolor (0.2, 0.2, 0.2, 0.0); Set the background color to white;
glcolor3f (0.0f, 0.0f, 0.0f); Set the drawing color to black;
Glpointsize (1.0); Set the point size;
Gllinewidth (1.0); Set the line width;
Glmatrixmode (gl_projection); Select the appropriate matrix;
Glloadidentity ();
gluortho2d (0.0, 500.0, 0.0, 500.0); Set the window size;
}
void Drawchessboard (void)
{
Glclear (Gl_color_buffer_bit); Clear screen;
glcolor3f (0.6, 0.6, 0.6);
Glrecti (0.0,0.0,100.0,100.0);
Glrecti (0.0, 200.0, 100.0, 300.0);
Glrecti (0.0, 400.0, 100.0, 500.0);
Glrecti (100.0, 100.0, 200.0, 200.0);
Glrecti (100.0, 300.0, 200.0, 400.0);
Glrecti (200.0, 0.0, 300.0, 100.0);
Glrecti (200.0, 200.0, 300.0, 300.0);
Glrecti (200.0, 400.0, 300.0, 500.0);
Glrecti (300.0, 100.0, 400.0, 200.0);
Glrecti (300.0, 300.0, 400.0, 400.0);
GLRECTI (400, 0, 500, 100);
Glrecti (400, 200, 500, 300);
GLRECTI (400, 400, 500, 500);
Glflush ();
}
int main (int argc,char* argv[])
{
Glutinit (&ARGC, argv); Initialize the toolkit;
Glutinitdisplaymode (Glut_single | GLUT_RGB); Set the display mode;
Glutinitwindowposition (100, 100); Sets the position of the window on the screen;
Glutinitwindowsize (500, 500); Set the window size;
Glutcreatewindow ("chessboard"); Open the screen window;
Glutdisplayfunc (Drawchessboard); Register redraw function;
Myinit ();
Glutmainloop (); Enter the permanent cycle;
}
Opengl_ Chess board