Skip to content

Commit

Permalink
Workaround weird resize-bug on UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Oct 3, 2023
1 parent 3984daa commit 7b72867
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sdl/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void Window::UpdateInput() {
}
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
if (!impl->firstFrame && event.window.event == SDL_WINDOWEVENT_RESIZED) {
const int originalWidth = width_;
const int originalHeight = height_;
SDL_GL_GetDrawableSize(impl->sdlWindow, &width_, &height_);
Expand Down Expand Up @@ -416,6 +416,7 @@ void Window::UpdateInput() {

void Window::SwapBuffers() {
SDL_GL_SwapWindow(impl->sdlWindow);
impl->firstFrame = false;
}

void Window::SetMouseVisible(const bool visible) {
Expand Down
4 changes: 4 additions & 0 deletions src/sdl/windowimpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class WindowImpl {

/// For Retina screens on macOS SDL does its own scaling of mouse coordinates, etc. :(
float hidpiScaleFactor;

/// On UWP there's a bug that sometimes there are "wrong" resize events at startup (maybe due to
/// fullscreen mode?). Just skipping them until the first frame is drawn is a workaround.
bool firstFrame = true;
};

} // namespace jngl

0 comments on commit 7b72867

Please sign in to comment.