diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 5d8e61a653..3878df70b1 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -1327,11 +1327,11 @@ bool FramebufferManager::GetCurrentFramebuffer(GPUDebugBuffer &buffer) return true; } - buffer.Allocate(vfb->fb_stride, vfb->height, GE_FORMAT_8888); + buffer.Allocate(vfb->renderWidth, vfb->renderHeight, GE_FORMAT_8888); fbo_bind_for_read(vfb->fbo); glPixelStorei(GL_PACK_ALIGNMENT, 4); - glReadPixels(0, 0, vfb->fb_stride, vfb->height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.GetData()); + glReadPixels(0, 0, vfb->renderWidth, vfb->renderHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.GetData()); return true; } diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index a37c9fc695..12ef88e4ef 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -145,7 +145,7 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { if (bufferResult) { if (buffer.GetFormat() == GE_FORMAT_8888) { - frameWindow->Draw(buffer.GetData(), buffer.GetStride(), buffer.GetHeight()); + frameWindow->Draw(buffer.GetData(), buffer.GetStride(), buffer.GetHeight(), SimpleGLWindow::RESIZE_SHRINK_FIT); } else { ERROR_LOG(COMMON, "Non-8888 buffers not yet supported."); frameWindow->Clear(); diff --git a/Windows/GEDebugger/SimpleGLWindow.cpp b/Windows/GEDebugger/SimpleGLWindow.cpp index 04ee66efc1..12bf2f51ee 100644 --- a/Windows/GEDebugger/SimpleGLWindow.cpp +++ b/Windows/GEDebugger/SimpleGLWindow.cpp @@ -140,7 +140,7 @@ void SimpleGLWindow::CreateProgram() { glsl_unbind(); } -void SimpleGLWindow::Draw(u8 *data, int w, int h) { +void SimpleGLWindow::Draw(u8 *data, int w, int h, ResizeType resize) { wglMakeCurrent(hDC_, hGLRC_); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); @@ -160,6 +160,18 @@ void SimpleGLWindow::Draw(u8 *data, int w, int h) { glsl_bind(drawProgram_); float fw = (float)w, fh = (float)h; + if (resize == RESIZE_SHRINK_FIT) { + float wscale = fw / w_, hscale = fh / h_; + + // Too wide, and width is the biggest problem, so scale based on that. + if (wscale > 1.0f && wscale > hscale) { + fw = (float)w_; + fh /= wscale; + } else if (hscale > 1.0f) { + fw /= hscale; + fh = (float)h_; + } + } const float pos[12] = {0,0,0, fw,0,0, fw,fh,0, 0,fh,0}; const float texCoords[8] = {0,1, 1,1, 1,0, 0,0}; const GLubyte indices[4] = {0,1,3,2}; diff --git a/Windows/GEDebugger/SimpleGLWindow.h b/Windows/GEDebugger/SimpleGLWindow.h index 562c971465..97479d2ccc 100644 --- a/Windows/GEDebugger/SimpleGLWindow.h +++ b/Windows/GEDebugger/SimpleGLWindow.h @@ -24,6 +24,11 @@ struct SimpleGLWindow { static const PTCHAR windowClass; + enum ResizeType { + RESIZE_NONE, + RESIZE_SHRINK_FIT, + }; + SimpleGLWindow(HINSTANCE hInstance, HWND hParent, int x, int y, int w, int h); ~SimpleGLWindow() { if (drawProgram_ != NULL) { @@ -41,7 +46,7 @@ struct SimpleGLWindow { void CreateProgram(); void Clear(); - void Draw(u8 *data, int w, int h); + void Draw(u8 *data, int w, int h, ResizeType resize = RESIZE_NONE); void Swap() { SwapBuffers(hDC_);