Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vsync option to ini files #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion data/editor.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
width=1280
height=800
resizable=true
fullscreen=false
fullscreen=false
vsync=false
3 changes: 2 additions & 1 deletion data/pingpong.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
width=800
height=600
resizable=false
fullscreen=false
fullscreen=false
vsync=false
3 changes: 2 additions & 1 deletion data/platformer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
width=800
height=600
resizable=false
fullscreen=false
fullscreen=false
vsync=false
3 changes: 2 additions & 1 deletion data/racing.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
width=600
height=600
resizable=false
fullscreen=false
fullscreen=false
vsync=false
3 changes: 2 additions & 1 deletion data/teamgame.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
width=800
height=600
resizable=false
fullscreen=false
fullscreen=false
vsync=false
3 changes: 2 additions & 1 deletion data/tiles_example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
width=800
height=600
resizable=true
fullscreen=false
fullscreen=false
vsync=false
10 changes: 9 additions & 1 deletion source/dagger/core/graphics/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -179,7 +180,14 @@ void WindowSystem::SpinUp()
}

glfwMakeContextCurrent(window);
glfwSwapInterval(0);
if (m_Config.vsync)
{
glfwSwapInterval(1);
}
else
{
glfwSwapInterval(0);
}

if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
Expand Down
1 change: 1 addition & 0 deletions source/dagger/core/graphics/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct RenderConfig
{
Bool fullscreen;
Bool resizable;
Bool vsync;
GLsizei windowWidth;
GLsizei windowHeight;
GLFWwindow* window;
Expand Down