-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouse.cpp
More file actions
57 lines (47 loc) · 1.16 KB
/
Copy pathmouse.cpp
File metadata and controls
57 lines (47 loc) · 1.16 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
#include<GL/glut.h>
#include<stdlib.h>
float r,g,b,x,y;
bool check=true;
void mouse(int button, int state, int mousex, int mousey)
{
if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN){
check=true;
x = mousex;
y = 480-mousey;
r=0;g=0;b=0;
}
else if(button==GLUT_RIGHT_BUTTON && state==GLUT_DOWN){
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
check = false;
}
glutPostRedisplay();
}
void display(void)
{
glColor3f(r,g,b);
glPointSize(50);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640.0, 0.0, 480.0);
if(check)
{
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
}
glFlush();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("DDA Line Drawing");
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}