X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=demo_prior;a=blobdiff_plain;f=src%2Fmain.c;h=a6db18784eb406697dc09c7145b4d7fc203d3df3;hp=2113a5372428b44172a833f440af177329085ee1;hb=44a7a61d2bec54ed741930572e63e5015326daca;hpb=ec776ad8bf37d25b9308e2c770d66247135b46ea diff --git a/src/main.c b/src/main.c index 2113a53..a6db187 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,7 @@ #include #include "miniglut.h" #include "demo.h" +#include "opt.h" static void display(void); static void idle(void); @@ -12,10 +13,20 @@ static long time_start; int main(int argc, char **argv) { + unsigned int glut_flags = GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH; + glutInit(&argc, argv); - glutInitWindowSize(1280, 800); - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_SRGB | GLUT_MULTISAMPLE); - glutCreateWindow("demo"); + + read_cfg("demo.cfg"); + if(parse_args(argc, argv) == -1) { + return 1; + } + if(opt.srgb) glut_flags |= GLUT_SRGB; + if(opt.msaa) glut_flags |= GLUT_MULTISAMPLE; + + glutInitWindowSize(opt.width, opt.height); + glutInitDisplayMode(glut_flags); + glutCreateWindow("Prior Art / Mindlapse"); glutDisplayFunc(display); glutIdleFunc(idle); @@ -28,6 +39,10 @@ int main(int argc, char **argv) glutSpaceballRotateFunc(demo_sball_rotate); glutSpaceballButtonFunc(demo_sball_button); + if(opt.fullscr) { + glutFullScreen(); + } + if(demo_init() == -1) { return 1; } @@ -58,8 +73,26 @@ static void idle(void) glutPostRedisplay(); } +#define KEYCOMBO_FS \ + ((key == '\r' || key == '\n') && (glutGetModifiers() & GLUT_ACTIVE_ALT)) + + static void keydown(unsigned char key, int x, int y) { + static int fullscr = -1, prev_x, prev_y; + + if(KEYCOMBO_FS) { + if(fullscr == -1) fullscr = opt.fullscr; + fullscr ^= 1; + if(fullscr) { + prev_x = glutGet(GLUT_WINDOW_X); + prev_y = glutGet(GLUT_WINDOW_Y); + glutFullScreen(); + } else { + glutPositionWindow(prev_x, prev_y); + } + } + demo_keyboard(key, 1); }