Hey,
Unfortunately I cannot find my answer in the already existing topics, so here I come. I have some problems with the windowing system, especially with chaning the window style at runtime.
First of all, the window has 3 different mode: Windowed, Borderless and Fullscreen. Borderless and Fullscreen mode means the window's style is simply a WS_POPUP, while the Windowed mode means the window can have borders, system menu, maximize button, and so on. The window has border, caption, minimize-maximize-close buttons by default when selecting Windowed mode.
I'm using the WM_SIZE message to resize the frame buffers (aka render targets). The window does not have a resizing border, so only the engine (and the maximize/restore buttons) can change the size and cause the message to arrive.
I have a function in my Window class which supposed to be used to change the style and/or the resolution of the window. And this is not working. :) Initially, I'm creating a window with the startup settings. Now it's 1280x720 windowed = border + caption. The size is adjusted, so the client area is the 1280x720, the window itself is bigger.
For testing purposes, I'm using the F1-F3 keys to select the new window mode. The resolution is the same for now. I'm also running FRAPS to check if everything is okay. Here are the steps:
0) the window is shown, everything is okay (I have a really simple test scene)
1) switch to borderless mode: it looks like the style is changed (the borders are gone), however the FPS counter is gone and I have a strange "border" at the left and top side of the window. So it seems the style change was not really successful.
2) switch back to windowed mode: everything works again, the FPS counter is back, the window border is back, and the viewport fits.
3) switch to borderless mode again: this is the worst case - a double resize event is raised, first with size 1296x758 (which is the full size of the window with borders) then back to 1280x720. This means a double-resize of textures but the size actually isn't changed. And of course the same problems as in the 1st step.
And here is the code of the window changing function:
void WindowsWindow::Reshape(uint32 width, uint32 height, WindowMode mode)
{
// change style based on window mode change
if (windowMode != mode)
{
windowMode = mode;
//const uint32 styleChangeFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED;
if (mode == WindowMode::Fullscreen || mode == WindowMode::Borderless) // going full-screen
{
SetWindowLongPtr(hwnd, GWL_STYLE, fullscreenStyle);
//SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, styleChangeFlags);
}
else // going windowed
{
SetWindowLongPtr(hwnd, GWL_STYLE, windowedStyle);
//SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, styleChangeFlags);
}
}
uint32 flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_SHOWWINDOW;
int32 x = 0;
int32 y = 0;
// adjust window size and position
if (windowMode == WindowMode::Windowed)
flags |= SWP_NOMOVE;
Adjust(x, y, width, height);
SetWindowPos(hwnd, nullptr, x, y, width, height, flags);
}
I hope someone can help me solve this issue.
Edit:
The code was just changed that's why I have comments and "strange if" there. :)
Edit 2:
If I change the window mode to borderless, I get a window which looks like as in the 2nd image above. However if after this I change the resolution to ... say 1024x768 then back to 1280x720, everything works fine. (Haven't tested fullscreen mode yet, that will be another problem)