GLES2RICE: Update from upstream
authorptitSeb <sebastien.chev@gmail.com>
Mon, 3 Mar 2014 13:57:21 +0000 (14:57 +0100)
committerptitSeb <sebastien.chev@gmail.com>
Mon, 3 Mar 2014 13:57:21 +0000 (14:57 +0100)
source/gles2rice/src/Config.cpp
source/gles2rice/src/OGLES2FragmentShaders.cpp
source/gles2rice/src/OGLGraphicsContext.cpp
source/gles2rice/src/OGLRender.cpp
source/gles2rice/src/osal_opengl.h

index da18f8e..7ac7295 100755 (executable)
@@ -476,7 +476,7 @@ static void ReadConfiguration(void)
 
     options.mipmapping = ConfigGetParamInt(l_ConfigVideoRice, "Mipmapping");
        //*SEB* Force to 0 has other setting crash on the Pandora
-       options.mipmapping = 0;
+       options.mipmapping = TEXTURE_NO_MIPMAP;
     options.fogMethod = ConfigGetParamInt(l_ConfigVideoRice, "FogMethod");
     options.forceTextureFilter = ConfigGetParamInt(l_ConfigVideoRice, "ForceTextureFilter");
     options.textureEnhancement = ConfigGetParamInt(l_ConfigVideoRice, "TextureEnhancement");
index 29b8e97..d43fcae 100755 (executable)
@@ -35,6 +35,7 @@ const char *vertexShader =
 "attribute lowp vec2    aTexCoord0;                         \n"\
 "attribute lowp vec2    aTexCoord1;                         \n"\
 "attribute lowp vec2    aAtlasTransform;                    \n"\
+"attribute mediump float aFogCoord;                         \n"\
 "                                                           \n"\
 "varying lowp float vFactor;                                \n"\
 "varying lowp vec4  vShadeColor;                            \n"\
@@ -48,6 +49,7 @@ const char *vertexShader =
 "vShadeColor = aColor;                                      \n"\
 "vTexCoord0 = aTexCoord0;                                   \n"\
 "vTexCoord1 = aTexCoord1;                                   \n"\
+"vFog = clamp((FogMinMax[1] - aFogCoord)/(FogMinMax[1]-FogMinMax[0]),0.0,1.0);                       \n"\
 "                                                           \n"\
 "}                                                          \n"\
 "                                                           \n";
@@ -71,7 +73,6 @@ const char *fragmentHeader =
 "uniform vec4 FogColor;                                     \n"\
 "uniform vec2  FogMinMax;                                   \n"\
 "                                                           \n"\
-"varying lowp float vFactor;                                \n"\
 "varying lowp vec4  vShadeColor;                            \n"\
 "varying mediump vec2  vTexCoord0;                          \n"\
 "varying lowp vec2  vTexCoord1;                             \n"\
@@ -80,7 +81,7 @@ const char *fragmentHeader =
 "{                                                          \n"\
 "vec4 comb,comb2;                                           \n"\
 "                                                           \n"\
-"#ifdef NEED_TEX0                                              \n"\
+"#ifdef NEED_TEX0                                           \n"\
 "vec4 t0 = texture2D(uTex0,vTexCoord0);                     \n"\
 "#endif                                                     \n"\
 "                                                           \n"\
@@ -91,19 +92,15 @@ const char *fragmentHeader =
 const char *fragmentFooter =
 "                                                           \n"\
 "#ifdef FOG                                                 \n"\
-"   float z = gl_FragCoord.z * 2.0 - 1.0;                                   \n"\
-"   float FogFactor = (FogMinMax[1] - z) / (FogMinMax[1] - FogMinMax[0]);   \n"\
-"   FogFactor = clamp(FogFactor, 0.0, 1.0);                                 \n"\
-"                                                                           \n"\
-"   gl_FragColor.rgb = mix(FogColor.rgb, comb.rgb, FogFactor );             \n"\
-"   gl_FragColor.a = comb.a;                                                \n"\
-"#else                                                                      \n"\
-"   gl_FragColor = comb;                                                    \n"\
-"#endif                                                                     \n"\
-"                                                                           \n"\
-"#ifdef ALPHA_TEST                                                          \n"\
+"gl_FragColor.rgb = mix(FogColor.rgb,comb.rgb,vFog);        \n"\
+"gl_FragColor.a = comb.a;                                   \n"\
+"#else                                                      \n"\
+"gl_FragColor = comb;                                       \n"\
+"#endif                                                     \n"\
+"                                                           \n"\
+"#ifdef ALPHA_TEST                                          \n"\
    ALPHA_TEST                                                                  
