Skip to content

Commit 3b221ae

Browse files
committed
Merge pull request #200 from victorlevasseur/bugfix/resolution-change-and-fullscreen
Fix Vsync and Max FPS not reactived after a sf::RenderWindow change
2 parents a0246dd + 0092841 commit 3b221ae

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

Core/GDCore/PlatformDefinition/Project.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ void Project::UnserializeFrom(const SerializerElement & element)
527527
SetDefaultHeight(propElement.GetChild("windowHeight", 0, "WindowH").GetValue().GetInt());
528528
SetMaximumFPS(propElement.GetChild("maxFPS", 0, "FPSmax").GetValue().GetInt());
529529
SetMinimumFPS(propElement.GetChild("minFPS", 0, "FPSmin").GetValue().GetInt());
530-
SetVerticalSyncActivatedByDefault(propElement.GetChild("verticalSync").GetValue().GetInt());
530+
SetVerticalSyncActivatedByDefault(propElement.GetChild("verticalSync").GetValue().GetBool());
531531
#if defined(GD_IDE_ONLY)
532532
SetAuthor(propElement.GetChild("author", 0, "Auteur").GetValue().GetString());
533533
SetPackageName(propElement.GetStringAttribute("packageName"));

GDCpp/GDCpp/BuiltinExtensions/RuntimeSceneTools.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,12 @@ void GD_API SetWindowSize( RuntimeScene & scene, int windowWidth, int windowHeig
277277
if ( windowWidth == scene.renderWindow->getSize().x && windowHeight == scene.renderWindow->getSize().y )
278278
return;
279279

280-
if ( scene.RenderWindowIsFullScreen() )
281-
{
282-
scene.renderWindow->create( sf::VideoMode( windowWidth, windowHeight, 32 ), scene.GetWindowDefaultTitle(), sf::Style::Close | sf::Style::Fullscreen );
283-
scene.ChangeRenderWindow(scene.renderWindow);
284-
}
285-
else
286-
{
287-
scene.renderWindow->create( sf::VideoMode( windowWidth, windowHeight, 32 ), scene.GetWindowDefaultTitle(), sf::Style::Close );
288-
scene.ChangeRenderWindow(scene.renderWindow);
289-
}
280+
281+
scene.renderWindow->create(
282+
sf::VideoMode( windowWidth, windowHeight, 32 ),
283+
scene.GetWindowDefaultTitle(),
284+
sf::Style::Close | (scene.RenderWindowIsFullScreen() ? sf::Style::Fullscreen : 0) );
285+
scene.ChangeRenderWindow(scene.renderWindow);
290286
#endif
291287
}
292288

GDCpp/GDCpp/IDE/Dialogs/CppLayoutPreviewer.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ void CppLayoutPreviewer::OnPreviewPlayWindowBtClick( wxCommandEvent & event )
275275
externalPreviewWindow = std::shared_ptr<RenderDialog>(new RenderDialog(editor.GetParentControl(), this) );
276276

277277
externalPreviewWindow->Show(true);
278-
externalPreviewWindow->renderCanvas->setFramerateLimit( previewGame.GetMaximumFPS() );
279278

280279
externalPreviewWindow->SetSizeOfRenderingZone(editor.GetProject().GetMainWindowDefaultWidth(), editor.GetProject().GetMainWindowDefaultHeight());
281280
previewScene.ChangeRenderWindow(externalPreviewWindow->renderCanvas);

GDCpp/GDCpp/RuntimeScene.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ void RuntimeScene::ChangeRenderWindow(sf::RenderWindow * newWindow)
9292
if (!renderWindow) return;
9393

9494
renderWindow->setTitle(GetWindowDefaultTitle());
95+
96+
if(game)
97+
{
98+
renderWindow->setFramerateLimit(game->GetMaximumFPS());
99+
renderWindow->setVerticalSyncEnabled(game->IsVerticalSynchronizationEnabledByDefault());
100+
}
95101
SetupOpenGLProjection();
96102
}
97103

GDCpp/Runtime/main.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ int main( int argc, char *p_argv[] )
174174
window.create(sf::VideoMode(game.GetMainWindowDefaultWidth(), game.GetMainWindowDefaultHeight(), 32),
175175
"", sf::Style::Close);
176176
window.setActive(true);
177-
window.setFramerateLimit(game.GetMaximumFPS());
178-
window.setVerticalSyncEnabled(game.IsVerticalSynchronizationEnabledByDefault());
179177

180178
//Game main loop
181179
bool abort = false;

0 commit comments

Comments
 (0)