I'm getting some weird FPS issues using views to maintain the drawing ratio like you suggested. Are there any bugs in SFML that make this happen or is this a problem on my part? It seems really odd to me because with the zoom, it actually uses LESS render calls because I optimized it to not draw tiles outside of the view.
Main Menu State-GUI (w/o view)
400~ FPS / 8 window.draw() calls
-GUI (w/ views + zooming)
170~ FPS / 8 window.draw() calls
Game State-Game (w/o view)
300~ FPS / 1875 window.draw() calls (I'm going to optimize this, don't worry
)
-Game (w/ view)
100~ FPS / 1875 window.draw() calls
-Game (w/ view + zoom)
40 FPS / 768 window.draw() calls
Every loop I go through this in the camera class:
// Move the camera to the center of the player
bool changedView = false;
if(you->getSprite().getPosition().x < x + ((gl::Vars::screenW / 1.5) / 2) - 100)
{
changedView = true;
view.move(-1, 0);
x-=1;
}
else if(you->getSprite().getPosition().x > 100 + x + ((gl::Vars::screenW / 1.5) / 2))
{
changedView = true;
view.move(1, 0);
x+=1;
}
if(you->getSprite().getPosition().y < y + ((gl::Vars::screenH / 1.5) / 2) - 100)
{
changedView = true;
view.move(0, -1);
y-=1;
}
else if(you->getSprite().getPosition().y > 100 + y + ((gl::Vars::screenH / 1.5) / 2))
{
changedView = true;
view.move(0, 1);
y+=1;
}
if(changedView)
{
//view.reset(sf::FloatRect(x, y, gl::Vars::screenW / 1.5, gl::Vars::screenH / 1.5));
gl::Win.setView(view);
}
It essentially gets the position of the player and if the player goes outside of the bounding box, it moves the camera accordingly.
Suggestions? 40 FPS is not acceptable for me. I should be getting around 400 considering the meager amount of tiles I'm drawing. It also is preventing me from recording my game with FRAPs, as I get only 15 FPS.