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

Author Topic: Fullscreen problem  (Read 12889 times)

0 Members and 1 Guest are viewing this topic.

andreaszdw

  • Newbie
  • *
  • Posts: 26
    • View Profile
Fullscreen problem
« on: March 11, 2009, 08:02:38 am »
If I switch from windowed to fullscreen with this:

Code: [Select]

void CGameEngine::Init(const char* title, int width, int height, int bpp, bool fullscreen)
{
   App = new sf::RenderWindow (sf::VideoMode(width, height, bpp), title, sf::Style::Close);

   App->Close ();

   App->Create (sf::VideoMode(800, 600), "SFML Window", sf::Style::Fullscreen);

   App->SetFramerateLimit (60);
}


I get this message:

Quote

The requested video mode is not available, switching to a valid mode


Than the old resolution (not 800, 600 like wanted) is switched to fullscreen.

I have this problem only on linux. I have tested if 800, 600 is a valid mode.

What's my problem?

Andreas

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Fullscreen problem
« Reply #1 on: March 11, 2009, 11:07:43 am »
You can print the list of valid video modes returned by SFML. If it's empty or if it looks weird, there's probably a bug somewhere :)
Laurent Gomila - SFML developer

andreaszdw

  • Newbie
  • *
  • Posts: 26
    • View Profile
Valid modes
« Reply #2 on: March 11, 2009, 11:20:18 am »
Yes, I have done it with this:

Code: [Select]
unsigned int VideoModesCount = sf::VideoMode::GetModesCount();
for (unsigned int i = 0; i < VideoModesCount; ++i)
{
   sf::VideoMode Mode = sf::VideoMode::GetMode(i);
   // Mode is a valid video mode
   std::cout << "Mode " << Mode.Width << "-" << Mode.Height << "-" << Mode.BitsPerPixel << " is valid" << std::endl;
}


The mode is valid, but it doesn't work.

Andreas

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Fullscreen problem
« Reply #3 on: March 11, 2009, 02:17:30 pm »
Damn! Try inserting an "assert(Mode.IsValid())" in your loop.
Laurent Gomila - SFML developer

andreaszdw

  • Newbie
  • *
  • Posts: 26
    • View Profile
BitsPerPixel is the problem
« Reply #4 on: March 11, 2009, 09:59:17 pm »
I have found my problem.

If I do this:



Code: [Select]
unsigned int VideoModesCount = sf::VideoMode::GetModesCount();
   for (unsigned int i = 0; i < VideoModesCount; ++i)
   {
       sf::VideoMode Mode = sf::VideoMode::GetMode(i);
       // Mode is a valid video mode
       std::cout << "Mode " << Mode.Width << "-" << Mode.Height << "-" << Mode.BitsPerPixel << " is valid" << std::endl;
   }


I get this in the console:

Quote
Mode 1280-1024-32 is valid
Mode 1280-960-32 is valid
Mode 1152-864-32 is valid
Mode 1024-768-32 is valid
Mode 960-600-32 is valid
Mode 960-540-32 is valid
Mode 840-525-32 is valid
Mode 832-624-32 is valid
Mode 800-600-32 is valid
Mode 800-512-32 is valid
Mode 720-450-32 is valid
Mode 680-384-32 is valid
Mode 640-512-32 is valid
Mode 640-480-32 is valid
Mode 576-432-32 is valid
Mode 512-384-32 is valid
Mode 416-312-32 is valid
Mode 400-300-32 is valid
Mode 320-240-32 is valid


But my monitor knows only up to 24 BitsPerPixel.

So I change my mode to 24 BitsPerPixel and the mode is not
valid and it switches with this in your code to the nearest mode:

Code: [Select]
void Window::Create(VideoMode Mode, const std::string& Title, unsigned long WindowStyle, const WindowSettings& Params)

{

    // Check validity of video mode

    if ((WindowStyle & Style::Fullscreen) && !Mode.IsValid())

    {

        std::cerr << "The requested video mode is not available, switching to a valid mode" << std::endl;

        Mode = VideoMode::GetMode(0);

    }



    // Check validity of style

    if ((WindowStyle & Style::Close) || (WindowStyle & Style::Resize))

        WindowStyle |= Style::Titlebar;



    // Destroy the previous window implementation

    delete myWindow;



    // Activate the global context

    Context::GetGlobal().SetActive(true);



    mySettings = Params;

    Initialize(priv::WindowImpl::New(Mode, Title, WindowStyle, mySettings));

}


And this mode is on my computer 1280 - 1024 - 24.

Can I change somewhere the valid modes to 24 BitsPerPixel?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Fullscreen problem
« Reply #5 on: March 12, 2009, 09:28:33 pm »
Ok, I've found the problem. At the time I implemented video modes on Linux (2 years ago!), I used a hard-coded value of 32 because I couldn't find a way to get the real depth :)

I'll look into it once again, maybe I'll found something now.
Laurent Gomila - SFML developer

andreaszdw

  • Newbie
  • *
  • Posts: 26
    • View Profile
depth
« Reply #6 on: March 12, 2009, 09:54:34 pm »
Thanks for your help.

Andreas

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Fullscreen problem
« Reply #7 on: March 12, 2009, 10:08:29 pm »
It's fixed.
Laurent Gomila - SFML developer

 

anything