-"#endif                                                                     \n"\
+"#endif                                                     \n"\
 "}                                                          \n";
 
 //Fragment shader for InitCycleCopy
@@ -194,10 +191,10 @@ COGL_FragmentProgramCombiner::COGL_FragmentProgramCombiner(CRender *pRender)
     m_pDecodedMux = new DecodedMuxForPixelShader;
     m_bFragmentProgramIsSupported = true;
     m_AlphaRef = 0.0f;
-    bAlphaTestState = DISABLE;
-    bAlphaTestPreviousState = DISABLE;
-    bFogState = DISABLE;
-    bFogPreviousState = DISABLE;
+    bAlphaTestState = false;
+    bAlphaTestPreviousState = false;
+    bFogState = false;
+    bFogPreviousState = false;
 
     //Create shaders for fill and copy
     GLint success;
@@ -328,6 +325,8 @@ void COGL_FragmentProgramCombiner::InitCombinerCycleCopy(void)
     OPENGL_CHECK_ERRORS;
     glDisableVertexAttribArray(VS_TEXCOORD1);
     OPENGL_CHECK_ERRORS;
+       glDisableVertexAttribArray(VS_FOG);
+       OPENGL_CHECK_ERRORS;
     COGLTexture* pTexture = g_textures[gRSP.curTile].m_pCOGLTexture;
     if( pTexture )
     {
@@ -573,6 +572,8 @@ int COGL_FragmentProgramCombiner::ParseDecodedMux()
                        OPENGL_CHECK_ERRORS;
                        glBindAttribLocation(res.programID,VS_POSITION,"aPosition");
                        OPENGL_CHECK_ERRORS;
+                       glBindAttribLocation(res.programID,VS_FOG,"aFogCoord");
+                       OPENGL_CHECK_ERRORS;
 
                        glLinkProgram(res.programID);
                        OPENGL_CHECK_ERRORS;
@@ -650,6 +651,11 @@ void COGL_FragmentProgramCombiner::GenerateCombinerSetting(int index)
     OPENGL_CHECK_ERRORS;
     glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
     OPENGL_CHECK_ERRORS;
+       
+       glEnableVertexAttribArray(VS_FOG);
+       OPENGL_CHECK_ERRORS;
+       glVertexAttribPointer(VS_FOG,1,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][4]));
+       OPENGL_CHECK_ERRORS;
 }
 
 void COGL_FragmentProgramCombiner::GenerateCombinerSettingConstants(int index)
index 6c1f4e8..09acac0 100755 (executable)
@@ -310,7 +310,7 @@ void COGLGraphicsContext::InitOGLExtension(void)
     m_bSupportAnisotropicFiltering = IsExtensionSupported("GL_EXT_texture_filter_anisotropic");
 #else
     m_bSupportMultiTexture = true;
-    m_bSupportFogCoord = false;
+    m_bSupportFogCoord = true;
     m_bSupportAnisotropicFiltering = true;
 #endif
     // Compute maxAnisotropicFiltering
index 5f25f16..f11798e 100755 (executable)
@@ -198,7 +198,13 @@ void OGLRender::Initialize(void)
         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
index 5fd341c..dd77e67 100755 (executable)
@@ -51,6 +51,7 @@
 #define VS_COLOR                            1
 #define VS_TEXCOORD0                        2
 #define VS_TEXCOORD1                        3
+#define VS_FOG                              4
 
 // Constant substitutions
 #define GL_CLAMP                            GL_CLAMP_TO_EDGE