X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdemo.c;h=50232756f48fc1af6c96559936bee7e276e3effd;hb=ba4adddb6685c5a64a3ca5cae56ba879841327ec;hp=1614426c30df98c9ef85443afcb770acc549a7c5;hpb=fca3f24e31b3bbbe81ce0ef00da901480a2a92cc;p=andemo diff --git a/src/demo.c b/src/demo.c index 1614426..5023275 100644 --- a/src/demo.c +++ b/src/demo.c @@ -3,6 +3,7 @@ #include "opengl.h" #include "sanegl.h" #include "assman.h" +#include "demosys.h" static unsigned int sdr_foo; static unsigned int tex_logo; @@ -19,17 +20,6 @@ int demo_init(void) if(!(tex_logo = get_tex2d("data/ml_logo_old.png"))) { return -1; } - return 0; -} - -void demo_cleanup(void) -{ -} - -void demo_display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - glUseProgram(sdr_foo); gl_begin(GL_QUADS); gl_texcoord2f(0, 1); @@ -41,21 +31,106 @@ void demo_display(void) gl_texcoord2f(0, 0); gl_vertex2f(-1, 1); gl_end(); + swap_buffers(); + + if(dsys_init("data/demoscript") == -1) { + return -1; + } + + return 0; +} + +void demo_cleanup(void) +{ + dsys_destroy(); +} + +void demo_display(void) +{ + struct demoscreen *scr; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + scr = dsys_act_scr; + while(scr) { + if(scr->update) { + scr->update(dsys_time); + } + scr->draw(); + scr = scr->next; + } } void demo_reshape(int x, int y) { + int i; + glViewport(0, 0, x, y); + + for(i=0; ireshape) { + dsys_screens[i]->reshape(x, y); + } + } } void demo_keyboard(int key, int pressed) { + if(!pressed) return; + + switch(key) { + case ' ': + if(dsys_running) { + dsys_stop(); + } else { + dsys_run(); + } + break; + + case '\b': + dsys_seek_abs(0); + break; + + default: + if(key >= '0' && key <= '9') { + dsys_seek_rel((float)(key - '0') / 9.0f); + + } else if(key >= KEY_F1 && key <= KEY_F12) { + int idx = key - KEY_F1; + if(idx < dsys_num_screens) { + dsys_run_screen(dsys_screens[idx]); + } + + } else { + struct demoscreen *scr = dsys_act_scr; + while(scr) { + if(scr->keyboard) { + scr->keyboard(key, pressed); + } + scr = scr->next; + } + } + } } void demo_mouse(int bn, int pressed, int x, int y) { + struct demoscreen *scr = dsys_act_scr; + while(scr) { + if(scr->mouse) { + scr->mouse(bn, pressed, x, y); + } + scr = scr->next; + } } void demo_motion(int x, int y) { + struct demoscreen *scr = dsys_act_scr; + while(scr) { + if(scr->motion) { + scr->motion(x, y); + } + scr = scr->next; + } }