istereo2

view src/glut/main.c @ 9:64e15874f3bd

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 26 Sep 2015 02:56:07 +0300
parents src/glutmain.c@81d35769f546
children 2a0ef5efb8e2
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>
23 #include <GL/glut.h>
24 #include "sanegl.h"
25 #include "istereo.h"
26 #include "sdr.h"
28 void disp(void);
29 void keyb(unsigned char key, int x, int y);
30 void mouse(int bn, int st, int x, int y);
31 void motion(int x, int y);
33 int main(int argc, char **argv)
34 {
35 glutInit(&argc, argv);
36 glutInitWindowSize(640, 920);
37 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
38 glutCreateWindow("test");
40 glutDisplayFunc(disp);
41 glutIdleFunc(glutPostRedisplay);
42 glutReshapeFunc(reshape);
43 glutKeyboardFunc(keyb);
44 glutMouseFunc(mouse);
45 glutMotionFunc(motion);
47 glewInit();
49 if(init() == -1) {
50 return 1;
51 }
53 glutMainLoop();
54 return 0;
55 }
57 void disp(void)
58 {
59 redraw();
61 glutSwapBuffers();
62 }
64 extern int stereo;
65 extern int use_bump;
67 void keyb(unsigned char key, int x, int y)
68 {
69 switch(key) {
70 case 27:
71 exit(0);
73 case 's':
74 stereo = !stereo;
75 break;
77 case 'b':
78 use_bump = !use_bump;
79 break;
81 case '`':
82 {
83 int xsz = glutGet(GLUT_WINDOW_WIDTH);
84 int ysz = glutGet(GLUT_WINDOW_HEIGHT);
86 glutReshapeWindow(ysz, xsz);
87 }
88 break;
90 default:
91 break;
92 }
93 }
95 void mouse(int bn, int st, int x, int y)
96 {
97 mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN ? 1 : 0, x, y);
98 }
100 void motion(int x, int y)
101 {
102 mouse_motion(x, y);
103 }