-
Notifications
You must be signed in to change notification settings - Fork 10
/
ch2_01.cpp
47 lines (39 loc) · 863 Bytes
/
ch2_01.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
47
#include <GL/freeglut.h>
#include <iostream>
const unsigned int backgroundTexID = 1;
void update()
{
glutPostRedisplay();
}
void render()
{
glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
glutSwapBuffers();
}
void reshape( int w, int h )
{
glViewport( 0, 0, w, h );
}
void keyEvents( unsigned char key, int x, int y )
{
switch ( key )
{
case 27: case 'Q': case 'q':
glutLeaveMainLoop();
return;
}
glutPostRedisplay();
}
int main( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH|GLUT_MULTISAMPLE );
glutCreateWindow( "ch2_01_OpenGL_Env" );
glutFullScreen();
glutIdleFunc( update );
glutDisplayFunc( render );
glutReshapeFunc( reshape );
glutKeyboardFunc( keyEvents );
glutMainLoop();
return 0;
}