-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp9-gl.C
75 lines (49 loc) · 1.27 KB
/
app9-gl.C
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
// test OpenGL calls
#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>
static void ReSizeGLScene (int width, int height)
{
printf("resize to %d/%d\n", width, height);
if (width < 1)
width = 1;
if (height < 1)
height = 1;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)width /(GLfloat)height, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void InitGL ()
{
glShadeModel(GL_SMOOTH);
glClearColor(0.4f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}
static void DrawGLScene ()
{
//printf("draw...\n");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glutSwapBuffers();
}
int main (int argc, char* argv[])
{
printf("started\n");
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 400);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
InitGL();
glutDisplayFunc(DrawGLScene);
glutIdleFunc(DrawGLScene);
glutReshapeFunc(ReSizeGLScene);
glutMainLoop();
return 0;
}