-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhello.cpp
More file actions
89 lines (69 loc) · 1.58 KB
/
Copy pathhello.cpp
File metadata and controls
89 lines (69 loc) · 1.58 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
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
/*
glQuickText hello world
requires GLFW : www.glfw.org
compile with: c++ -o hello -I. hello.cpp -lglfw -lGLU -lGL
written 2021 by emogenet@gmail.com
in the public domain
*/
#include <GLFW/glfw3.h>
#include <glQuickText.h>
// entry
int main(
int,
char *[]
) {
// init GLFW
if(GLFW_FALSE==glfwInit()) {
fprintf(stderr, "can't initialize GLFW\n");
exit(1);
}
// open window
auto w = 320;
auto h = 100;
auto win = glfwCreateWindow(
w,
h,
"glQuickText hello world",
NULL,
NULL
);
glfwMakeContextCurrent(win);
// configure OpenGL context
glViewport(0, 0, w, h);
glClearColor(0.2, 0.2, 0.2, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, double(w), 0.0, double(h), -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// render loop
while(1) {
// see if it's time to die
if(glfwWindowShouldClose(win)) {
break;
}
// clear window
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT);
// render text
glColor4ub(0xFF, 0xFF, 0xFF, 0xFF);
glQuickText::printfAt(
50.0f,
45.0f,
0.0,
1.5,
"%s",
"Hello, World!"
);
// show frame
glFlush();
glfwSwapBuffers(win);
// check event queue
glfwPollEvents();
}
// clean up
glfwTerminate();
// make some noise before leaving
printf("exited cleanly\n");
return 0;
}