rev |
line source |
nuclear@0
|
1 #include <stdlib.h>
|
nuclear@0
|
2 #ifdef __APPLE__
|
nuclear@0
|
3 #include <GLUT/glut.h>
|
nuclear@0
|
4 #else
|
nuclear@0
|
5 #include <GL/glut.h>
|
nuclear@0
|
6 #endif
|
nuclear@0
|
7 #include "app.h"
|
nuclear@0
|
8
|
nuclear@0
|
9 static void display();
|
nuclear@0
|
10 static void reshape(int x, int y);
|
nuclear@0
|
11 static void keydown(unsigned char key, int x, int y);
|
nuclear@0
|
12 static void mouse(int bn, int st, int x, int y);
|
nuclear@0
|
13 static void motion(int x, int y);
|
nuclear@0
|
14
|
nuclear@2
|
15 static int win_width, win_height;
|
nuclear@2
|
16
|
nuclear@0
|
17 int main(int argc, char **argv)
|
nuclear@0
|
18 {
|
nuclear@1
|
19 glutInitWindowSize(1024, 768);
|
nuclear@0
|
20 glutInit(&argc, argv);
|
nuclear@2
|
21 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
|
nuclear@0
|
22 glutCreateWindow("cubemapper");
|
nuclear@0
|
23
|
nuclear@0
|
24 glutDisplayFunc(display);
|
nuclear@0
|
25 glutReshapeFunc(reshape);
|
nuclear@0
|
26 glutKeyboardFunc(keydown);
|
nuclear@0
|
27 glutMouseFunc(mouse);
|
nuclear@0
|
28 glutMotionFunc(motion);
|
nuclear@0
|
29
|
nuclear@0
|
30 if(!app_init(argc, argv)) {
|
nuclear@0
|
31 return 1;
|
nuclear@0
|
32 }
|
nuclear@0
|
33
|
nuclear@0
|
34 glutMainLoop();
|
nuclear@0
|
35 return 0;
|
nuclear@0
|
36 }
|
nuclear@0
|
37
|
nuclear@0
|
38 void app_quit()
|
nuclear@0
|
39 {
|
nuclear@0
|
40 app_cleanup();
|
nuclear@0
|
41 exit(0);
|
nuclear@0
|
42 }
|
nuclear@0
|
43
|
nuclear@0
|
44 void app_redisplay()
|
nuclear@0
|
45 {
|
nuclear@0
|
46 glutPostRedisplay();
|
nuclear@0
|
47 }
|
nuclear@0
|
48
|
nuclear@0
|
49 void app_swap_buffers()
|
nuclear@0
|
50 {
|
nuclear@0
|
51 glutSwapBuffers();
|
nuclear@0
|
52 }
|
nuclear@0
|
53
|
nuclear@1
|
54 void app_resize(int x, int y)
|
nuclear@1
|
55 {
|
nuclear@1
|
56 glutReshapeWindow(x, y);
|
nuclear@1
|
57 }
|
nuclear@1
|
58
|
nuclear@2
|
59 void app_print_text(int x, int y, const char *str)
|
nuclear@2
|
60 {
|
nuclear@2
|
61 glMatrixMode(GL_PROJECTION);
|
nuclear@2
|
62 glPushMatrix();
|
nuclear@2
|
63 glLoadIdentity();
|
nuclear@2
|
64 glOrtho(0, win_width, 0, win_height, -1, 1);
|
nuclear@2
|
65
|
nuclear@2
|
66 glMatrixMode(GL_MODELVIEW);
|
nuclear@2
|
67 glPushMatrix();
|
nuclear@2
|
68 glLoadIdentity();
|
nuclear@2
|
69
|
nuclear@2
|
70 glRasterPos2i(x, y);
|
nuclear@2
|
71
|
nuclear@2
|
72 while(*str) {
|
nuclear@2
|
73 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, *str++);
|
nuclear@2
|
74 }
|
nuclear@2
|
75
|
nuclear@2
|
76 glMatrixMode(GL_PROJECTION);
|
nuclear@2
|
77 glPopMatrix();
|
nuclear@2
|
78 glMatrixMode(GL_MODELVIEW);
|
nuclear@2
|
79 glPopMatrix();
|
nuclear@2
|
80 }
|
nuclear@2
|
81
|
nuclear@0
|
82 static void display()
|
nuclear@0
|
83 {
|
nuclear@0
|
84 app_draw();
|
nuclear@0
|
85 }
|
nuclear@0
|
86
|
nuclear@0
|
87 static void reshape(int x, int y)
|
nuclear@0
|
88 {
|
nuclear@2
|
89 win_width = x;
|
nuclear@2
|
90 win_height = y;
|
nuclear@0
|
91 app_reshape(x, y);
|
nuclear@0
|
92 }
|
nuclear@0
|
93
|
nuclear@0
|
94 static void keydown(unsigned char key, int x, int y)
|
nuclear@0
|
95 {
|
nuclear@0
|
96 app_keyboard(key, true);
|
nuclear@0
|
97 }
|
nuclear@0
|
98
|
nuclear@0
|
99 static void mouse(int bn, int st, int x, int y)
|
nuclear@0
|
100 {
|
nuclear@0
|
101 app_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
|
nuclear@0
|
102 }
|
nuclear@0
|
103
|
nuclear@0
|
104 static void motion(int x, int y)
|
nuclear@0
|
105 {
|
nuclear@0
|
106 app_mouse_motion(x, y);
|
nuclear@0
|
107 }
|