Procházet zdrojové kódy

Code cleanup.
Do not create point light shadow indirection textures if no shadow mapping capability.

Lasse Öörni před 13 roky
rodič
revize
c1c7dcf0ec

+ 1 - 0
Android/src/org/libsdl/app/SDLActivity.java

@@ -209,6 +209,7 @@ public class SDLActivity extends Activity {
                 }
                 int[] configSpec = {
                     EGL10.EGL_DEPTH_SIZE, 16,
+                    EGL10.EGL_STENCIL_SIZE, 8,
                     EGL10.EGL_RENDERABLE_TYPE, renderableType,
                     EGL10.EGL_NONE
                 };

+ 0 - 10
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -1140,12 +1140,7 @@ void Graphics::SetTexture(unsigned index, Texture* texture)
     {
         if (impl_->activeTexture_ != index)
         {
-            glGetError();
             glActiveTexture(GL_TEXTURE0 + index);
-            int error = glGetError();
-            if (error)
-                LOGERROR("Activetexture unit " + String(index) + " error " + String(error));
-            
             impl_->activeTexture_ = index;
         }
         
@@ -1180,12 +1175,7 @@ void Graphics::SetTexture(unsigned index, Texture* texture)
         {
             if (impl_->activeTexture_ != index)
             {
-                glGetError();
                 glActiveTexture(GL_TEXTURE0 + index);
-                int error = glGetError();
-                if (error)
-                    LOGERROR("Activetexture unit " + String(index) + " error " + String(error));
-                
                 impl_->activeTexture_ = index;
             }
             

+ 2 - 1
Engine/Graphics/OpenGL/OGLTexture.cpp

@@ -25,6 +25,7 @@
 #include "FileSystem.h"
 #include "Graphics.h"
 #include "GraphicsImpl.h"
+#include "Log.h"
 #include "Material.h"
 #include "Profiler.h"
 #include "ResourceCache.h"
@@ -173,11 +174,11 @@ void Texture::UpdateParameters()
         break;
     }
     
+    #ifndef GL_ES_VERSION_2_0
     // Anisotropy
     glTexParameterf(target_, GL_TEXTURE_MAX_ANISOTROPY_EXT, filterMode_ == FILTER_ANISOTROPIC ?
         (float)graphics_->GetTextureAnisotropy() : 1.0f);
     
-    #ifndef GL_ES_VERSION_2_0
     // Shadow compare
     if (shadowCompare_)
     {

+ 49 - 44
Engine/Graphics/Renderer.cpp

@@ -1690,56 +1690,61 @@ void Renderer::CreateGeometries()
     pointLightGeometry_->SetIndexBuffer(plib);
     pointLightGeometry_->SetDrawRange(TRIANGLE_LIST, 0, plib->GetIndexCount());
     
-    faceSelectCubeMap_ = new TextureCube(context_);
-    faceSelectCubeMap_->SetNumLevels(1);
-    faceSelectCubeMap_->SetSize(1, graphics_->GetRGBAFormat());
-    faceSelectCubeMap_->SetFilterMode(FILTER_NEAREST);
-    
-    unsigned char data[256 * 256 * 4];
-    
-    for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
+    #if !defined(USE_OPENGL) || !defined(GL_ES_VERSION_2_0)
+    if (graphics_->GetShadowMapFormat())
     {
-        unsigned axis = i / 2;
-        data[0] = (axis == 0) ? 255 : 0;
-        data[1] = (axis == 1) ? 255 : 0;
-        data[2] = (axis == 2) ? 255 : 0;
-        data[3] = 0;
-        faceSelectCubeMap_->SetData((CubeMapFace)i, 0, 0, 0, 1, 1, data);
-    }
-    
-    indirectionCubeMap_ = new TextureCube(context_);
-    indirectionCubeMap_->SetNumLevels(1);
-    indirectionCubeMap_->SetSize(256, graphics_->GetRGBAFormat());
-    indirectionCubeMap_->SetFilterMode(FILTER_BILINEAR);
-    indirectionCubeMap_->SetAddressMode(COORD_U, ADDRESS_CLAMP);
-    indirectionCubeMap_->SetAddressMode(COORD_V, ADDRESS_CLAMP);
-    indirectionCubeMap_->SetAddressMode(COORD_W, ADDRESS_CLAMP);
-    
-    for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
-    {
-        unsigned char faceX = (i & 1) * 255;
-        unsigned char faceY = (i / 2) * 255 / 3;
-        unsigned char* dest = data;
-        for (unsigned y = 0; y < 256; ++y)
+        faceSelectCubeMap_ = new TextureCube(context_);
+        faceSelectCubeMap_->SetNumLevels(1);
+        faceSelectCubeMap_->SetSize(1, graphics_->GetRGBAFormat());
+        faceSelectCubeMap_->SetFilterMode(FILTER_NEAREST);
+        
+        unsigned char data[256 * 256 * 4];
+        
+        for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
         {
-            for (unsigned x = 0; x < 256; ++x)
+            unsigned axis = i / 2;
+            data[0] = (axis == 0) ? 255 : 0;
+            data[1] = (axis == 1) ? 255 : 0;
+            data[2] = (axis == 2) ? 255 : 0;
+            data[3] = 0;
+            faceSelectCubeMap_->SetData((CubeMapFace)i, 0, 0, 0, 1, 1, data);
+        }
+        
+        indirectionCubeMap_ = new TextureCube(context_);
+        indirectionCubeMap_->SetNumLevels(1);
+        indirectionCubeMap_->SetSize(256, graphics_->GetRGBAFormat());
+        indirectionCubeMap_->SetFilterMode(FILTER_BILINEAR);
+        indirectionCubeMap_->SetAddressMode(COORD_U, ADDRESS_CLAMP);
+        indirectionCubeMap_->SetAddressMode(COORD_V, ADDRESS_CLAMP);
+        indirectionCubeMap_->SetAddressMode(COORD_W, ADDRESS_CLAMP);
+        
+        for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
+        {
+            unsigned char faceX = (i & 1) * 255;
+            unsigned char faceY = (i / 2) * 255 / 3;
+            unsigned char* dest = data;
+            for (unsigned y = 0; y < 256; ++y)
             {
-                #ifdef USE_OPENGL
-                *dest++ = x;
-                *dest++ = 255 - y;
-                *dest++ = faceX;
-                *dest++ = 255 * 2 / 3 - faceY;
-                #else
-                *dest++ = x;
-                *dest++ = y;
-                *dest++ = faceX;
-                *dest++ = faceY;
-                #endif
+                for (unsigned x = 0; x < 256; ++x)
+                {
+                    #ifdef USE_OPENGL
+                    *dest++ = x;
+                    *dest++ = 255 - y;
+                    *dest++ = faceX;
+                    *dest++ = 255 * 2 / 3 - faceY;
+                    #else
+                    *dest++ = x;
+                    *dest++ = y;
+                    *dest++ = faceX;
+                    *dest++ = faceY;
+                    #endif
+                }
             }
+            
+            indirectionCubeMap_->SetData((CubeMapFace)i, 0, 0, 0, 256, 256, data);
         }
-        
-        indirectionCubeMap_->SetData((CubeMapFace)i, 0, 0, 0, 256, 256, data);
     }
+    #endif
 }
 
 void Renderer::CreateInstancingBuffer()