-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlab-4.cpp
More file actions
59 lines (46 loc) · 1.2 KB
/
lab-4.cpp
File metadata and controls
59 lines (46 loc) · 1.2 KB
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
#include <windows.h>
#include <GL/glut.h>
void display() {
// glOrtho(-4, 4, -4, 4, -4, 4);
glClear(GL_COLOR_BUFFER_BIT);
//glBegin(GL_QUADS);
bool ok = false;
for (int i = 0;i <= 800;i += 100) {
for (int j = 0;j <= 800;j += 100) {
if (ok) {
glColor3f(0.0, 0.0, 0.0);
ok =! ok;
}
else {
glColor3f(1.0, 1.0, 1.0);
ok =! ok;
}
glBegin(GL_QUADS);
glVertex2i(i, j);
//glVertex2i(i, 100);
glVertex2i(i, j+100);
glVertex2i(i+100, j+100);
glVertex2i(i+100, j);
glEnd();
glFlush();
}
}
}
void myInit(void) {
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 800, 0.0, 800);
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
//glutCreateWindow("Simple Triangle");
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("chess");
glutInitWindowSize(800, 800);
glutInitWindowPosition(111, 111);
glutDisplayFunc(display);
//return 0;
myInit();
glutMainLoop();
}