-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSegundo Exercicio.cpp
More file actions
98 lines (61 loc) · 1.7 KB
/
Copy pathSegundo Exercicio.cpp
File metadata and controls
98 lines (61 loc) · 1.7 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
89
90
91
92
93
94
95
96
97
98
//#include <GL/gl.h>
#include <GL/glew.h>
#include <GL/freeglut.h>
void keyInput(unsigned char key, int x, int y){
switch(key) {
case 27:
exit(0);
break;
default:
break;
}
}
void resize(int w, int h){
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void setup(void) {
glClearColor(1.0, 1.0, 1.0, 0.0);
}
void drawPolygon (void) {
glClear(GL_COLOR_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor3f(0.0, 0.0, 0.0);
// desenha o poligono
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(10.0, 60.0, 0.0);
glVertex3f(10.0, 80.0, 0.0);
glVertex3f(20.0, 60.0, 0.0);
glVertex3f(40.0, 80.0, 0.0);
glVertex3f(20.0, 20.0, 0.0);
glVertex3f(40.0, 40.0, 0.0);
glVertex3f(80.0, 20.0, 0.0);
glVertex3f(60.0, 40.0, 0.0);
glVertex3f(80.0, 60.0, 0.0);
glVertex3f(60.0, 80.0, 0.0);
glVertex3f(90.0, 60.0, 0.0);
glVertex3f(90.0, 80.0, 0.0);
glEnd();
glColor3f(1.0, 0.0, 0.0);
glEnd();
glFlush();
}
int main (int argc, char** argv){
glutInit(&argc, argv);
glutInitContextVersion(4, 3);
glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100, 100);
glutCreateWindow("Hello World modificado");
glutDisplayFunc(drawPolygon);
glutReshapeFunc(resize);
glutKeyboardFunc(keyInput);
//glewExperimental = GL_TRUE;
setup();
glutMainLoop();
return 0;
}