1
Window / Problem creating a fullscreen window in linux
« on: August 05, 2008, 04:12:10 pm »
Sorry for the delay in responding, we had a mayor internet crash at the office.
After a lot of debuging, I found that my video card's driver is not supporting several very low end configurations in linux (such as 640x480x16bpp), wich is really what I was aiming for. Gonna need to get my hands on older hardware.
Of course, sfml was responding as intended, switching to the best resolution available when asked to use unsupported resolutions. My mistake was assuming that resolutions supported in win32 were also present in my linux driver. It turned out to be unrelated to sfml.
I had to come to a compromise, in order to try and ensure that very old computers can run the game (not my choise in the matter).
I'll post my code just for reference, it might help someone.
After a lot of debuging, I found that my video card's driver is not supporting several very low end configurations in linux (such as 640x480x16bpp), wich is really what I was aiming for. Gonna need to get my hands on older hardware.
Of course, sfml was responding as intended, switching to the best resolution available when asked to use unsupported resolutions. My mistake was assuming that resolutions supported in win32 were also present in my linux driver. It turned out to be unrelated to sfml.
I had to come to a compromise, in order to try and ensure that very old computers can run the game (not my choise in the matter).
I'll post my code just for reference, it might help someone.
Code: [Select]
sf::WindowSettings Settings;
if ( ScreamConfig::quality == 1 ) {
Settings.DepthBits = 24;
Settings.AntialiasingLevel = 2;
} else
Settings.DepthBits = 16;
if ( ScreamConfig::fullscreen ) {
sf::VideoMode requestedMode(ScreamConfig::width,ScreamConfig::height,ScreamConfig::depth);
if ( requestedMode.IsValid() )
m_pkWindow = new sf::Window(requestedMode, "Perfil de Riesgo", sf::Style::Fullscreen, Settings);
else {
vector<sf::VideoMode> validModes;
unsigned int VideoModesCount = sf::VideoMode::GetModesCount();
for (unsigned int i = 0; i < VideoModesCount; ++i)
validModes.push_back( sf::VideoMode::GetMode(i) );
// Try to find the nearest valid mode
if ( ScreamConfig::quality == 0 ) {
vector<sf::VideoMode>::const_reverse_iterator iter;
for ( iter = validModes.rbegin(); iter != validModes.rend(); ++iter) {
if ( (*iter).Width == requestedMode.Width && (*iter).Height == requestedMode.Height ) {
m_pkWindow = new sf::Window((*iter), "Perfil de Riesgo", sf::Style::Fullscreen, Settings);
break;
}
}
} else {
vector<sf::VideoMode>::const_iterator iter;
for ( iter = validModes.begin(); iter != validModes.end(); ++iter ) {
if ( (*iter).Width == requestedMode.Width && (*iter).Height == requestedMode.Height ) {
m_pkWindow = new sf::Window((*iter), "Perfil de Riesgo", sf::Style::Fullscreen, Settings);
break;
}
}
}
if ( !m_pkWindow ) {
// Couldn't find, go windowed
RenderError(...);
sf::VideoMode desktopVideoMode = sf::VideoMode::GetDesktopMode();
m_pkWindow = new sf::Window(sf::VideoMode(ScreamConfig::width,ScreamConfig::height,desktopVideoMode.BitsPerPixel),
"Perfil de Riesgo", sf::Style::Close, Settings);
}
}
} else {
sf::VideoMode desktopVideoMode = sf::VideoMode::GetDesktopMode();
m_pkWindow = new sf::Window(sf::VideoMode(ScreamConfig::width,ScreamConfig::height,desktopVideoMode.BitsPerPixel),
"Perfil de Riesgo", sf::Style::Close, Settings);
}