X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fapp.c;h=6f7e250427afe1fa6ed536a0395ea9089f36da17;hb=208078d05078a27b5cdfc213031d91e88180994b;hp=fdcbe118dd2c7342e580c23bd73f33380b1a6174;hpb=b0088adf036a53139f67ebf96f1bbb55abf199f4;p=retroray diff --git a/src/app.c b/src/app.c index fdcbe11..6f7e250 100644 --- a/src/app.c +++ b/src/app.c @@ -52,6 +52,7 @@ struct font *uifont; uint32_t *framebuf; +struct scene *scn; /* available screens */ #define MAX_SCREENS 8 @@ -65,13 +66,15 @@ int app_init(void) char *start_scr_name; static rtk_draw_ops guigfx = {gui_fill, gui_blit, gui_drawtext, gui_textrect}; - init_logger(); - #if !defined(NDEBUG) && defined(DBG_FPEXCEPT) printf("floating point exceptions enabled\n"); enable_fpexcept(); #endif +#ifdef GFX_SW + gaw_sw_init(); +#endif + load_options("retroray.cfg"); app_resize(opt.xres, opt.yres); app_vsync(opt.vsync); @@ -89,6 +92,10 @@ int app_init(void) rtk_setup(&guigfx); + if(!(scn = create_scene())) { + return -1; + } + /* initialize screens */ screens[num_screens++] = &scr_model; screens[num_screens++] = &scr_rend; @@ -133,6 +140,12 @@ void app_shutdown(void) destroy_font(uifont); free(uifont); +#ifdef GFX_SW + gaw_sw_destroy(); +#endif + + free_scene(scn); + cleanup_logger(); } @@ -141,8 +154,6 @@ void app_display(void) time_msec = app_getmsec(); cur_scr->display(); - - app_swap_buffers(); } void app_reshape(int x, int y) @@ -150,7 +161,9 @@ void app_reshape(int x, int y) int numpix = x * y; int prev_numpix = win_width * win_height; - if(numpix > prev_numpix) { + printf("reshape(%d, %d)\n", x, y); + + if(!framebuf || numpix > prev_numpix) { void *tmp; if(!(tmp = realloc(framebuf, numpix * sizeof *framebuf))) { errormsg("failed to resize framebuffer to %dx%d\n", x, y);