Merge pull request #200 from victorlevasseur/bugfix/resolution-change-and-fullscreen

Fix Vsync and Max FPS not reactived after a sf::RenderWindow change
This commit is contained in:
Florian Rival
2015-09-16 20:24:10 +02:00
5 changed files with 13 additions and 14 deletions

View File

@@ -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"));

View File

@@ -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
}

View File

@@ -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);

View File

@@ -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();
}

View File

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