vrfileman

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