From 2a56d36b126e3d188a8320f206e7b8ac2f3b1d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 20 Nov 2012 16:48:24 +0100 Subject: [PATCH] glViewport calls need to be in pixel coordinates. --- Core/CoreParameter.h | 7 +++++++ GPU/GLES/DisplayListInterpreter.cpp | 4 ++-- Windows/EmuThread.cpp | 18 ++++++++++-------- android/jni/EmuScreen.cpp | 4 +++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Core/CoreParameter.h b/Core/CoreParameter.h index a39385f5b521..bd9b219e62da 100644 --- a/Core/CoreParameter.h +++ b/Core/CoreParameter.h @@ -49,8 +49,15 @@ struct CoreParameter bool printfEmuLog; // writes "emulator:" logging to stdout bool headLess; // Try to avoid messageboxes etc + // Internal PSP resolution int renderWidth; int renderHeight; + + // Virtual (dpi-adjusted) output resolution int outputWidth; int outputHeight; + + // Actual pixel output resolution (for use by glViewport and the like) + int pixelWidth; + int pixelHeight; }; diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index adcb193fd26f..bb5ac7cf614e 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -82,7 +82,7 @@ void GLES_GPU::InitClear() // glClearColor(1,0,1,1); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); } - glViewport(0, 0, renderWidth_, renderHeight_); + glViewport(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); } void GLES_GPU::BeginFrame() @@ -115,7 +115,7 @@ void GLES_GPU::CopyDisplayToOutput() VirtualFramebuffer *vfb = GetDisplayFBO(); fbo_unbind(); - glViewport(0, 0, PSP_CoreParameter().outputWidth, PSP_CoreParameter().outputHeight); + glViewport(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); currentRenderVfb_ = 0; diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 518722748176..da27fd68041b 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -60,18 +60,20 @@ DWORD TheThread(LPVOID x) INFO_LOG(BOOT, "Starting up hardware."); - CoreParameter coreParameter; - coreParameter.fileToStart = fileToStart; - coreParameter.enableSound = true; - coreParameter.gpuCore = GPU_GLES; - coreParameter.cpuCore = g_Config.bJIT ? CPU_JIT : CPU_INTERPRETER; - coreParameter.enableDebugging = true; - coreParameter.printfEmuLog = false; - coreParameter.headLess = false; + CoreParameter coreParameter; + coreParameter.fileToStart = fileToStart; + coreParameter.enableSound = true; + coreParameter.gpuCore = GPU_GLES; + coreParameter.cpuCore = g_Config.bJIT ? CPU_JIT : CPU_INTERPRETER; + coreParameter.enableDebugging = true; + coreParameter.printfEmuLog = false; + coreParameter.headLess = false; coreParameter.renderWidth = 480 * g_Config.iWindowZoom; coreParameter.renderHeight = 272 * g_Config.iWindowZoom; coreParameter.outputWidth = 480 * g_Config.iWindowZoom; coreParameter.outputHeight = 272 * g_Config.iWindowZoom; + coreParameter.pixelWidth = 480 * g_Config.iWindowZoom; + coreParameter.pixelHeight = 272 * g_Config.iWindowZoom; std::string error_string; if (!PSP_Init(coreParameter, &error_string)) diff --git a/android/jni/EmuScreen.cpp b/android/jni/EmuScreen.cpp index a2c07a60b937..7b11d3c9ed97 100644 --- a/android/jni/EmuScreen.cpp +++ b/android/jni/EmuScreen.cpp @@ -65,6 +65,8 @@ EmuScreen::EmuScreen(const std::string &filename) : invalid_(true) coreParam.renderHeight = 272; coreParam.outputWidth = dp_xres; coreParam.outputHeight = dp_yres; + coreParam.pixelWidth = pixel_xres; + coreParam.pixelHeight = pixel_yres; std::string error_string; if (PSP_Init(coreParam, &error_string)) { @@ -176,7 +178,7 @@ void EmuScreen::render() uiTexture->Bind(0); - glViewport(0, 0, dp_xres, dp_yres); + glViewport(0, 0, pixel_xres, pixel_yres); ui_draw2d.Begin(DBMODE_NORMAL);