1
Graphics / Re: Game is half off screen when using a view at a lower resolution
« on: May 07, 2023, 01:50:20 am »
Yes I see *Cartman voice*
It's a bit hard to tell exactly what's going without seeing the whole code or knowing which parts are the provided library. Also, I've only been using SFML for a few months and I haven't delved too deep into the realm of dealing with different video resolutions yet.
However I noticed in your first post the window size is 1280 x 720 while the View size is 1920 x 1080. I would try keeping the View size the same as the window size.
So in a pure SFML environment it might look something like:
And then maybe even have it readjust every time the window resizes. So somewhere inside the game loop you would have:
Somehow I doubt this solves everything, but maybe it might help reveal the ultimate solution.
It's a bit hard to tell exactly what's going without seeing the whole code or knowing which parts are the provided library. Also, I've only been using SFML for a few months and I haven't delved too deep into the realm of dealing with different video resolutions yet.
However I noticed in your first post the window size is 1280 x 720 while the View size is 1920 x 1080. I would try keeping the View size the same as the window size.
So in a pure SFML environment it might look something like:
sf::RenderWindow window;
sf::View view;
window.create(
sf::VideoMode(1920, 1080),
"Game Name",
sf::Style::Fullscreen
);
// As far as I can tell, the initial size for video mode above kind of doesnt matter if youre doing Style::Fullscreen or Style::Default because the window will be automatically resized based on the operating system environment.
sf::Vector2u windowSize = window.getSize(); // Get the actual size of the window now that it exists.
view.setSize(windowSize.x, windowSize.y);
sf::View view;
window.create(
sf::VideoMode(1920, 1080),
"Game Name",
sf::Style::Fullscreen
);
// As far as I can tell, the initial size for video mode above kind of doesnt matter if youre doing Style::Fullscreen or Style::Default because the window will be automatically resized based on the operating system environment.
sf::Vector2u windowSize = window.getSize(); // Get the actual size of the window now that it exists.
view.setSize(windowSize.x, windowSize.y);
And then maybe even have it readjust every time the window resizes. So somewhere inside the game loop you would have:
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Resized)
view.setSize(event.size.width, event.size.height);
}
while (window.pollEvent(event)) {
if (event.type == sf::Event::Resized)
view.setSize(event.size.width, event.size.height);
}
Somehow I doubt this solves everything, but maybe it might help reveal the ultimate solution.