X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=source%2Fgles2rice%2Fsrc%2FOGLRender.cpp;h=f11798eff509e93cf4b1e00b114d71ab2fdaf888;hb=ea03ad213a7c83970cdf11e64c769918274ebda2;hp=d0b8cf3eeb2d250c3a8491bd304eb0f06a37e1b2;hpb=ac4f8e4321adb765745b2da188b8b359735ea379;p=mupen64plus-pandora.git diff --git a/source/gles2rice/src/OGLRender.cpp b/source/gles2rice/src/OGLRender.cpp index d0b8cf3..f11798e 100755 --- a/source/gles2rice/src/OGLRender.cpp +++ b/source/gles2rice/src/OGLRender.cpp @@ -45,10 +45,6 @@ UVFlagMap OGLXUVFlagMaps[] = {TEXTURE_UV_FLAG_CLAMP, GL_CLAMP}, }; -#if SDL_VIDEO_OPENGL_ES2 - static GLuint disabledTextureID; -#endif - //=================================================================== OGLRender::OGLRender() { @@ -62,28 +58,8 @@ OGLRender::OGLRender() m_texUnitEnabled[i]=FALSE; } -#if SDL_VIDEO_OPENGL m_bEnableMultiTexture = false; -#elif SDL_VIDEO_OPENGL_ES2 - m_bEnableMultiTexture = true; - - //Create a texture as replacement for glEnable/Disable(GL_TEXTURE_2D) - unsigned int white[8*8]; - for (int i=0; i<8*8; i++) { - //white[i].r = white[i].g = white[i].b = 0; - //white[i].a = 0; - white[i] = 0; - } - glGenTextures(1,&disabledTextureID); - OPENGL_CHECK_ERRORS; - glBindTexture(GL_TEXTURE_2D, disabledTextureID); - OPENGL_CHECK_ERRORS; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - OPENGL_CHECK_ERRORS; - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, white); - OPENGL_CHECK_ERRORS; -#endif } OGLRender::~OGLRender() @@ -206,6 +182,31 @@ void OGLRender::Initialize(void) OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_MIRRORED_REPEAT; m_bSupportClampToEdge = true; OGLXUVFlagMaps[TEXTURE_UV_FLAG_CLAMP].realFlag = GL_CLAMP_TO_EDGE; + + glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0])); + OPENGL_CHECK_ERRORS; + + if( m_bMultiTexture ) + { + glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u)); + OPENGL_CHECK_ERRORS; + glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u)); + OPENGL_CHECK_ERRORS; + } + else + { + glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u)); + OPENGL_CHECK_ERRORS; + } + + if (m_bSupportFogCoordExt) + { + glVertexAttribPointer(VS_FOG,1,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][4])); + OPENGL_CHECK_ERRORS; + } + + glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) ); + OPENGL_CHECK_ERRORS; #endif #ifdef PAULSCODE @@ -617,6 +618,13 @@ bool OGLRender::RenderTexRect() g_texRectTVtx[0].tcord[0].u,g_texRectTVtx[0].tcord[0].v }; + GLfloat tex2[] = { + g_texRectTVtx[3].tcord[1].u,g_texRectTVtx[3].tcord[1].v, + g_texRectTVtx[2].tcord[1].u,g_texRectTVtx[2].tcord[1].v, + g_texRectTVtx[1].tcord[1].u,g_texRectTVtx[1].tcord[1].v, + g_texRectTVtx[0].tcord[1].u,g_texRectTVtx[0].tcord[1].v + }; + float w = windowSetting.uDisplayWidth / 2.0f, h = windowSetting.uDisplayHeight / 2.0f, inv = 1.0f; GLfloat vertices[] = { @@ -629,6 +637,7 @@ bool OGLRender::RenderTexRect() glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_TRUE, 0, &colour ); glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices); glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, 0, &tex); + glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, 0, &tex2); OPENGL_CHECK_ERRORS; glDrawArrays(GL_TRIANGLE_FAN,0,4); OPENGL_CHECK_ERRORS; @@ -637,7 +646,7 @@ bool OGLRender::RenderTexRect() glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) ); glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0])); glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u)); - + glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u)); #endif if( cullface ) glEnable(GL_CULL_FACE); @@ -690,6 +699,7 @@ bool OGLRender::RenderFillRect(uint32 dwColor, float depth) glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour ); glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices); glDisableVertexAttribArray(VS_TEXCOORD0); + glDisableVertexAttribArray(VS_TEXCOORD1); OPENGL_CHECK_ERRORS; glDrawArrays(GL_TRIANGLE_FAN,0,4); OPENGL_CHECK_ERRORS; @@ -698,6 +708,7 @@ bool OGLRender::RenderFillRect(uint32 dwColor, float depth) glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) ); glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0])); glEnableVertexAttribArray(VS_TEXCOORD0); + glEnableVertexAttribArray(VS_TEXCOORD1); #endif @@ -871,6 +882,16 @@ void OGLRender::DrawSimple2DTexture(float x0, float y0, float x1, float y1, floa g_texRectTVtx[3].tcord[0].u,g_texRectTVtx[3].tcord[0].v, }; + GLfloat tex2[] = { + g_texRectTVtx[0].tcord[1].u,g_texRectTVtx[0].tcord[1].v, + g_texRectTVtx[1].tcord[1].u,g_texRectTVtx[1].tcord[1].v, + g_texRectTVtx[2].tcord[1].u,g_texRectTVtx[2].tcord[1].v, + + g_texRectTVtx[0].tcord[1].u,g_texRectTVtx[0].tcord[1].v, + g_texRectTVtx[2].tcord[1].u,g_texRectTVtx[2].tcord[1].v, + g_texRectTVtx[3].tcord[1].u,g_texRectTVtx[3].tcord[1].v, + }; + float w = windowSetting.uDisplayWidth / 2.0f, h = windowSetting.uDisplayHeight / 2.0f, inv = 1.0f; GLfloat vertices[] = { @@ -886,6 +907,7 @@ void OGLRender::DrawSimple2DTexture(float x0, float y0, float x1, float y1, floa glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour ); glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices); glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, 0, &tex); + glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, 0, &tex2); OPENGL_CHECK_ERRORS; glDrawArrays(GL_TRIANGLES,0,6); OPENGL_CHECK_ERRORS; @@ -894,6 +916,7 @@ void OGLRender::DrawSimple2DTexture(float x0, float y0, float x1, float y1, floa glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) ); glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0])); glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u)); + glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u)); #endif @@ -946,6 +969,7 @@ void OGLRender::DrawSimpleRect(int nX0, int nY0, int nX1, int nY1, uint32 dwColo glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour ); glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices); glDisableVertexAttribArray(VS_TEXCOORD0); + glDisableVertexAttribArray(VS_TEXCOORD1); OPENGL_CHECK_ERRORS; glDrawArrays(GL_TRIANGLE_FAN,0,4); OPENGL_CHECK_ERRORS; @@ -954,6 +978,7 @@ void OGLRender::DrawSimpleRect(int nX0, int nY0, int nX1, int nY1, uint32 dwColo glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) ); glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0])); glEnableVertexAttribArray(VS_TEXCOORD0); + glEnableVertexAttribArray(VS_TEXCOORD1); #endif @@ -1026,24 +1051,19 @@ void OGLRender::SetAlphaTestEnable(BOOL bAlphaTestEnable) #ifdef DEBUGGER if( bAlphaTestEnable && debuggerEnableAlphaTest ) #else - if( bAlphaTestEnable ) -#endif + #if SDL_VIDEO_OPENGL + if( bAlphaTestEnable ) glEnable(GL_ALPHA_TEST); else glDisable(GL_ALPHA_TEST); + OPENGL_CHECK_ERRORS; #elif SDL_VIDEO_OPENGL_ES2 - { - COGL_FragmentProgramCombiner* frag = (COGL_FragmentProgramCombiner*)m_pColorCombiner; - frag->m_AlphaRef = m_dwAlpha / 255.0f; - } - else - { - COGL_FragmentProgramCombiner* frag = (COGL_FragmentProgramCombiner*)m_pColorCombiner; - frag->m_AlphaRef = 0.0f; - } + COGL_FragmentProgramCombiner* frag = (COGL_FragmentProgramCombiner*)m_pColorCombiner; + frag->SetAlphaTestState(bAlphaTestEnable); +#endif + #endif - OPENGL_CHECK_ERRORS; } void OGLRender::BindTexture(GLuint texture, int unitno) @@ -1079,27 +1099,11 @@ void OGLRender::EnableTexUnit(int unitno, BOOL flag) if( m_texUnitEnabled[0] != flag ) { m_texUnitEnabled[0] = flag; -#if SDL_VIDEO_OPENGL + if( flag == TRUE ) glEnable(GL_TEXTURE_2D); else glDisable(GL_TEXTURE_2D); -#elif SDL_VIDEO_OPENGL_ES2 - if(flag) - { - pglActiveTexture(GL_TEXTURE0_ARB + unitno); - OPENGL_CHECK_ERRORS; - glBindTexture(GL_TEXTURE_2D,m_curBoundTex[unitno]); - } - else - { - pglActiveTexture(GL_TEXTURE0_ARB + unitno); - OPENGL_CHECK_ERRORS; - glEnable(GL_BLEND); //Need blend for transparent disabled texture - glBindTexture(GL_TEXTURE_2D,disabledTextureID); - } -#endif - OPENGL_CHECK_ERRORS; } } @@ -1122,9 +1126,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 +1147,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 +1167,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; @@ -1185,9 +1181,6 @@ void OGLRender::SetFogMinMax(float fMin, float fMax) OPENGL_CHECK_ERRORS; glFogf(GL_FOG_END, gRSPfFogMax); // Fog End Depth OPENGL_CHECK_ERRORS; -#elif SDL_VIDEO_OPENGL_ES2 - ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->UpdateFog(gRSP.bFogEnabled); - OPENGL_CHECK_ERRORS; #endif } @@ -1200,7 +1193,7 @@ void OGLRender::TurnFogOnOff(bool flag) glDisable(GL_FOG); OPENGL_CHECK_ERRORS; #elif SDL_VIDEO_OPENGL_ES2 - ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->UpdateFog(flag); + ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->SetFogState(flag); OPENGL_CHECK_ERRORS; #endif } @@ -1236,7 +1229,7 @@ void OGLRender::SetFogEnable(bool bEnable) OPENGL_CHECK_ERRORS; } #elif SDL_VIDEO_OPENGL_ES2 - ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->UpdateFog(gRSP.bFogEnabled); + ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->SetFogState(gRSP.bFogEnabled); OPENGL_CHECK_ERRORS; #endif } @@ -1283,7 +1276,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) {