diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp index f4c461f930..06bbc42eb9 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp @@ -526,19 +526,23 @@ bool SetScissorRect() { int xoff = bpmem.scissorOffset.x*2-342; int yoff = bpmem.scissorOffset.y*2-342; - + //printf("xoff: %d yoff: %d\n", xoff, yoff); RECT rc; - rc.left=bpmem.scissorTL.x + xoff - 342; - if (rc.left<0) rc.left=0; - rc.top=bpmem.scissorTL.y + yoff - 342; - if (rc.top<0) rc.top=0; + rc.left = bpmem.scissorTL.x + xoff - 342; + rc.left *= MValue; + if (rc.left < 0) rc.left = 0; + rc.top = bpmem.scissorTL.y + yoff - 342; + rc.top *= MValue; + if (rc.top < 0) rc.top = 0; - rc.right=bpmem.scissorBR.x + xoff - 342 +1; - if (rc.right>640) rc.right=640; - rc.bottom=bpmem.scissorBR.y + yoff - 342 +1; - if (rc.bottom>480) rc.bottom=480; + rc.right = bpmem.scissorBR.x + xoff - 342 +1; + rc.right *= MValue; + if (rc.right > 640 * MValue) rc.right = 640 * MValue; + rc.bottom = bpmem.scissorBR.y + yoff - 342 +1; + rc.bottom *= MValue; + if (rc.bottom > 480 * MValue) rc.bottom = 480 * MValue; - PRIM_LOG("scissor: lt=(%d,%d),rb=(%d,%d),off=(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom, xoff, yoff); + //printf("scissor: lt=(%d,%d),rb=(%d,%d),off=(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom, xoff, yoff); if( rc.right>=rc.left && rc.bottom>=rc.top ) { glScissor(rc.left, Renderer::GetTargetHeight()-(rc.bottom), (rc.right-rc.left), (rc.bottom-rc.top)); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp index 1fc678a805..a46cb21a0b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLInit.cpp @@ -32,8 +32,6 @@ // screen offset int nBackbufferWidth, nBackbufferHeight; -u32 s_nTargetWidth = 0, s_nTargetHeight = 0; -u32 g_AAx = 0, g_AAy = 0; #ifndef _WIN32 GLWindow GLWin; @@ -146,9 +144,11 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight nBackbufferWidth = _twidth; nBackbufferHeight = _theight; - // change later - s_nTargetWidth = 640 << g_AAx; - s_nTargetHeight = 480 << g_AAy; + float FactorW = (float)640 / (float)nBackbufferWidth; + float FactorH = (float)480 / (float)nBackbufferHeight; + + float Max = (FactorW < FactorH) ? FactorH : FactorW; + MValue = 1 / Max; g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp index bfd68acb80..82c75bf7bd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp @@ -22,7 +22,7 @@ #include "IniFile.h" #include - +float MValue; int frameCount; Config g_Config; @@ -657,4 +657,4 @@ void SysMessage(const char *fmt, ...) if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; wxMessageBox(wxString::FromAscii(msg)); -} \ No newline at end of file +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index c6789dae16..98d9d89a74 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -97,7 +97,7 @@ struct RECT #define GL_DEPTH24_STENCIL8_EXT 0x88F0 #define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 #endif - +extern float MValue; // several macros // PLEASE DO NOT USE THE FOLLOWING SAFE* // They only encourage sloppy coding, and hide bugs. diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 5584873416..514de0c048 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -451,14 +451,14 @@ void Renderer::ReinitView(int nNewWidth, int nNewHeight) //TODO: Return correct Values int Renderer::GetTargetWidth() { - return 640; - //return nBackbufferWidth; + //return 640; + return nBackbufferWidth; } int Renderer::GetTargetHeight() { - return 480; - //return nBackbufferHeight; + //return 480; + return nBackbufferHeight; } bool Renderer::CanBlendLogicOp() @@ -663,21 +663,11 @@ void Renderer::Swap(const TRectangle& rc) for(int i = 1; i < 8; ++i) TextureMngr::DisableStage(i); GL_REPORT_ERRORD(); - //TODO: Do Correctly in a bit - float FactorW = (float)640 / (float)nBackbufferWidth; - float FactorH = (float)480 / (float)nBackbufferHeight; - - float Max = (FactorW < FactorH) ? FactorH : FactorW; - float Temp = 1 / Max; - FactorW *= Temp; - FactorH *= Temp; - - glBegin(GL_QUADS); - glTexCoord2f(0, 0); glVertex2f(-FactorW,-FactorH); - glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-FactorW,FactorH); - glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(FactorW,FactorH); - glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(FactorW,-FactorH); + glTexCoord2f(0, 0); glVertex2f(-1,-1); + glTexCoord2f(0, (float)GetTargetHeight()); glVertex2f(-1,1); + glTexCoord2f((float)GetTargetWidth(), (float)GetTargetHeight()); glVertex2f(1,1); + glTexCoord2f((float)GetTargetWidth(), 0); glVertex2f(1,-1); glEnd(); glBindTexture(GL_TEXTURE_RECTANGLE_NV, 0); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp index a101d98024..bc05ca2c57 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp @@ -322,7 +322,7 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs) // [5] = 16777215 * farz INFO_LOG("view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)\n",rawViewport[3]-rawViewport[0]-342,rawViewport[4]+rawViewport[1]-342, 2 * rawViewport[0], 2 * rawViewport[1], (rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f); - glViewport((int)(rawViewport[3]-rawViewport[0]-342),Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)), abs((int)(2 * rawViewport[0])), abs((int)(2 * rawViewport[1]))); + glViewport((int)(rawViewport[3]-rawViewport[0]-342) * MValue,Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)) * MValue, abs((int)(2 * rawViewport[0])) * MValue, abs((int)(2 * rawViewport[1])) * MValue); glDepthRange((rawViewport[5]-rawViewport[2])/16777215.0f, rawViewport[5]/16777215.0f); } @@ -482,7 +482,6 @@ void VertexShaderMngr::SetViewport(float* _Viewport) if( *(u32*)(_Viewport + i) == 0x7f800000 ) return; // invalid number } - memcpy(rawViewport, _Viewport, sizeof(rawViewport)); bViewportChanged = true; }