SFML community forums
Help => Window => Topic started by: Puck 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:
#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.
-
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 :)
-
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?
-
Yes, I think it has something do to with the fact that the new internal window is created before the old one is destroyed.
-
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.
-
Ah, good to hear! I assume the change applies to the SVN version of SFML? I'll give it a try. Thanks again! :D
-
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.