Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem creating a fullscreen window in linux  (Read 4254 times)

0 Members and 1 Guest are viewing this topic.

Gabez

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problem creating a fullscreen window in linux
« on: July 30, 2008, 09:53:45 pm »
First of all, thx for such a convenient multi-plataform library!

Now, onto my problem.
I'm trying to create a sf::window under linux. Size and fullscreen/windowed properties are read from a config file. the problem is that for some reason, whenever I create a window with a sf::Style::Fullscreen windowstyle, sfml seems to create it as if I were doing something like
Code: [Select]

sf::Window app(sf::VideoMode::GetMode(0), ...)

The thing is that if I try to create, say a 1024x768x32 fullscreen window, sfml creates a 1280x1024x32 window, showing a 1024x768 view at the lower left corner.

Anyway, I wanted to see if anyone was having the same issue.

Thanks for all,
Gabez.

remi.k2620

  • Full Member
  • ***
  • Posts: 186
    • View Profile
    • http://remi.tuxfamily.org
Problem creating a fullscreen window in linux
« Reply #1 on: July 30, 2008, 10:11:14 pm »
I remember I had a similar problem but didn't test much. You can always solve your problem by using sf::VideoMode::GetDesktopMode() and then define a view (sf::View) that suits your needs.

Gabez

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problem creating a fullscreen window in linux
« Reply #2 on: July 31, 2008, 02:45:26 pm »
Thx for the reply.
The thing is, the game needs to be able to run on fairly old computers, window resolution needs to be flexible.
My question is, Is there a way to force a desktop resolution change when going fullscreen (as in W32)?

Thanks again,
Gabez.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problem creating a fullscreen window in linux
« Reply #3 on: July 31, 2008, 05:07:16 pm »
Yes, it should work as expected.

Can you give more details about your configuration ?
Laurent Gomila - SFML developer

Gabez

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problem creating a fullscreen window in linux
« Reply #4 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.

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);
}