From 4457d2a14564cc8c4c4335c5ca7f00e47da74fe2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 10 Feb 2012 17:20:43 +0000 Subject: [PATCH] From Colin McDonald, "Upgrading to OpenSceneGraph 3.0.1, texture mip mapping stopped working on some junk low-end graphics cards which I still have to support. They worked ok with osg 2.8 and earlier. The problem turned out to be with gl proxy textures, which are unreliable on those devices. Proxy textures are used by the glu mipmap build routines to determine if a texture size is supported. The external glu library had a nice fallback behaviour, so that if proxy textures didn't work then the mipmap texture was still created. But in the work on the new embedded glu routines that fallback behaviour has been inadvertently lost. I have restored the fallback in src/osg/glu/libutil/mipmap.cpp. It doesn't add any extra complexity." --- src/osg/glu/libutil/mipmap.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/osg/glu/libutil/mipmap.cpp b/src/osg/glu/libutil/mipmap.cpp index 6ca032e3f..7292afb80 100644 --- a/src/osg/glu/libutil/mipmap.cpp +++ b/src/osg/glu/libutil/mipmap.cpp @@ -3492,35 +3492,36 @@ static void closestFit(GLenum target, GLint width, GLint height, * that we will never be aware of when this happens * since it will silently branch out. */ - *newWidth= 0; - *newHeight= 0; - return; + break; } widthPowerOf2= widthAtLevelOne; heightPowerOf2= heightAtLevelOne; } /* else it does fit */ } while (proxyWidth == 0); - /* loop must terminate! */ /* return the width & height at level 0 that fits */ - *newWidth= widthPowerOf2; - *newHeight= heightPowerOf2; + if ( proxyWidth > 0 ) + { + *newWidth= widthPowerOf2; + *newHeight= heightPowerOf2; /*printf("Proxy Textures\n");*/ + return; + } } /* if gluCheckExtension() */ - else #endif // end of #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) - { /* no texture extension, so do this instead */ - GLint maxsize; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize); - /* clamp user's texture sizes to maximum sizes, if necessary */ - *newWidth = nearestPower(width); - if (*newWidth > maxsize) *newWidth = maxsize; - *newHeight = nearestPower(height); - if (*newHeight > maxsize) *newHeight = maxsize; + /* no texture extension, or proxy textures not working, so do this instead */ + + GLint maxsize; + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize); + /* clamp user's texture sizes to maximum sizes, if necessary */ + *newWidth = nearestPower(width); + if (*newWidth > maxsize) *newWidth = maxsize; + *newHeight = nearestPower(height); + if (*newHeight > maxsize) *newHeight = maxsize; /*printf("NO proxy textures\n");*/ - } } /* closestFit() */ GLint GLAPIENTRY