-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouse.cpp
More file actions
53 lines (44 loc) · 1.05 KB
/
mouse.cpp
File metadata and controls
53 lines (44 loc) · 1.05 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
#include <GL/gl.h>
#include <GL/glut.h>
int movex = 0, movey = 0;
void ponto(){
glPointSize(20);
glBegin(GL_POINTS);
glColor3f(0,1,0);
glVertex2f(movex,movey);
glEnd();
}
void desenhaObjetos(void){
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,800,600,0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
ponto();
glPopMatrix();
glutSwapBuffers();
}
void movimentaMouse (int x, int y){
movex = x;
movey = y;
glutPostRedisplay();
}
void gerenciaMouse (int botao, int estado, int x, int y){
if (botao == GLUT_LEFT_BUTTON)
if (estado == GLUT_DOWN){
glutMotionFunc(movimentaMouse);
}
}
int main(void){
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(800,600);
glutInitWindowPosition(320,150);
glutCreateWindow("Funcao Mouse - Interacao");
glutDisplayFunc(desenhaObjetos);
glutMouseFunc(gerenciaMouse);
glClearColor(1,1,1,0);
glutMainLoop();
return 0;
}