]> git.lizzy.rs Git - dragonblocks_alpha.git/commitdiff
Add vsync setting
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 13 Feb 2022 12:51:45 +0000 (13:51 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 13 Feb 2022 12:51:45 +0000 (13:51 +0100)
src/client/client_config.c
src/client/client_config.h
src/client/window.c

index 43743c1ae6d7ec7c7efb520d0e092ed895b4fae1..658fe5e1fe714e8dca7c1469720de6a4f4ab6037 100644 (file)
@@ -5,6 +5,7 @@ struct ClientConfig client_config = {
        .antialiasing = 4,
        .mipmap = true,
        .render_distance = 255.0,
+       .vsync = true,
 };
 
 __attribute__((constructor)) static void client_config_init()
@@ -24,7 +25,12 @@ __attribute__((constructor)) static void client_config_init()
                        .type = CT_FLOAT,
                        .key = "render_distance",
                        .value = &client_config.render_distance,
+               },
+               {
+                       .type = CT_BOOL,
+                       .key = "vsync",
+                       .value = &client_config.vsync,
                }
-       }, 3);
+       }, 4);
 }
 
index 984d5e8583d6465586cc895efe823a1e4c5d5daa..21b40ddb45e4ab80e32ecb3de9b40fb5d1e094e7 100644 (file)
@@ -7,6 +7,7 @@ extern struct ClientConfig {
        unsigned int antialiasing;
        bool mipmap;
        double render_distance;
+       bool vsync;
 } client_config;
 
 #endif
index 808c36f304a2249d8ae996d89ac4ceb11ac9d898..b45b95bf8ec268777a8cf76ac5f67c662305cfc6 100644 (file)
@@ -82,6 +82,9 @@ bool window_init(int width, int height)
 
        glfwMakeContextCurrent(window.handle);
 
+       if (! client_config.vsync)
+               glfwSwapInterval(0);
+
        if (glewInit() != GLEW_OK) {
                fprintf(stderr, "Failed to initialize GLEW\n");
                return false;