From 6ac88641e446ee9d85b928769d7b7055318152c4 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 12 Oct 2013 21:12:13 +0200 Subject: [PATCH] Added aspect ratio option to RICE GLES2 --- source/gles2rice/src/Config.cpp | 15 +++++++++++++-- source/gles2rice/src/OGLRender.cpp | 19 ++++++------------- source/gles2rice/src/Video.h | 4 +++- 3 files changed, 22 insertions(+), 16 deletions(-) mode change 100644 => 100755 source/gles2rice/src/Video.h diff --git a/source/gles2rice/src/Config.cpp b/source/gles2rice/src/Config.cpp index 98d86cd..da18f8e 100755 --- a/source/gles2rice/src/Config.cpp +++ b/source/gles2rice/src/Config.cpp @@ -313,6 +313,9 @@ BOOL InitConfiguration(void) ConfigSetDefaultBool(l_ConfigVideoGeneral, "Fullscreen", 0, "Use fullscreen mode if True, or windowed mode if False "); ConfigSetDefaultInt(l_ConfigVideoGeneral, "ScreenWidth", 640, "Width of output window or fullscreen width"); ConfigSetDefaultInt(l_ConfigVideoGeneral, "ScreenHeight", 480, "Height of output window or fullscreen height"); +#if 1 + ConfigSetDefaultBool(l_ConfigVideoGeneral, "AspectRatio", 1, "If true, use correct aspect ratio, if false, stretch to fullscreen"); +#endif ConfigSetDefaultBool(l_ConfigVideoGeneral, "VerticalSync", 0, "If true, activate the SDL_GL_SWAP_CONTROL attribute"); ConfigSetDefaultInt(l_ConfigVideoRice, "FrameBufferSetting", FRM_BUF_NONE, "Frame Buffer Emulation (0=ROM default, 1=disable)"); @@ -430,8 +433,16 @@ static void ReadConfiguration(void) windowSetting.bDisplayFullscreen = ConfigGetParamBool(l_ConfigVideoGeneral, "Fullscreen"); windowSetting.uDisplayWidth = ConfigGetParamInt(l_ConfigVideoGeneral, "ScreenWidth"); #if 1 - if (windowSetting.uDisplayWidth==800) - windowSetting.uDisplayWidth = 640; // no strech + windowSetting.bDisplayRatio = true; + windowSetting.uDisplayX = 0; + windowSetting.uDisplayY = 0; + windowSetting.bDisplayRatio = ConfigGetParamBool(l_ConfigVideoGeneral, "AspectRatio"); + if (windowSetting.bDisplayRatio) { + if (windowSetting.uDisplayWidth==800) { + windowSetting.uDisplayWidth = 640; // no strech + windowSetting.uDisplayX = 80; + } + } #endif windowSetting.uDisplayHeight = ConfigGetParamInt(l_ConfigVideoGeneral, "ScreenHeight"); windowSetting.bVerticalSync = ConfigGetParamBool(l_ConfigVideoGeneral, "VerticalSync"); diff --git a/source/gles2rice/src/OGLRender.cpp b/source/gles2rice/src/OGLRender.cpp index d0b8cf3..ee99b97 100755 --- a/source/gles2rice/src/OGLRender.cpp +++ b/source/gles2rice/src/OGLRender.cpp @@ -1122,9 +1122,7 @@ void OGLRender::UpdateScissor() uint32 height = (gRDP.scissor.right*gRDP.scissor.bottom)/width; glEnable(GL_SCISSOR_TEST); OPENGL_CHECK_ERRORS; -/* glScissor(0, int(height*windowSetting.fMultY+windowSetting.statusBarHeightToUse), - int(width*windowSetting.fMultX), int(height*windowSetting.fMultY) );*/ - glScissor(80, int(height*windowSetting.fMultY+windowSetting.statusBarHeightToUse), + glScissor(windowSetting.uDisplayX, windowSetting.uDisplayY+int(height*windowSetting.fMultY+windowSetting.statusBarHeightToUse), int(width*windowSetting.fMultX), int(height*windowSetting.fMultY) ); OPENGL_CHECK_ERRORS; } @@ -1145,17 +1143,13 @@ void OGLRender::ApplyRDPScissor(bool force) uint32 height = (gRDP.scissor.right*gRDP.scissor.bottom)/width; glEnable(GL_SCISSOR_TEST); OPENGL_CHECK_ERRORS; -/* glScissor(0, int(height*windowSetting.fMultY+windowSetting.statusBarHeightToUse), - int(width*windowSetting.fMultX), int(height*windowSetting.fMultY) );*/ - glScissor(80, int(height*windowSetting.fMultY+windowSetting.statusBarHeightToUse), + glScissor(windowSetting.uDisplayX, windowSetting.uDisplayY+int(height*windowSetting.fMultY+windowSetting.statusBarHeightToUse), int(width*windowSetting.fMultX), int(height*windowSetting.fMultY) ); OPENGL_CHECK_ERRORS; } else { -/* glScissor(int(gRDP.scissor.left*windowSetting.fMultX), int((windowSetting.uViHeight-gRDP.scissor.bottom)*windowSetting.fMultY+windowSetting.statusBarHeightToUse), - int((gRDP.scissor.right-gRDP.scissor.left)*windowSetting.fMultX), int((gRDP.scissor.bottom-gRDP.scissor.top)*windowSetting.fMultY ));*/ - glScissor(80+int(gRDP.scissor.left*windowSetting.fMultX), int((windowSetting.uViHeight-gRDP.scissor.bottom)*windowSetting.fMultY+windowSetting.statusBarHeightToUse), + glScissor(windowSetting.uDisplayX+int(gRDP.scissor.left*windowSetting.fMultX), windowSetting.uDisplayY+int((windowSetting.uViHeight-gRDP.scissor.bottom)*windowSetting.fMultY+windowSetting.statusBarHeightToUse), int((gRDP.scissor.right-gRDP.scissor.left)*windowSetting.fMultX), int((gRDP.scissor.bottom-gRDP.scissor.top)*windowSetting.fMultY )); OPENGL_CHECK_ERRORS; } @@ -1169,9 +1163,7 @@ void OGLRender::ApplyScissorWithClipRatio(bool force) glEnable(GL_SCISSOR_TEST); OPENGL_CHECK_ERRORS; -/* glScissor(windowSetting.clipping.left, int((windowSetting.uViHeight-gRSP.real_clip_scissor_bottom)*windowSetting.fMultY)+windowSetting.statusBarHeightToUse, - windowSetting.clipping.width, windowSetting.clipping.height);*/ - glScissor(80+windowSetting.clipping.left, int((windowSetting.uViHeight-gRSP.real_clip_scissor_bottom)*windowSetting.fMultY)+windowSetting.statusBarHeightToUse, + glScissor(windowSetting.uDisplayX+windowSetting.clipping.left, windowSetting.uDisplayY+int((windowSetting.uViHeight-gRSP.real_clip_scissor_bottom)*windowSetting.fMultY)+windowSetting.statusBarHeightToUse, windowSetting.clipping.width, windowSetting.clipping.height); OPENGL_CHECK_ERRORS; @@ -1283,7 +1275,8 @@ void OGLRender::glViewportWrapper(GLint x, GLint y, GLsizei width, GLsizei heigh static GLsizei m_width=0, m_height=0; static bool mflag=true; - x+=80; + x+=windowSetting.uDisplayX; + y+=windowSetting.uDisplayY; if( x!=mx || y!=my || width!=m_width || height!=m_height || mflag!=flag) { diff --git a/source/gles2rice/src/Video.h b/source/gles2rice/src/Video.h old mode 100644 new mode 100755 index 30a23d7..0d22f8d --- a/source/gles2rice/src/Video.h +++ b/source/gles2rice/src/Video.h @@ -30,7 +30,9 @@ typedef struct { float fViWidth, fViHeight; unsigned short uViWidth, uViHeight; unsigned short uDisplayWidth, uDisplayHeight; - + unsigned short uDisplayX, uDisplayY; + BOOL bDisplayRatio; + BOOL bDisplayFullscreen; BOOL bVerticalSync; -- 2.39.5