From 2d0f7d800b47cf3426e84f394c185b343dbaa001 Mon Sep 17 00:00:00 2001 From: Vladimir Vuksanovic Date: Fri, 16 Apr 2021 22:05:12 +0200 Subject: [PATCH 1/2] Add vsync option to ini files --- data/editor.ini | 3 ++- data/pingpong.ini | 3 ++- data/platformer.ini | 3 ++- data/racing.ini | 3 ++- data/teamgame.ini | 3 ++- data/tiles_example.ini | 3 ++- source/dagger/core/graphics/window.cpp | 10 +++++++++- source/dagger/core/graphics/window.h | 1 + 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/data/editor.ini b/data/editor.ini index 89d04483..6b857bfa 100644 --- a/data/editor.ini +++ b/data/editor.ini @@ -2,4 +2,5 @@ width=1280 height=800 resizable=true -fullscreen=false \ No newline at end of file +fullscreen=false +vsync=false \ No newline at end of file diff --git a/data/pingpong.ini b/data/pingpong.ini index e4d2a034..70f7d190 100644 --- a/data/pingpong.ini +++ b/data/pingpong.ini @@ -2,4 +2,5 @@ width=800 height=600 resizable=false -fullscreen=false \ No newline at end of file +fullscreen=false +vsync=false \ No newline at end of file diff --git a/data/platformer.ini b/data/platformer.ini index e4d2a034..70f7d190 100644 --- a/data/platformer.ini +++ b/data/platformer.ini @@ -2,4 +2,5 @@ width=800 height=600 resizable=false -fullscreen=false \ No newline at end of file +fullscreen=false +vsync=false \ No newline at end of file diff --git a/data/racing.ini b/data/racing.ini index d28c43f1..c613fccd 100644 --- a/data/racing.ini +++ b/data/racing.ini @@ -2,4 +2,5 @@ width=600 height=600 resizable=false -fullscreen=false \ No newline at end of file +fullscreen=false +vsync=false \ No newline at end of file diff --git a/data/teamgame.ini b/data/teamgame.ini index e4d2a034..70f7d190 100644 --- a/data/teamgame.ini +++ b/data/teamgame.ini @@ -2,4 +2,5 @@ width=800 height=600 resizable=false -fullscreen=false \ No newline at end of file +fullscreen=false +vsync=false \ No newline at end of file diff --git a/data/tiles_example.ini b/data/tiles_example.ini index 5d95eb4f..00e529d4 100644 --- a/data/tiles_example.ini +++ b/data/tiles_example.ini @@ -2,4 +2,5 @@ width=800 height=600 resizable=true -fullscreen=false \ No newline at end of file +fullscreen=false +vsync=false \ No newline at end of file diff --git a/source/dagger/core/graphics/window.cpp b/source/dagger/core/graphics/window.cpp index 4b848598..f76e0c1a 100644 --- a/source/dagger/core/graphics/window.cpp +++ b/source/dagger/core/graphics/window.cpp @@ -138,6 +138,7 @@ void WindowSystem::SpinUp() m_Config.windowHeight = atoi(Engine::GetIniFile().GetValue("window", "height", "600")); m_Config.fullscreen = strcmp(Engine::GetIniFile().GetValue("window", "fullscreen", "false"), "true") == 0; m_Config.resizable = strcmp(Engine::GetIniFile().GetValue("window", "resizable", "false"), "true") == 0; + m_Config.vsync = strcmp(Engine::GetIniFile().GetValue("window", "vsync", "false"), "true") == 0; assert(m_Config.windowWidth > 0 && m_Config.windowHeight > 0); @@ -179,7 +180,14 @@ void WindowSystem::SpinUp() } glfwMakeContextCurrent(window); - glfwSwapInterval(0); + if (m_Config.vsync) + { + glfwSwapInterval(1); + } + else + { + glfwSwapInterval(0); + } if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { diff --git a/source/dagger/core/graphics/window.h b/source/dagger/core/graphics/window.h index 5b1f5a93..47fc6edd 100644 --- a/source/dagger/core/graphics/window.h +++ b/source/dagger/core/graphics/window.h @@ -35,6 +35,7 @@ struct RenderConfig { Bool fullscreen; Bool resizable; + Bool vsync; GLsizei windowWidth; GLsizei windowHeight; GLFWwindow* window; From 80fb3c1c5e0393e8a6b478b7cc985d16dfb12d7b Mon Sep 17 00:00:00 2001 From: Vladimir Vuksanovic Date: Mon, 19 Apr 2021 11:22:02 +0200 Subject: [PATCH 2/2] Fix indentation --- source/dagger/core/graphics/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dagger/core/graphics/window.cpp b/source/dagger/core/graphics/window.cpp index f76e0c1a..bae9df42 100644 --- a/source/dagger/core/graphics/window.cpp +++ b/source/dagger/core/graphics/window.cpp @@ -182,7 +182,7 @@ void WindowSystem::SpinUp() glfwMakeContextCurrent(window); if (m_Config.vsync) { - glfwSwapInterval(1); + glfwSwapInterval(1); } else {