SFML community forums
Help => Graphics => Topic started by: soaup on December 26, 2023, 11:19:32 am
-
Hello! My game runs on laptop in fullscreen like this (when the screen resolution is less than 1920*1080):
(https://add.pics/images/2023/12/26/BEZ-IMENI.md.png) (https://add.pics/JUUiBd)
Creating window code:
//BASE_WIDTH - 1920
//BASE_HEIGHT - 1080
bool res = texture->create(BASE_WIDTH, BASE_HEIGHT);
myCout() << "CREATE MAIN TEXTURE - " << res;
if (!res) {
myError() << "ERROR CREATE TEXTURE";
exit(1);
}
textureForShader->create(BASE_WIDTH, BASE_HEIGHT);
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
if (this->fullScreen)
window->create(sf::VideoMode(screenWidth, screenHeight), windowTitle,
sf::Style::Fullscreen, settings);
else
window->create(sf::VideoMode(screenWidth, screenHeight), windowTitle,
sf::Style::Close, settings);
sf::View view( sf::FloatRect(0, 0, (float)screenWidth, (float)screenHeight) );
view.setCenter(BASE_WIDTH/2, BASE_HEIGHT/2);
window->setView(view);
window->setFramerateLimit(60);
window->setVerticalSyncEnabled(true);
Graphics card on my laptops is NVIDIA RTX 2050.
OŃ‚ PC with GeForce GTX 770 everything is fine - the game is stretched to full screen when the screen resolution is less than 1920*1080.
Please answer - what is the problem? drivers?
-
Am I understand you right, that you set the screenWidth and screenHeight to less than your normal display resolution?
You might want to get the valid fullscreen resolutions (https://www.sfml-dev.org/documentation/2.6.1/classsf_1_1VideoMode.php#a0f99e67ef2b51fbdc335d9991232609e) or at least validate your selected resolution (https://www.sfml-dev.org/documentation/2.6.1/classsf_1_1VideoMode.php#ad5e04c044b0925523c75ecb173d2129a), as not every resolution can be "fullscreened" and the driver/window manager is apparently left some room to decide on its own, how it handles such invalid screen resolutions.