In working on my Asteroids project, I began using sf::Views and sf::Style::Fullscreen.
My monitor's native resolution is 1366 x 768 (16:9), so I was typically using sf::Style::Fullscreen to have the game run fullscreen and this all worked fine; however, as soon as I started using Views it began warping the game.
Ie. all of the planets became egg-shaped (The entire game was stretched across the X axis to fill the monitor)
I'm curious how to fix this, either changing the definition of sf::View or changing how the RenderWindow is initialized... Any help would be greatly appreciated.
Here is the related code:
//In main.cpp
{
sf::Vector2f Center(5000, 5000);
sf::Vector2f HalfSize(512, 384);
sf::View View(Center, HalfSize);
sf::RenderWindow App;
App.Create(sf::VideoMode::GetDesktopMode(0), "Onyx [Alpha]", sf::Style::Fullscreen);
{
App.SetView(View);
if (App.GetInput().IsKeyDown(sf::Key::Add)) View.Zoom(1.1f);
if (App.GetInput().IsKeyDown(sf::Key::Subtract)) View.Zoom(0.9f);
View.SetCenter(pl.RenderPlayerX, pl.RenderPlayerY);
App.SetView(App.GetDefaultView()); //Sets View to be correct for drawing the HUD
App.Draw(SHealth);
App.Draw(STempTop);
App.Draw(HealthText);
App.Draw(EnergyText); //Draws the HUD
App.Draw(FuelText);
App.Draw(CurrencyText);
App.SetView(View);
App.Display();
}
return EXIT_SUCCESS;
}
Here is a picture of the warped game: