istereo2

view src/glut/main.c @ 10:2a0ef5efb8e2

fixed macosx build
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 27 Sep 2015 04:55:30 +0300
parents 64e15874f3bd
children f4dd01c36b0c
line source
1 /*
2 Stereoscopic tunnel for iOS.
3 Copyright (C) 2011-2015 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <GL/glew.h>
24 #ifdef __APPLE__
25 #include <GLUT/glut.h>
26 #else
27 #include <GL/glut.h>
28 #endif
30 #include "sanegl.h"
31 #include "istereo.h"
32 #include "sdr.h"
34 void disp(void);
35 void keyb(unsigned char key, int x, int y);
36 void mouse(int bn, int st, int x, int y);
37 void motion(int x, int y);
39 int main(int argc, char **argv)
40 {
41 glutInit(&argc, argv);
42 glutInitWindowSize(920, 640);
43 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
44 glutCreateWindow("test");
46 glutDisplayFunc(disp);
47 glutIdleFunc(glutPostRedisplay);
48 glutReshapeFunc(reshape);
49 glutKeyboardFunc(keyb);
50 glutMouseFunc(mouse);
51 glutMotionFunc(motion);
53 glewInit();
55 if(init() == -1) {
56 return 1;
57 }
59 glutMainLoop();
60 return 0;
61 }
63 void disp(void)
64 {
65 redraw();
67 glutSwapBuffers();
68 }
70 extern int stereo;
71 extern int use_bump;
73 void keyb(unsigned char key, int x, int y)
74 {
75 switch(key) {
76 case 27:
77 exit(0);
79 case 's':
80 stereo = !stereo;
81 break;
83 case 'b':
84 use_bump = !use_bump;
85 break;
87 case '`':
88 {
89 int xsz = glutGet(GLUT_WINDOW_WIDTH);
90 int ysz = glutGet(GLUT_WINDOW_HEIGHT);
92 glutReshapeWindow(ysz, xsz);
93 }
94 break;
96 default:
97 break;
98 }
99 }
101 void mouse(int bn, int st, int x, int y)
102 {
103 mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN ? 1 : 0, x, y);
104 }
106 void motion(int x, int y)
107 {
108 mouse_motion(x, y);
109 }