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

Author Topic: sf::RenderWindow fullscreen switch problem  (Read 16145 times)

0 Members and 1 Guest are viewing this topic.

Puck

  • Newbie
  • *
  • Posts: 8
    • View Profile
sf::RenderWindow fullscreen switch problem
« on: July 15, 2008, 05:33:46 am »
Hi! I'm just starting with SFML and I just want to say great job! I really like the concept and implementation of SFML, and the pre-built mingw libraries are a godsend for me. Usually I have to build my own from .dlls and .libs. :|

Anyway, after reading the tutorials I decided to try a simple test to really get comfortable with the library, but I've run into a small problem:

I'm using the RenderWindow::Create function to toggle between fullscreen and windowed modes, and it works beautifully going from the initial windowed mode to fullscreen, but when switching back the window remains the same size as my desktop, and as far as I can tell from reading the documentation and searching these forums there's no way to resize the window.

I'm using Code::Blocks and MinGW. Can anyone tell me what I'm doing wrong? Is this a quirk with the Windows/MinGW implementation or a bug/limitation in SFML? And if so is there a workaround or should I go ahead and dive into SFML's source? Any help is appreciated! :)

My source:
Code: [Select]
#include <SFML/Graphics.hpp>
using namespace sf;

int main() {
Event input;
bool fullscreen;
RenderWindow App(VideoMode(640, 480, 16), "SFML Test");

while (App.IsOpened()) {
        //Process events
        while (App.GetEvent(input)) {
            //Exit
            if (input.Type == Event::Closed) App.Close();
            if ((input.Type == Event::KeyPressed) && (input.Key.Code == Key::Escape)) App.Close();
            //Fullscreen toggle
            if ((input.Type == Event::KeyPressed) && (input.Key.Code == Key::F)) {
fullscreen = !fullscreen;
App.Create(VideoMode(640, 480, 16), "SFML Test", (fullscreen ? Style::Fullscreen : Style::Resize|Style::Close));
}
        }

        App.Display();
}

return EXIT_SUCCESS;
}


P.S. It seems that it's not just the window size that's off, but the video mode. Displaying a 640x480 image in the window results in a large black space around it after switching to fullscreen and back.

Edit: I knew I was forgetting something. I'm using the latest stable version of SFML: 1.3.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::RenderWindow fullscreen switch problem
« Reply #1 on: July 15, 2008, 07:13:22 am »
Hi

As far as I know, this is not a known bug. I'll try your code to see what's wrong.

Thanks for your feedback :)
Laurent Gomila - SFML developer

Puck

  • Newbie
  • *
  • Posts: 8
    • View Profile
sf::RenderWindow fullscreen switch problem
« Reply #2 on: July 15, 2008, 11:49:52 am »
Thanks, I appreciate it! I know you must be busy maintaining the library, but I can't seem to figure this one out even after looking at the library source. :?


Update: Closing the window with RenderWindow::Close just before the call to RenderWindow::Create solves the issue. I'm still not sure of the cause though, perhaps something is preserved that shouldn't be when Create is called on and existing window?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::RenderWindow fullscreen switch problem
« Reply #3 on: July 15, 2008, 01:14:07 pm »
Yes, I think it has something do to with the fact that the new internal window is created before the old one is destroyed.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::RenderWindow fullscreen switch problem
« Reply #4 on: July 19, 2008, 05:56:20 pm »
Hi

I've tested your code, and it works fine.

However, I changed the window initialization so that the previous internal window is actually destroyed before the new one is created. It should fix your problem.
Laurent Gomila - SFML developer

Puck

  • Newbie
  • *
  • Posts: 8
    • View Profile
sf::RenderWindow fullscreen switch problem
« Reply #5 on: July 20, 2008, 10:35:35 pm »
Ah, good to hear! I assume the change applies to the SVN version of SFML? I'll give it a try. Thanks again! :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::RenderWindow fullscreen switch problem
« Reply #6 on: July 21, 2008, 03:10:53 am »
Quote
I assume the change applies to the SVN version of SFML?

Yes, but I haven't commited the changes yet, because I'm also rewriting all the unicode stuff.
Laurent Gomila - SFML developer

 

anything