Commits

Murat Sari committed 8f68667

GLES: Do not filter textures without mipmap chain on android (otherwise we get black textures)

  • Participants
  • Parent commits 5010210
  • Branches v1-9

Comments (0)

Files changed (3)

File RenderSystems/GLES/include/OgreGLESRenderSystem.h

             bool activateGLTextureUnit(size_t unit);
             bool activateGLClientTextureUnit(size_t unit);
 
+			// Mipmap count of the actual bounded texture
+			size_t mCurTexMipCount;
         public:
             // Default constructor / destructor
             GLESRenderSystem();
              RenderSystem
              */
             void _setTextureUnitCompareFunction(size_t unit, CompareFunction function);
+			/** See
+             RenderSystem
+             */
+			virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
+				FilterOptions magFilter, FilterOptions mipFilter);
             /** See
              RenderSystem
              */

File RenderSystems/GLES/src/OgreGLESRenderSystem.cpp

     GLESRenderSystem::GLESRenderSystem()
         : mGpuProgramManager(0),
           mHardwareBufferManager(0),
-          mRTTManager(0)
+          mRTTManager(0),
+		  mCurTexMipCount(0)
     {
             // Get function pointers on platforms that doesn't have prototypes
 #ifndef GL_GLEXT_PROTOTYPES
 
     void GLESRenderSystem::_setTexture(size_t stage, bool enabled, const TexturePtr &texPtr)
     {
-        GL_CHECK_ERROR;
-
-        // TODO We need control texture types?????
         GLESTexturePtr tex = texPtr;
 
         if (!mStateCacheManager->activateGLTextureUnit(stage))
 
         if (enabled)
         {
+#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+			mCurTexMipCount = 0;
+#endif
             if (!tex.isNull())
             {
                 // Note used
                 tex->touch();
                 glEnable(tex->getGLESTextureTarget());
                 mStateCacheManager->bindGLTexture(tex->getGLESTextureTarget(), tex->getGLID());
-                
+#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+				mCurTexMipCount = tex->getNumMipmaps();
+#endif
             }
             else
             {
                         // linear min, linear mip
                         return GL_LINEAR_MIPMAP_LINEAR;
                     case FO_POINT:
-#if OGRE_PLATFORM != OGRE_PLATFORM_ANDROID
                         // linear min, point mip
                         return GL_LINEAR_MIPMAP_NEAREST;
-#endif
                     case FO_NONE:
                         // linear min, no mip
                         return GL_LINEAR;
         return 0;
     }
 
+	void GLESRenderSystem::_setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
+				FilterOptions magFilter, FilterOptions mipFilter)
+	{ 		
+		mMipFilter = mipFilter;
+#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+		if(mCurTexMipCount == 0 && mMipFilter != FO_NONE)
+		{
+			mMipFilter = FO_NONE;			
+		}
+#endif
+		_setTextureUnitFiltering(unit, FT_MAG, magFilter);
+		_setTextureUnitFiltering(unit, FT_MIN, minFilter);
+	}
+	
     void GLESRenderSystem::_setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions fo)
     {
 		if (!mStateCacheManager->activateGLTextureUnit(unit))
                 break;
             case FT_MIP:
                 mMipFilter = fo;
-
-                // Combine with existing min filter
-                mStateCacheManager->setTexParameteri(GL_TEXTURE_2D,
-                                                     GL_TEXTURE_MIN_FILTER,
-                                                     getCombinedMinMipFilter());
                 break;
         }
 

File RenderSystems/GLES2/include/OgreGLES2RenderSystem.h

 		     /** See
               RenderSystem
              */
-		    void _setTextureUnitCompareEnabled(size_t unit, bool compare);
-			
+		    void _setTextureUnitCompareEnabled(size_t unit, bool compare);			
 			/** See
              RenderSystem
              */
 			virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
-				FilterOptions magFilter, FilterOptions mipFilter);
-				
+				FilterOptions magFilter, FilterOptions mipFilter);				
             /** See
              RenderSystem
              */