Add vsync setting

master
Elias Fleckenstein 2022-02-13 13:51:45 +01:00
parent 3359396220
commit 5e478fd9a6
No known key found for this signature in database
GPG Key ID: 06927A5199D6C9B2
3 changed files with 11 additions and 1 deletions

View 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);
}

View File

@ -7,6 +7,7 @@ extern struct ClientConfig {
unsigned int antialiasing;
bool mipmap;
double render_distance;
bool vsync;
} client_config;
#endif

View 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;