Skip to content

Commit

Permalink
Merge pull request #200 from victorlevasseur/bugfix/resolution-change…
Browse files Browse the repository at this point in the history
…-and-fullscreen

Fix Vsync and Max FPS not reactived after a sf::RenderWindow change
  • Loading branch information
4ian committed Sep 16, 2015
2 parents a0246dd + 0092841 commit 3b221ae
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Core/GDCore/PlatformDefinition/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void Project::UnserializeFrom(const SerializerElement & element)
SetDefaultHeight(propElement.GetChild("windowHeight", 0, "WindowH").GetValue().GetInt());
SetMaximumFPS(propElement.GetChild("maxFPS", 0, "FPSmax").GetValue().GetInt());
SetMinimumFPS(propElement.GetChild("minFPS", 0, "FPSmin").GetValue().GetInt());
SetVerticalSyncActivatedByDefault(propElement.GetChild("verticalSync").GetValue().GetInt());
SetVerticalSyncActivatedByDefault(propElement.GetChild("verticalSync").GetValue().GetBool());
#if defined(GD_IDE_ONLY)
SetAuthor(propElement.GetChild("author", 0, "Auteur").GetValue().GetString());
SetPackageName(propElement.GetStringAttribute("packageName"));
Expand Down
16 changes: 6 additions & 10 deletions GDCpp/GDCpp/BuiltinExtensions/RuntimeSceneTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,12 @@ void GD_API SetWindowSize( RuntimeScene & scene, int windowWidth, int windowHeig
if ( windowWidth == scene.renderWindow->getSize().x && windowHeight == scene.renderWindow->getSize().y )
return;

if ( scene.RenderWindowIsFullScreen() )
{
scene.renderWindow->create( sf::VideoMode( windowWidth, windowHeight, 32 ), scene.GetWindowDefaultTitle(), sf::Style::Close | sf::Style::Fullscreen );
scene.ChangeRenderWindow(scene.renderWindow);
}
else
{
scene.renderWindow->create( sf::VideoMode( windowWidth, windowHeight, 32 ), scene.GetWindowDefaultTitle(), sf::Style::Close );
scene.ChangeRenderWindow(scene.renderWindow);
}

scene.renderWindow->create(
sf::VideoMode( windowWidth, windowHeight, 32 ),
scene.GetWindowDefaultTitle(),
sf::Style::Close | (scene.RenderWindowIsFullScreen() ? sf::Style::Fullscreen : 0) );
scene.ChangeRenderWindow(scene.renderWindow);
#endif
}

Expand Down
1 change: 0 additions & 1 deletion GDCpp/GDCpp/IDE/Dialogs/CppLayoutPreviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ void CppLayoutPreviewer::OnPreviewPlayWindowBtClick( wxCommandEvent & event )
externalPreviewWindow = std::shared_ptr<RenderDialog>(new RenderDialog(editor.GetParentControl(), this) );

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

externalPreviewWindow->SetSizeOfRenderingZone(editor.GetProject().GetMainWindowDefaultWidth(), editor.GetProject().GetMainWindowDefaultHeight());
previewScene.ChangeRenderWindow(externalPreviewWindow->renderCanvas);
Expand Down
6 changes: 6 additions & 0 deletions GDCpp/GDCpp/RuntimeScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ void RuntimeScene::ChangeRenderWindow(sf::RenderWindow * newWindow)
if (!renderWindow) return;

renderWindow->setTitle(GetWindowDefaultTitle());

if(game)
{
renderWindow->setFramerateLimit(game->GetMaximumFPS());
renderWindow->setVerticalSyncEnabled(game->IsVerticalSynchronizationEnabledByDefault());
}
SetupOpenGLProjection();
}

Expand Down
2 changes: 0 additions & 2 deletions GDCpp/Runtime/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ int main( int argc, char *p_argv[] )
window.create(sf::VideoMode(game.GetMainWindowDefaultWidth(), game.GetMainWindowDefaultHeight(), 32),
"", sf::Style::Close);
window.setActive(true);
window.setFramerateLimit(game.GetMaximumFPS());
window.setVerticalSyncEnabled(game.IsVerticalSynchronizationEnabledByDefault());

//Game main loop
bool abort = false;
Expand Down

0 comments on commit 3b221ae

Please sign in to comment.