Skip to content

Commit

Permalink
Maintain device resolution on window resize for OpenGl
Browse files Browse the repository at this point in the history
  • Loading branch information
Coiland committed Nov 28, 2024
1 parent 1a40dec commit f4bc048
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/core/renderer_gl/renderer_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
}

void RendererGL::display() {

static u32 lastWidth = outputWindowWidth;
static u32 lastHeight = outputWindowHeight;

gl.disableScissor();
gl.disableBlend();
gl.disableDepth();
Expand Down Expand Up @@ -580,9 +584,18 @@ void RendererGL::display() {
}

if constexpr (!Helpers::isHydraCore()) {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
screenFramebuffer.bind(OpenGL::ReadFramebuffer);
glBlitFramebuffer(0, 0, 400, 480, 0, 0, outputWindowWidth, outputWindowHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);

const u32 newX0 = (outputWindowWidth - 400) / 2;
const u32 newY0 = (outputWindowHeight - 480) / 2;
if(lastWidth != outputWindowWidth || lastHeight != outputWindowHeight) {
lastHeight = outputWindowHeight;
lastWidth = outputWindowWidth;
glClear(GL_COLOR_BUFFER_BIT);
}

glBlitFramebuffer(0, 0, 400, 480, newX0, newY0, newX0 + 400, newY0 + 480, GL_COLOR_BUFFER_BIT, GL_LINEAR);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/panda_sdl/frontend_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ FrontendSDL::FrontendSDL() : keyboardMappings(InputMappings::defaultKeyboardMapp
}
#endif

SDL_SetWindowMinimumSize(window, 400, 480);

emu.initGraphicsContext(window);
}

Expand Down

0 comments on commit f4bc048

Please sign in to comment.