-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
94 lines (83 loc) · 2.46 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-0.97f, 0.0f);
glVertex2f(-0.97f, 0.4f);
glVertex2f(-0.87f, 0.2f);
glVertex2f(-0.77f, 0.4f);
glVertex2f(-0.77f, 0.0f);
glEnd();
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_STRIP);
glVertex2f(-0.75f, 0.0f);
glVertex2f(-0.70f, 0.4f);
glVertex2f(-0.65f, 0.0f);
glEnd();
glBegin(GL_LINES);
glVertex2f(-0.725f, 0.2f);
glVertex2f(-0.675f, 0.2f);
glEnd();
glColor3f(1.0, 0, 0);
glBegin(GL_LINES);
glVertex2f(-0.6f, 0.0f);
glVertex2f(-0.6f, 0.2f);
glVertex2f(-0.65f, 0.4f);
glVertex2f(-0.6f, 0.2f);
glVertex2f(-0.55f, 0.4f);
glVertex2f(-0.6f, 0.2f);
glEnd();
glColor3f(0, 0, 1.0);
glBegin(GL_LINE_STRIP);
glVertex2f(-0.55f, 0.0f);
glVertex2f(-0.50f, 0.4f);
glVertex2f(-0.45f, 0.0f);
glEnd();
glBegin(GL_LINES);
glVertex2f(-0.525f, 0.2f);
glVertex2f(-0.475f, 0.2f);
glEnd();
glColor3f(0, 1.0, 0);
glBegin(GL_LINE_STRIP);
glVertex2f(-0.40f, 0.0f);
glVertex2f(-0.40f, 0.4f);
glVertex2f(-0.30f, 0.0f);
glVertex2f(-0.30f, 0.4f);
glEnd();
glColor3f(0, 1.0, 1.0);
glBegin(GL_LINES);
glVertex2f(-0.25f, 0.0f);
glVertex2f(-0.25f, 0.4f);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(-0.15f, 0.0f);
glVertex2f(-0.25f, 0.2f);
glVertex2f(-0.15f, 0.4f);
glEnd();
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}