vrfileman
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/main.cc Fri Jan 30 12:25:16 2015 +0200 1.3 @@ -0,0 +1,106 @@ 1.4 +#include <stdlib.h> 1.5 +#include "opengl.h" 1.6 + 1.7 +#ifdef __APPLE__ 1.8 +#include <GLUT/glut.h> 1.9 +#else 1.10 +#include <GL/glut.h> 1.11 +#endif 1.12 + 1.13 +#include "app.h" 1.14 + 1.15 +static void display(); 1.16 +static void reshape(int x, int y); 1.17 +static void key_down(unsigned char key, int x, int y); 1.18 +static void key_up(unsigned char key, int x, int y); 1.19 +static void mouse(int bn, int state, int x, int y); 1.20 +static void motion(int x, int y); 1.21 + 1.22 +static int win_width, win_height; 1.23 +static unsigned int mod; 1.24 + 1.25 +int main(int argc, char **argv) 1.26 +{ 1.27 + glutInit(&argc, argv); 1.28 + 1.29 + glutInitWindowSize(1280, 720); 1.30 + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 1.31 + glutCreateWindow("VR file manager"); 1.32 + 1.33 + glutDisplayFunc(display); 1.34 + glutReshapeFunc(reshape); 1.35 + glutKeyboardFunc(key_down); 1.36 + glutKeyboardUpFunc(key_up); 1.37 + glutMouseFunc(mouse); 1.38 + glutMotionFunc(motion); 1.39 + glutPassiveMotionFunc(motion); 1.40 + 1.41 + if(app_init() == -1) { 1.42 + return 1; 1.43 + } 1.44 + 1.45 + glutMainLoop(); 1.46 + return 0; 1.47 +} 1.48 + 1.49 +void swap_buffers() 1.50 +{ 1.51 + glutSwapBuffers(); 1.52 +} 1.53 + 1.54 +void redisplay() 1.55 +{ 1.56 + glutPostRedisplay(); 1.57 +} 1.58 + 1.59 +void quit() 1.60 +{ 1.61 + app_shutdown(); 1.62 + exit(0); 1.63 +} 1.64 + 1.65 +void get_window_size(int *xsz, int *ysz) 1.66 +{ 1.67 + *xsz = win_width; 1.68 + *ysz = win_height; 1.69 +} 1.70 + 1.71 +unsigned int get_modifiers() 1.72 +{ 1.73 + return mod; 1.74 +} 1.75 + 1.76 +static void display() 1.77 +{ 1.78 + app_display(); 1.79 +} 1.80 + 1.81 +static void reshape(int x, int y) 1.82 +{ 1.83 + win_width = x; 1.84 + win_height = y; 1.85 + app_reshape(x, y); 1.86 +} 1.87 + 1.88 +static void key_down(unsigned char key, int x, int y) 1.89 +{ 1.90 + mod = glutGetModifiers(); 1.91 + app_keyboard(key, true, x, y); 1.92 +} 1.93 + 1.94 +static void key_up(unsigned char key, int x, int y) 1.95 +{ 1.96 + mod = glutGetModifiers(); 1.97 + app_keyboard(key, false, x, y); 1.98 +} 1.99 + 1.100 +static void mouse(int bn, int state, int x, int y) 1.101 +{ 1.102 + mod = glutGetModifiers(); 1.103 + app_mouse_button(bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y); 1.104 +} 1.105 + 1.106 +static void motion(int x, int y) 1.107 +{ 1.108 + app_mouse_motion(x, y); 1.109 +}