From c3fb8dc71435e7c925853ef7032eb2db56726748 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 24 Feb 2012 12:15:15 +0000 Subject: [PATCH] Added support for using glGenerateMipmap instead of GL_GENERATE_MIPMAP_SGIS on GLES2 --- src/osgText/Glyph.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/osgText/Glyph.cpp b/src/osgText/Glyph.cpp index a896c15e4..3120e72d4 100644 --- a/src/osgText/Glyph.cpp +++ b/src/osgText/Glyph.cpp @@ -155,6 +155,23 @@ void GlyphTexture::apply(osg::State& state) const bool newTextureObject = (textureObject == 0); + #if defined(OSG_GLES2_AVAILABLE) + bool requiresGenerateMipmapCall = false; + + // need to look to see generate mip map call is required. + switch(_min_filter) + { + case NEAREST_MIPMAP_NEAREST: + case NEAREST_MIPMAP_LINEAR: + case LINEAR_MIPMAP_NEAREST: + case LINEAR_MIPMAP_LINEAR: + requiresGenerateMipmapCall = generateMipMapSupported; + break; + default: + break; + } + #endif + if (newTextureObject) { GLint maxTextureSize = 256; @@ -176,7 +193,6 @@ void GlyphTexture::apply(osg::State& state) const applyTexParameters(GL_TEXTURE_2D,state); - // need to look at generate mip map extension if mip mapping required. switch(_min_filter) @@ -187,7 +203,9 @@ void GlyphTexture::apply(osg::State& state) const case LINEAR_MIPMAP_LINEAR: if (generateMipMapSupported) { + #if !defined(OSG_GLES2_AVAILABLE) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE); + #endif } else glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, LINEAR); break; @@ -274,7 +292,13 @@ void GlyphTexture::apply(osg::State& state) const { OpenThreads::ScopedLock lock(_mutex); - if (!s_subloadAllGlyphsTogether) + bool subloadAllGlyphsTogether = s_subloadAllGlyphsTogether; + + #if defined(OSG_GLES2_AVAILABLE) + if (requiresGenerateMipmapCall) subloadAllGlyphsTogether = true; + #endif + + if (!subloadAllGlyphsTogether) { if (newTextureObject) { @@ -349,6 +373,10 @@ void GlyphTexture::apply(osg::State& state) const getTextureHeight(), GL_ALPHA, GL_UNSIGNED_BYTE, local_data ); + #if defined(OSG_GLES2_AVAILABLE) + if (requiresGenerateMipmapCall) glGenerateMipmap(GL_TEXTURE_2D); + #endif + delete [] local_data; }