From fdbb1fe021de94c36efa655661e891020f807c42 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 28 Jun 2004 22:09:52 +0000 Subject: [PATCH] Re-organised Texture::computeInternalFormatWithImage() to avoid testing for extensions when not required. --- src/osg/Texture.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index e8dc859aa..c5c5b1b60 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -333,19 +333,24 @@ void Texture::dirtyTextureParameters() void Texture::computeInternalFormatWithImage(const osg::Image& image) const { - const unsigned int contextID = 0; // state.getContextID(); // set to 0 right now, assume same paramters for each graphics context... - const Extensions* extensions = getExtensions(contextID,true); - -// static bool s_ARB_Compression = isGLExtensionSupported("GL_ARB_texture_compression"); -// static bool s_S3TC_Compression = isGLExtensionSupported("GL_EXT_texture_compression_s3tc"); - GLint internalFormat = image.getInternalTextureFormat(); - switch(_internalFormatMode) - { - case(USE_IMAGE_DATA_FORMAT): - internalFormat = image.getInternalTextureFormat(); - break; + if (_internalFormatMode==USE_IMAGE_DATA_FORMAT) + { + internalFormat = image.getInternalTextureFormat(); + } + else if (_internalFormatMode==USE_USER_DEFINED_FORMAT) + { + internalFormat = _internalFormat; + } + else + { + + const unsigned int contextID = 0; // state.getContextID(); // set to 0 right now, assume same paramters for each graphics context... + const Extensions* extensions = getExtensions(contextID,true); + + switch(_internalFormatMode) + { case(USE_ARB_COMPRESSION): if (extensions->isTextureCompressionARBSupported()) { @@ -411,10 +416,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const else internalFormat = image.getInternalTextureFormat(); break; - case(USE_USER_DEFINED_FORMAT): - internalFormat = _internalFormat; - break; - + } } _internalFormat = internalFormat;