-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample6.cpp
40 lines (31 loc) · 855 Bytes
/
sample6.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
#include <GL/glut.h>
#include <GL/freeglut_ext.h>
#include <iostream>
using namespace std;
void display1();
void textAdjustPosition();
float xpos = 0.0f;
float ypos = 0.0f;
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitWindowSize(640, 480);
glutInitWindowPosition(0, 0); // top-left most
glutCreateWindow("OpenGL Setup Test");
glutDisplayFunc(display1);
glutMainLoop();
return 0;
}
void textAdjustPosition(int value) {
xpos -= 0.02f; // move to the left
glutPostRedisplay();
}
void display1() {
glClear(GL_COLOR_BUFFER_BIT);
const unsigned char str[100] = {"FEU-TECH"};
glColor3f(0.0f, 0.0f, 1.0f);
glRasterPos2f(xpos, ypos);
glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, str);
glFlush();
// automatically move the text to the left by 0.02 every 1000 ms = 1 sec
glutTimerFunc(1000, textAdjustPosition, 1);
}