-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample4.cpp
46 lines (38 loc) · 1018 Bytes
/
sample4.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
#include <GL/glut.h>
#include <GL/freeglut_ext.h>
#include <iostream>
using namespace std;
void display1();
void mouseMonitor(int button, int state, int x, int y);
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);
glutMouseFunc(mouseMonitor);
glutMainLoop();
return 0;
}
void mouseMonitor(int button, int state, int x, int y) {
if (button == GLUT_LEFT_BUTTON) {
cout << "LEFT" << endl;
if (state == GLUT_UP) { // mouse pressed
cout << "UP" << endl;
} else { // mouse unpressed
cout << "DOWN" << endl;
}
} else if (button == GLUT_RIGHT_BUTTON) {
cout << "RIGHT" << endl;
}
}
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();
}