nuclear@0: #include nuclear@0: #include nuclear@0: #include nuclear@0: #ifndef __APPLE__ nuclear@0: #include nuclear@0: #else nuclear@0: #include nuclear@0: #endif nuclear@1: #include "effect.h" nuclear@0: nuclear@0: void display(); nuclear@0: void idle(); nuclear@0: void reshape(int x, int y); nuclear@0: void keyboard(unsigned char key, int x, int y); nuclear@0: bool parse_args(int argc, char **argv); nuclear@0: nuclear@0: static int win_width = 1280, win_height = 800; nuclear@0: static bool fullscreen; nuclear@0: nuclear@0: static unsigned long start_time; nuclear@0: nuclear@0: int main(int argc, char **argv) nuclear@0: { nuclear@0: glutInit(&argc, argv); nuclear@0: if(!parse_args(argc, argv)) { nuclear@0: return 1; nuclear@0: } nuclear@0: glutInitWindowSize(win_width, win_height); nuclear@0: glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); nuclear@0: glutCreateWindow("textbomb"); nuclear@0: nuclear@0: if(fullscreen) { nuclear@0: glutFullScreen(); nuclear@0: } nuclear@0: nuclear@0: glutDisplayFunc(display); nuclear@0: glutIdleFunc(idle); nuclear@0: glutReshapeFunc(reshape); nuclear@0: glutKeyboardFunc(keyboard); nuclear@0: nuclear@1: if(!fx_init()) { nuclear@0: return 1; nuclear@0: } nuclear@1: atexit(fx_cleanup); nuclear@0: nuclear@0: start_time = glutGet(GLUT_ELAPSED_TIME); nuclear@0: glutMainLoop(); nuclear@0: return 0; nuclear@0: } nuclear@0: nuclear@0: void display() nuclear@0: { nuclear@0: unsigned long msec = glutGet(GLUT_ELAPSED_TIME) - start_time; nuclear@0: nuclear@0: glClear(GL_COLOR_BUFFER_BIT); nuclear@0: nuclear@1: fx_draw(msec); nuclear@0: nuclear@0: glutSwapBuffers(); nuclear@0: assert(glGetError() == GL_NO_ERROR); nuclear@0: } nuclear@0: nuclear@0: void idle() nuclear@0: { nuclear@0: glutPostRedisplay(); nuclear@0: } nuclear@0: nuclear@0: void reshape(int x, int y) nuclear@0: { nuclear@0: float aspect = (float)x / (float)y; nuclear@0: nuclear@0: glViewport(0, 0, x, y); nuclear@0: nuclear@0: glMatrixMode(GL_PROJECTION); nuclear@0: glLoadIdentity(); nuclear@0: glScalef(1.0 / aspect, 1.0, 1.0); nuclear@0: } nuclear@0: nuclear@0: void keyboard(unsigned char key, int x, int y) nuclear@0: { nuclear@0: switch(key) { nuclear@0: case 27: nuclear@0: exit(0); nuclear@0: nuclear@0: case 'f': nuclear@0: case 'F': nuclear@0: fullscreen = !fullscreen; nuclear@0: if(fullscreen) { nuclear@0: glutFullScreen(); nuclear@0: } else { nuclear@0: glutReshapeWindow(win_width, win_height); nuclear@0: } nuclear@0: break; nuclear@0: nuclear@0: case ' ': nuclear@1: fx_dbg(); nuclear@0: break; nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: bool parse_args(int argc, char **argv) nuclear@0: { nuclear@0: for(int i=1; i