vrfileman

view src/main.cc @ 0:dca518e371cf

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 30 Jan 2015 12:25:16 +0200
parents
children 282da6123fd4
line source
1 #include <stdlib.h>
2 #include "opengl.h"
4 #ifdef __APPLE__
5 #include <GLUT/glut.h>
6 #else
7 #include <GL/glut.h>
8 #endif
10 #include "app.h"
12 static void display();
13 static void reshape(int x, int y);
14 static void key_down(unsigned char key, int x, int y);
15 static void key_up(unsigned char key, int x, int y);
16 static void mouse(int bn, int state, int x, int y);
17 static void motion(int x, int y);
19 static int win_width, win_height;
20 static unsigned int mod;
22 int main(int argc, char **argv)
23 {
24 glutInit(&argc, argv);
26 glutInitWindowSize(1280, 720);
27 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
28 glutCreateWindow("VR file manager");
30 glutDisplayFunc(display);
31 glutReshapeFunc(reshape);
32 glutKeyboardFunc(key_down);
33 glutKeyboardUpFunc(key_up);
34 glutMouseFunc(mouse);
35 glutMotionFunc(motion);
36 glutPassiveMotionFunc(motion);
38 if(app_init() == -1) {
39 return 1;
40 }
42 glutMainLoop();
43 return 0;
44 }
46 void swap_buffers()
47 {
48 glutSwapBuffers();
49 }
51 void redisplay()
52 {
53 glutPostRedisplay();
54 }
56 void quit()
57 {
58 app_shutdown();
59 exit(0);
60 }
62 void get_window_size(int *xsz, int *ysz)
63 {
64 *xsz = win_width;
65 *ysz = win_height;
66 }
68 unsigned int get_modifiers()
69 {
70 return mod;
71 }
73 static void display()
74 {
75 app_display();
76 }
78 static void reshape(int x, int y)
79 {
80 win_width = x;
81 win_height = y;
82 app_reshape(x, y);
83 }
85 static void key_down(unsigned char key, int x, int y)
86 {
87 mod = glutGetModifiers();
88 app_keyboard(key, true, x, y);
89 }
91 static void key_up(unsigned char key, int x, int y)
92 {
93 mod = glutGetModifiers();
94 app_keyboard(key, false, x, y);
95 }
97 static void mouse(int bn, int state, int x, int y)
98 {
99 mod = glutGetModifiers();
100 app_mouse_button(bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y);
101 }
103 static void motion(int x, int y)
104 {
105 app_mouse_motion(x, y);
106 }