X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdemo.c;h=77c33d2617bd83942af450a2239dacb0204ecbfc;hb=313480bbe9994a200ed9a4355d97a033bf0d6151;hp=68068b8ebe0f46e5533f6b2acd262ba111cc0bce;hpb=c7560762d55919077d830368a05da0ce223bc96a;p=andemo diff --git a/src/demo.c b/src/demo.c index 68068b8..77c33d2 100644 --- a/src/demo.c +++ b/src/demo.c @@ -1,7 +1,9 @@ +#include #include "demo.h" #include "opengl.h" #include "sanegl.h" #include "assman.h" +#include "demosys.h" static unsigned int sdr_foo; static unsigned int tex_logo; @@ -18,17 +20,7 @@ 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); - + glBindTexture(GL_TEXTURE_2D, tex_logo); glUseProgram(sdr_foo); gl_begin(GL_QUADS); gl_texcoord2f(0, 1); @@ -40,21 +32,92 @@ 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) +{ + dsys_update(); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + dsys_draw(); } 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 { + int i; + for(i=0; ikeyboard) scr->keyboard(key, pressed); + } + } + } } void demo_mouse(int bn, int pressed, int x, int y) { + int i; + for(i=0; imouse) scr->mouse(bn, pressed, x, y); + } } void demo_motion(int x, int y) { + int i; + for(i=0; imotion) scr->motion(x, y); + } }