istereo2

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