-
So after reading up on fullscreen in SFML, I came up with this little function:
void SED::RenderHandle::SEF_SetFullscreen(bool fullscreen) {
if (fullscreen)
SEV_GameWindow->create(sf::VideoMode(SEV_WindowWidth, SEV_WindowHeight, 32), SEV_WindowTitle, sf::Style::Fullscreen);
else
SEV_GameWindow->create(sf::VideoMode(SEV_WindowWidth, SEV_WindowHeight, 32), SEV_WindowTitle);
}
Obviously it doesn't work, it just crashes the program and sets the monitor to 640 * 480 (the previous resolution), but my question is, what did I do wrong? When I read the documentation, it said that sf::Window::create can be used to recreate the window, not just initialize it. So I assumed recreating it with the fullscreen flag would work? I also tried it with using sf::VideoMode::getFullscreenModes()[0] instead of sf::VideoMode(SEV_WindowWidth, SEV_WindowHeight, 32) for fullscreen, and that seemed to keep the monitor size, but still crashed the program.
So I guess what I'm asking is how do you activate/toggle fullscreen?
-
You can change the "fullscreeniness" of a window by using create to re-create it with a fullscreen style, as you have done.
It is probable that the reason the fullscreen resorts to a default size is because the video mode that you are attempting to assigning is not a supported fullscreen mode. This is evident by getFullscreenModes stopping that occurring.
So, now you can re-create the window in fullscreen -
SEV_GameWindow->create(sf::VideoMode::getFullscreenModes()[0], SEV_WindowTitle, sf::Style::Fullscreen);
- the problem is the now occurring crash, about which you have not provided any details.
-
Yes, I forgot to include the crash info.
(http://i.imgur.com/Mcy2qZT.png)
Sorry for the big image size, I had to capture the whole screen through ShareX because I couldn't get snipping tool to work there.
I also get this in the console window
(http://i.imgur.com/zjVAGfG.png)
(I was also unable to just straight copy the contents of the console for some reason...) I have no idea what either of those errors mean, so I'm quite clueless on this issue.
-
It crashes on your (I assume) screenshot function, where you call update(window, x, y) on a texture. What's your x and y value there? Sounds like you need to resize the texture as well in order to make a screenshot of larger window.
-
Well, you're right, I wasn't resizing the texture, so I fixed that part by setting the window width/height variables after calling that function; then before the screen is rendered and shaders are applied, it runs this code to make sure that the texture is up to spec with the screen size
if (SEV_Screen.tex.getSize().x != SEV_WindowWidth || SEV_Screen.tex.getSize().y != SEV_WindowHeight) {
SEV_Screen.tex.create(SEV_WindowWidth, SEV_WindowHeight);
SEV_Screen.spr.setTexture(SEV_Screen.tex);
}
A few more printf's revealed that SEV_WindowWidth/Height are the right size (1366 and 768 respectively), yet now I just get this error.
(http://i.imgur.com/lo52kiN.png)
That error occurs when
SEV_Screen.tex.update(*SEV_GameWindow);
is called; but I know that the texture is the right size. (I also tested the texture size)
(Btw thanks for the help thus far)
-
Your pointer is null (notice the 0x0000... as in you other thread).
-
Sadly, its a valid pointer. I tested if it was either NULL or nullptr before calling that, and it is not a null pointer.
-
(I'm assuming since this is a day later, this isn't a bump. Sorry if it is...)
Okay so I couldn't tell you what went wrong even if I wanted to, but what I did was after switching to fullscreen, I added a variable that waits a frame until re-adding the whole screen shader (the problem line), and that seemed to fix everything. I got the idea from this (https://github.com/SFML/SFML/issues/160) Github issue, which would lead me to believe that the issue is not limited to Linux.
Anyway, thanks for the help you guys!