glut version: make the loading screen fullscreen if demo is going to run fullscreen
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 12 Jul 2020 17:17:57 +0000 (20:17 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 12 Jul 2020 17:17:57 +0000 (20:17 +0300)
src/demo.c
src/demo.h
src/glut/main.c

index f9d4900..f7a2463 100644 (file)
@@ -42,10 +42,21 @@ static int con_active;
 
 extern uint16_t loading_pixels[];      /* data.asm */
 
-
 int demo_init(int argc, char **argv)
 {
-       struct screen *scr;
+       if(demo_init1(argc, argv) == -1) {
+               return -1;
+       }
+       if(demo_init2() == -1) {
+               return -1;
+       }
+       return 0;
+}
+
+static struct screen *scr;
+
+int demo_init1(int argc, char **argv)
+{
        char *env;
 
        if(load_config("demo.cfg") == -1) {
@@ -57,7 +68,11 @@ int demo_init(int argc, char **argv)
        if(parse_args(argc, argv) == -1) {
                return -1;
        }
+       return 0;
+}
 
+int demo_init2(void)
+{
        /* reuse the loading image as our back buffer.
         * adjust fb_pixels to leave 4 pixels guard band top/bottom. We have enough
         * space since the loading image is 8 pixels taller.
index de0654b..68cb967 100644 (file)
@@ -54,6 +54,8 @@ enum {
 extern float sball_matrix[16];
 
 int demo_init(int argc, char **argv);
+int demo_init1(int argc, char **argv);
+int demo_init2(void);
 void demo_cleanup(void);
 
 int demo_resizefb(int width, int height, int bpp);
index abe25cc..824837e 100644 (file)
@@ -118,21 +118,26 @@ int main(int argc, char **argv)
        wgl_swap_interval_ext = wglGetProcAddress("wglSwapIntervalEXT");
 #endif
 
-       reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
-
        if(au_init() == -1) {
                return 1;
        }
        time_msec = 0;
-       if(demo_init(argc, argv) == -1) {
+       if(demo_init1(argc, argv) == -1) {
                return 1;
        }
-       atexit(demo_cleanup);
 
        if(opt.fullscreen) {
                set_fullscreen(opt.fullscreen);
+               reshape(glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT));
+       } else {
+               reshape(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
        }
 
+       if(demo_init2() == -1) {
+               return 1;
+       }
+       atexit(demo_cleanup);
+
        reset_timer();
 
        glutMainLoop();