-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chess.cpp
71 lines (66 loc) · 1.6 KB
/
Chess.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include <GL/glut.h>
void myDisplay(void)
{
glClear (GL_COLOR_BUFFER_BIT);
int z = 0;
int w = 0;
for (int x=0; x<400; x+=50)
{
z =0;
if (w % 2 == 0)
{
z = 0;
}
else
{
z = 1;
}
for (int y=0; y<400; y+=50)
{
if (z % 2 == 0)
{
glColor3f (1.0, 1.0, 1.0);
glPointSize(5.0);
glBegin(GL_QUADS);
glVertex2i(x + 0, y + 0);
glVertex2i(x + 50, y + 0);
glVertex2i(x + 50, y + 50);
glVertex2i(x + 0, y + 50);
glEnd();
}
else
{
glColor3f (0.0, 0.0, 0.0);
glPointSize(5.0);
glBegin(GL_QUADS);
glVertex2i(x + 0, y + 0);
glVertex2i(x + 50, y + 0);
glVertex2i(x + 50, y + 50);
glVertex2i(x + 0, y + 50);
glEnd();
}
z++;
}
w++;
}
glFlush ();
}
void myInit (void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluOrtho2D(0.0, 400.0, 0.0, 400.0);
}
main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 150);
glutCreateWindow ("Hello World");
glutDisplayFunc(myDisplay);
myInit ();
glutMainLoop();
}