screen-relative events
[andemo] / src / demo.c
index cebac7c..f51dcc1 100644 (file)
@@ -37,6 +37,14 @@ int demo_init(void)
        if(dsys_init("data/demoscript") == -1) {
                return -1;
        }
+       if(opt.scrname) {
+               struct demoscreen *scr = dsys_find_screen(opt.scrname);
+               if(scr) {
+                       dsys_run_screen(scr);
+               } else {
+                       fprintf(stderr, "ignoring screen option, no such screen: %s\n", opt.scrname);
+               }
+       }
 
        return 0;
 }
@@ -51,6 +59,25 @@ void demo_display(void)
        dsys_update();
 
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+       glEnable(GL_BLEND);
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+       glBindTexture(GL_TEXTURE_2D, tex_logo);
+       glUseProgram(sdr_foo);
+       gl_begin(GL_QUADS);
+       gl_color4f(1, 1, 1, dsys_value("flashlogo"));
+       gl_texcoord2f(0, 1);
+       gl_vertex2f(-1, -1);
+       gl_texcoord2f(1, 1);
+       gl_vertex2f(1, -1);
+       gl_texcoord2f(1, 0);
+       gl_vertex2f(1, 1);
+       gl_texcoord2f(0, 0);
+       gl_vertex2f(-1, 1);
+       gl_end();
+       glDisable(GL_BLEND);
+
        dsys_draw();
 }
 
@@ -96,6 +123,12 @@ void demo_keyboard(int key, int pressed)
 
                } else {
                        int i;
+
+                       if(dsys.scr_override && dsys.scr_override->keyboard) {
+                               dsys.scr_override->keyboard(key, pressed);
+                               break;
+                       }
+
                        for(i=0; i<dsys.num_act; i++) {
                                struct demoscreen *scr = dsys.act[i];
                                if(scr->keyboard) scr->keyboard(key, pressed);
@@ -107,6 +140,12 @@ void demo_keyboard(int key, int pressed)
 void demo_mouse(int bn, int pressed, int x, int y)
 {
        int i;
+
+       if(dsys.scr_override && dsys.scr_override->mouse) {
+               dsys.scr_override->mouse(bn, pressed, x, y);
+               return;
+       }
+
        for(i=0; i<dsys.num_act; i++) {
                struct demoscreen *scr = dsys.act[i];
                if(scr->mouse) scr->mouse(bn, pressed, x, y);
@@ -116,6 +155,11 @@ void demo_mouse(int bn, int pressed, int x, int y)
 void demo_motion(int x, int y)
 {
        int i;
+
+       if(dsys.scr_override && dsys.scr_override->motion) {
+               dsys.scr_override->motion(x, y);
+       }
+
        for(i=0; i<dsys.num_act; i++) {
                struct demoscreen *scr = dsys.act[i];
                if(scr->motion) scr->motion(x, y);