Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Maintain device resolution on window resize for OpenGl #648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading