fixed mouse and keyboard stuff under DOS
[retroray] / src / app.c
index fdcbe11..1d45cdd 100644 (file)
--- 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);
@@ -182,6 +195,13 @@ void app_keyboard(int key, int press)
                        return;
 #endif
 
+               case 'q':
+                       if(modkeys & KEY_MOD_CTRL) {
+                               app_quit();
+                               return;
+                       }
+                       break;
+
                case '\n':
                case '\r':
                        if(modkeys & KEY_MOD_ALT) {