istereo2

annotate src/glut/main.c @ 30:900651a2f401

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 Oct 2015 06:54:18 +0300
parents 2b85d05df3f2
children
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@10 23
nuclear@10 24 #ifdef __APPLE__
nuclear@10 25 #include <GLUT/glut.h>
nuclear@10 26 #else
nuclear@2 27 #include <GL/glut.h>
nuclear@10 28 #endif
nuclear@10 29
nuclear@2 30 #include "sanegl.h"
nuclear@2 31 #include "istereo.h"
nuclear@2 32 #include "sdr.h"
nuclear@2 33
nuclear@2 34 void disp(void);
nuclear@2 35 void keyb(unsigned char key, int x, int y);
nuclear@9 36 void mouse(int bn, int st, int x, int y);
nuclear@9 37 void motion(int x, int y);
nuclear@2 38
nuclear@2 39 int main(int argc, char **argv)
nuclear@2 40 {
nuclear@2 41 glutInit(&argc, argv);
nuclear@10 42 glutInitWindowSize(920, 640);
nuclear@2 43 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
nuclear@2 44 glutCreateWindow("test");
nuclear@2 45
nuclear@2 46 glutDisplayFunc(disp);
nuclear@2 47 glutIdleFunc(glutPostRedisplay);
nuclear@2 48 glutReshapeFunc(reshape);
nuclear@2 49 glutKeyboardFunc(keyb);
nuclear@9 50 glutMouseFunc(mouse);
nuclear@9 51 glutMotionFunc(motion);
nuclear@2 52
nuclear@2 53 glewInit();
nuclear@2 54
nuclear@2 55 if(init() == -1) {
nuclear@2 56 return 1;
nuclear@2 57 }
nuclear@2 58
nuclear@2 59 glutMainLoop();
nuclear@2 60 return 0;
nuclear@2 61 }
nuclear@2 62
nuclear@2 63 void disp(void)
nuclear@2 64 {
nuclear@2 65 redraw();
nuclear@2 66
nuclear@2 67 glutSwapBuffers();
nuclear@2 68 }
nuclear@2 69
nuclear@2 70 extern int stereo;
nuclear@2 71 extern int use_bump;
nuclear@2 72
nuclear@2 73 void keyb(unsigned char key, int x, int y)
nuclear@2 74 {
nuclear@2 75 switch(key) {
nuclear@2 76 case 27:
nuclear@2 77 exit(0);
nuclear@2 78
nuclear@2 79 case 's':
nuclear@2 80 stereo = !stereo;
nuclear@2 81 break;
nuclear@2 82
nuclear@2 83 case 'b':
nuclear@2 84 use_bump = !use_bump;
nuclear@2 85 break;
nuclear@2 86
nuclear@2 87 case '`':
nuclear@2 88 {
nuclear@2 89 int xsz = glutGet(GLUT_WINDOW_WIDTH);
nuclear@2 90 int ysz = glutGet(GLUT_WINDOW_HEIGHT);
nuclear@2 91
nuclear@2 92 glutReshapeWindow(ysz, xsz);
nuclear@2 93 }
nuclear@2 94 break;
nuclear@2 95
nuclear@20 96 case ' ':
nuclear@20 97 playpause();
nuclear@20 98 break;
nuclear@20 99
nuclear@20 100 case '.':
nuclear@22 101 seektime(50);
nuclear@22 102 break;
nuclear@22 103 case '>':
nuclear@22 104 seektime(10);
nuclear@22 105 break;
nuclear@22 106 case ']':
nuclear@22 107 seektime(1);
nuclear@20 108 break;
nuclear@20 109
nuclear@20 110 case ',':
nuclear@22 111 seektime(-50);
nuclear@22 112 break;
nuclear@22 113 case '<':
nuclear@22 114 seektime(-10);
nuclear@22 115 break;
nuclear@22 116 case '[':
nuclear@22 117 seektime(-1);
nuclear@22 118 break;
nuclear@22 119
nuclear@22 120 case '1':
nuclear@22 121 glutReshapeWindow(960, 640); /* 3.5 inch iphone */
nuclear@22 122 break;
nuclear@22 123
nuclear@22 124 case '2':
nuclear@22 125 glutReshapeWindow(1136, 640); /* 4.0 inch iphone */
nuclear@22 126 break;
nuclear@22 127
nuclear@22 128 case '3':
nuclear@22 129 glutReshapeWindow(1334, 750); /* 4.7 inch iphone */
nuclear@22 130 break;
nuclear@22 131
nuclear@22 132 case '4':
nuclear@22 133 glutReshapeWindow(2208, 1242); /* 5.5 inch iphone */
nuclear@22 134 break;
nuclear@22 135
nuclear@22 136 case '5':
nuclear@22 137 glutReshapeWindow(2048, 1496); /* ipad2? */
nuclear@22 138 break;
nuclear@22 139
nuclear@22 140 case '9':
nuclear@22 141 glutReshapeWindow(1104, 621); /* hald 5.5 inch iphone */
nuclear@22 142 break;
nuclear@22 143
nuclear@22 144 case '0':
nuclear@22 145 glutReshapeWindow(1024, 748); /* half ipad2 */
nuclear@20 146 break;
nuclear@20 147
nuclear@2 148 default:
nuclear@2 149 break;
nuclear@2 150 }
nuclear@2 151 }
nuclear@9 152
nuclear@9 153 void mouse(int bn, int st, int x, int y)
nuclear@9 154 {
nuclear@9 155 mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN ? 1 : 0, x, y);
nuclear@9 156 }
nuclear@9 157
nuclear@9 158 void motion(int x, int y)
nuclear@9 159 {
nuclear@9 160 mouse_motion(x, y);
nuclear@9 161 }
nuclear@17 162
nuclear@17 163 /* dummy ad banner functions */
nuclear@17 164 void ad_banner_show(void)
nuclear@17 165 {
nuclear@17 166 }
nuclear@17 167
nuclear@17 168 void ad_banner_hide(void)
nuclear@17 169 {
nuclear@17 170 }