From e76c91ed788393c2bc53e3439908ddf272d0554c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 10 Jun 2015 16:47:15 +0000 Subject: [PATCH] From Colin McDonald, "An earlier fix in OSG 3.2 has been inadvertently lost in 3.3.x. The glGenerateMipMap function is part of the GL_EXT_framebuffer_object extension. Just checking if the function is present before using it for texture mipmaps is not sufficient, as on remote X-windows displays the client side capability may be different from the display server. This can lead to mipmapped textures failing to render. I've restored a fbo extension check. I've also tided up the GL version checking a little." git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14907 16af8721-9629-0410-8352-f15c8da7e697 --- src/osg/GLExtensions.cpp | 29 +++++++++++++++-------------- src/osg/Texture.cpp | 9 +++++---- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index fa1c365af..c26677425 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -465,7 +465,7 @@ GLExtensions::GLExtensions(unsigned int contextID) isCubeMapSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_texture_cube_map") || isGLExtensionSupported(contextID,"GL_EXT_texture_cube_map") || - strncmp((const char*)glGetString(GL_VERSION),"1.3",3)>=0;; + (glVersion >= 1.3f); @@ -686,7 +686,7 @@ GLExtensions::GLExtensions(unsigned int contextID) // BlendFunc extensions isBlendFuncSeparateSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID, "GL_EXT_blend_func_separate") || - strncmp((const char*)glGetString(GL_VERSION), "1.4", 3) >= 0; + (glVersion >= 1.4f); setGLExtensionFuncPtr(glBlendFuncSeparate, "glBlendFuncSeparate", "glBlendFuncSeparateEXT"); @@ -765,7 +765,7 @@ GLExtensions::GLExtensions(unsigned int contextID) // SampleMaski functionality isTextureMultisampleSupported = isGLExtensionSupported(contextID, "GL_ARB_texture_multisample"); - isOpenGL32upported = getGLVersionNumber() >= 3.2; + isOpenGL32upported = (glVersion >= 3.2f); // function pointers setGLExtensionFuncPtr(glSampleMaski, "glSampleMaski"); @@ -866,7 +866,7 @@ GLExtensions::GLExtensions(unsigned int contextID) setGLExtensionFuncPtr(glBindImageTexture, "glBindImageTexture", "glBindImageTextureARB"); - isTextureMaxLevelSupported = ( getGLVersionNumber() >= 1.2f ); + isTextureMaxLevelSupported = (glVersion >= 1.2f); isTextureStorageEnabled = isTexStorage2DSupported(); if ( (ptr = getenv("OSG_GL_TEXTURE_STORAGE")) != 0 && isTexStorage2DSupported()) @@ -880,7 +880,7 @@ GLExtensions::GLExtensions(unsigned int contextID) isTexture3DFast = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture3D"); if (isTexture3DFast) isTexture3DSupported = true; - else isTexture3DSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; + else isTexture3DSupported = (glVersion >= 1.2f); maxTexture3DSize = 0; glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxTexture3DSize); @@ -903,19 +903,19 @@ GLExtensions::GLExtensions(unsigned int contextID) // Blending isBlendColorSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_blend_color") || - strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; + (glVersion >= 1.2f); setGLExtensionFuncPtr(glBlendColor, "glBlendColor", "glBlendColorEXT"); bool bultInSupport = OSG_GLES2_FEATURES || OSG_GL3_FEATURES; isBlendEquationSupported = bultInSupport || isGLExtensionSupported(contextID, "GL_EXT_blend_equation") || - strncmp((const char*)glGetString(GL_VERSION), "1.2", 3) >= 0; + (glVersion >= 1.2f); isBlendEquationSeparateSupported = bultInSupport || isGLExtensionSupported(contextID, "GL_EXT_blend_equation_separate") || - strncmp((const char*)glGetString(GL_VERSION), "2.0", 3) >= 0; + (glVersion >= 2.0f); isSGIXMinMaxSupported = isGLExtensionSupported(contextID, "GL_SGIX_blend_alpha_minmax"); @@ -936,7 +936,7 @@ GLExtensions::GLExtensions(unsigned int contextID) // Stencil` isStencilWrapSupported = isGLExtensionOrVersionSupported(contextID, "GL_EXT_stencil_wrap", 1.4f); isStencilTwoSidedSupported = isGLExtensionSupported(contextID, "GL_EXT_stencil_two_side"); - isOpenGL20Supported = getGLVersionNumber() >= 2.0; + isOpenGL20Supported = (glVersion >= 2.0f); isSeparateStencilSupported = isGLExtensionSupported(contextID, "GL_ATI_separate_stencil"); // function pointers @@ -954,7 +954,7 @@ GLExtensions::GLExtensions(unsigned int contextID) // ClampColor isClampColorSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_color_buffer_float") || - strncmp((const char*)glGetString(GL_VERSION),"2.0",3)>=0; + (glVersion >= 2.0f); setGLExtensionFuncPtr(glClampColor, "glClampColor", "glClampColorARB"); @@ -964,15 +964,14 @@ GLExtensions::GLExtensions(unsigned int contextID) // Point - isPointParametersSupported = OSG_GL3_FEATURES || - strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0 || + isPointParametersSupported = OSG_GL3_FEATURES || (glVersion >= 1.4f) || isGLExtensionSupported(contextID,"GL_ARB_point_parameters") || isGLExtensionSupported(contextID,"GL_EXT_point_parameters") || isGLExtensionSupported(contextID,"GL_SGIS_point_parameters"); isPointSpriteSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_OES_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite"); - isPointSpriteCoordOriginSupported = OSG_GL3_FEATURES || strncmp((const char*)glGetString(GL_VERSION),"2.0",3)>=0; + isPointSpriteCoordOriginSupported = OSG_GL3_FEATURES || (glVersion >= 2.0f); setGLExtensionFuncPtr(glPointParameteri, "glPointParameteri", "glPointParameteriARB"); @@ -1028,7 +1027,9 @@ GLExtensions::GLExtensions(unsigned int contextID) glFramebufferTexture2D != 0 && glFramebufferRenderbuffer != 0 && glGenerateMipmap != 0 && - glGetRenderbufferParameteriv != 0; + glGetRenderbufferParameteriv != 0 && + ( OSG_GLES1_FEATURES || isGLExtensionOrVersionSupported(contextID, "GL_EXT_framebuffer_object",3.0f) ); + isPackedDepthStencilSupported = OSG_GL3_FEATURES || (isGLExtensionSupported(contextID, "GL_EXT_packed_depth_stencil")) || diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index 082a4d888..990bf3bb6 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -2699,7 +2699,8 @@ bool Texture::isHardwareMipmapGenerationEnabled(const State& state) const return true; } - if (extensions->glGenerateMipmap) + // FrameBufferObjects are required for glGenerateMipmap + if (extensions->isFrameBufferObjectSupported && extensions->glGenerateMipmap) { return true; } @@ -2717,7 +2718,7 @@ Texture::GenerateMipmapMode Texture::mipmapBeforeTexImage(const State& state, bo #else const GLExtensions* extensions = state.get(); - bool useGenerateMipMap = extensions->glGenerateMipmap!=0; + bool useGenerateMipMap = extensions->isFrameBufferObjectSupported && extensions->glGenerateMipmap; if (useGenerateMipMap) { @@ -2788,8 +2789,8 @@ void Texture::generateMipmap(State& state) const // get fbo extension which provides us with the glGenerateMipmapEXT function osg::GLExtensions* ext = state.get(); - // check if the function is supported - if (ext->glGenerateMipmap) + // FrameBufferObjects are required for glGenerateMipmap + if (ext->isFrameBufferObjectSupported && ext->glGenerateMipmap) { textureObject->bind(); ext->glGenerateMipmap(textureObject->target());