SFML community forums
Help => Window => Topic started by: JCSopko on March 14, 2011, 06:45:10 pm
-
I was unsure whether to put this here or in the Graphics forum but basically I'm trying to set my camera view to a size of an equal aspect ratio of the monitor.
VideoMode videoMode = sf::VideoMode::GetDesktopMode();
float aspectRatio = (float)videoMode.Width/(float)videoMode.Height;
float screenSize = 380;
scene->view = new sf::View(sf::FloatRect(0, 0, screenSize, screenSize/aspectRatio));
Hypothetically this should work with any given screenSize but I'm still getting pretty profound distortion with certain numbers (such as 800 on a 16:9 monitor).
Is there a better way to control the field of view while still keeping the proper aspect ratio (no stretching) no matter what monitor you're on?
Thanks!
-
Noone?
-
Shouldn't you use multiplication in the last argument when constructing the view? The height should be smaller if the ratio is <0
-
Aspect ratio is width divided by height. Width is the larger number on just about all monitors. For example the aspect ratio derived from my monitor is 16 divided by 9 which comes out to be about 1.777778. So division is the proper operation.
What I need to do is find an equation to be able to identify when distortion will occur and then increase the view marginally to prevent distortion.
I was hoping someone already has done this or it was built into SFML somehow but I've still gotten no reply. =[