#include <stdlib.h>
#include "miniglut.h"
#include "demo.h"
+#include "opt.h"
static void display(void);
static void idle(void);
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);
glutSpaceballRotateFunc(demo_sball_rotate);
glutSpaceballButtonFunc(demo_sball_button);
+ if(opt.fullscr) {
+ glutFullScreen();
+ }
+
if(demo_init() == -1) {
return 1;
}
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);
}