Added support for using the generate mip map extension within osgText.
This commit is contained in:
parent
925cd28f16
commit
55c25a551b
@ -70,6 +70,8 @@
|
|||||||
#define GL_TEXTURE_3D 0x806F
|
#define GL_TEXTURE_3D 0x806F
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
/** Texture base class which encapsulates OpenGl texture functionality which common betweent the various types of OpenGL textures.*/
|
/** Texture base class which encapsulates OpenGl texture functionality which common betweent the various types of OpenGL textures.*/
|
||||||
@ -248,6 +250,7 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
|||||||
bool isTextureMirroredRepeatSupported() const { return _isTextureMirroredRepeatSupported; }
|
bool isTextureMirroredRepeatSupported() const { return _isTextureMirroredRepeatSupported; }
|
||||||
bool isTextureEdgeClampSupported() const { return _isTextureEdgeClampSupported; }
|
bool isTextureEdgeClampSupported() const { return _isTextureEdgeClampSupported; }
|
||||||
bool isTextureBorderClampSupported() const { return _isTextureBorderClampSupported; }
|
bool isTextureBorderClampSupported() const { return _isTextureBorderClampSupported; }
|
||||||
|
bool isGenerateMipMapSupported() const { return _isGenerateMipMapSupported; }
|
||||||
|
|
||||||
GLint maxTextureSize() const { return _maxTextureSize; }
|
GLint maxTextureSize() const { return _maxTextureSize; }
|
||||||
|
|
||||||
@ -265,6 +268,7 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
|||||||
bool _isTextureMirroredRepeatSupported;
|
bool _isTextureMirroredRepeatSupported;
|
||||||
bool _isTextureEdgeClampSupported;
|
bool _isTextureEdgeClampSupported;
|
||||||
bool _isTextureBorderClampSupported;
|
bool _isTextureBorderClampSupported;
|
||||||
|
bool _isGenerateMipMapSupported;
|
||||||
|
|
||||||
GLint _maxTextureSize;
|
GLint _maxTextureSize;
|
||||||
|
|
||||||
|
@ -518,12 +518,12 @@ Texture::Extensions::Extensions(const Extensions& rhs):
|
|||||||
Referenced()
|
Referenced()
|
||||||
{
|
{
|
||||||
_isTextureFilterAnisotropicSupported = rhs._isTextureFilterAnisotropicSupported;
|
_isTextureFilterAnisotropicSupported = rhs._isTextureFilterAnisotropicSupported;
|
||||||
|
_isTextureCompressionARBSupported = rhs._isTextureCompressionARBSupported;
|
||||||
|
_isTextureCompressionS3TCSupported = rhs._isTextureCompressionS3TCSupported;
|
||||||
_isTextureMirroredRepeatSupported = rhs._isTextureMirroredRepeatSupported;
|
_isTextureMirroredRepeatSupported = rhs._isTextureMirroredRepeatSupported;
|
||||||
_isTextureEdgeClampSupported = rhs._isTextureEdgeClampSupported;
|
_isTextureEdgeClampSupported = rhs._isTextureEdgeClampSupported;
|
||||||
_isTextureBorderClampSupported = rhs._isTextureBorderClampSupported;
|
_isTextureBorderClampSupported = rhs._isTextureBorderClampSupported;
|
||||||
|
_isGenerateMipMapSupported = rhs._isGenerateMipMapSupported;
|
||||||
_isTextureCompressionARBSupported = rhs._isTextureCompressionARBSupported;
|
|
||||||
_isTextureCompressionS3TCSupported = rhs._isTextureCompressionS3TCSupported;
|
|
||||||
|
|
||||||
_maxTextureSize = rhs._maxTextureSize;
|
_maxTextureSize = rhs._maxTextureSize;
|
||||||
|
|
||||||
@ -540,6 +540,8 @@ void Texture::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
|||||||
if (!rhs._isTextureCompressionARBSupported) _isTextureCompressionARBSupported = false;
|
if (!rhs._isTextureCompressionARBSupported) _isTextureCompressionARBSupported = false;
|
||||||
if (!rhs._isTextureCompressionS3TCSupported) _isTextureCompressionS3TCSupported = false;
|
if (!rhs._isTextureCompressionS3TCSupported) _isTextureCompressionS3TCSupported = false;
|
||||||
|
|
||||||
|
if (!rhs._isGenerateMipMapSupported) _isGenerateMipMapSupported = false;
|
||||||
|
|
||||||
if (rhs._maxTextureSize<_maxTextureSize) _maxTextureSize = rhs._maxTextureSize;
|
if (rhs._maxTextureSize<_maxTextureSize) _maxTextureSize = rhs._maxTextureSize;
|
||||||
|
|
||||||
if (!rhs._glCompressedTexImage2D) _glCompressedTexImage2D = 0;
|
if (!rhs._glCompressedTexImage2D) _glCompressedTexImage2D = 0;
|
||||||
@ -549,12 +551,14 @@ void Texture::Extensions::setupGLExtenions()
|
|||||||
{
|
{
|
||||||
|
|
||||||
_isTextureFilterAnisotropicSupported = isGLExtensionSupported("GL_EXT_texture_filter_anisotropic");
|
_isTextureFilterAnisotropicSupported = isGLExtensionSupported("GL_EXT_texture_filter_anisotropic");
|
||||||
|
_isTextureCompressionARBSupported = isGLExtensionSupported("GL_ARB_texture_compression");
|
||||||
|
_isTextureCompressionS3TCSupported = isGLExtensionSupported("GL_EXT_texture_compression_s3tc");
|
||||||
_isTextureMirroredRepeatSupported = isGLExtensionSupported("GL_IBM_texture_mirrored_repeat");
|
_isTextureMirroredRepeatSupported = isGLExtensionSupported("GL_IBM_texture_mirrored_repeat");
|
||||||
_isTextureEdgeClampSupported = isGLExtensionSupported("GL_EXT_texture_edge_clamp");
|
_isTextureEdgeClampSupported = isGLExtensionSupported("GL_EXT_texture_edge_clamp");
|
||||||
_isTextureBorderClampSupported = isGLExtensionSupported("GL_ARB_texture_border_clamp");
|
_isTextureBorderClampSupported = isGLExtensionSupported("GL_ARB_texture_border_clamp");
|
||||||
|
_isGenerateMipMapSupported = (strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0) ||
|
||||||
|
isGLExtensionSupported("GL_SGIS_generate_mipmap");
|
||||||
|
|
||||||
_isTextureCompressionARBSupported = isGLExtensionSupported("GL_ARB_texture_compression");
|
|
||||||
_isTextureCompressionS3TCSupported = isGLExtensionSupported("GL_EXT_texture_compression_s3tc");
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&_maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&_maxTextureSize);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ void Font::addGlyph(unsigned int width, unsigned int height, unsigned int charco
|
|||||||
// reserve enough space for the glyphs.
|
// reserve enough space for the glyphs.
|
||||||
glyphTexture->setTextureSize(256,256);
|
glyphTexture->setTextureSize(256,256);
|
||||||
glyphTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
|
glyphTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
|
||||||
//glyphTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR);
|
glyphTexture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR);
|
||||||
//glyphTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::NEAREST);
|
//glyphTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::NEAREST);
|
||||||
glyphTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
|
glyphTexture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
|
||||||
glyphTexture->setMaxAnisotropy(8);
|
glyphTexture->setMaxAnisotropy(8);
|
||||||
@ -245,6 +245,9 @@ void Font::GlyphTexture::apply(osg::State& state) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Extensions* extensions = getExtensions(contextID,true);
|
||||||
|
bool generateMipMapSupported = extensions->isGenerateMipMapSupported();
|
||||||
|
|
||||||
// get the globj for the current contextID.
|
// get the globj for the current contextID.
|
||||||
GLuint& handle = getTextureObject(contextID);
|
GLuint& handle = getTextureObject(contextID);
|
||||||
|
|
||||||
@ -256,7 +259,22 @@ void Font::GlyphTexture::apply(osg::State& state) const
|
|||||||
|
|
||||||
applyTexParameters(GL_TEXTURE_2D,state);
|
applyTexParameters(GL_TEXTURE_2D,state);
|
||||||
|
|
||||||
//glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
|
// need to look at generate mip map extension if mip mapping required.
|
||||||
|
switch(_min_filter)
|
||||||
|
{
|
||||||
|
case NEAREST_MIPMAP_NEAREST:
|
||||||
|
case NEAREST_MIPMAP_LINEAR:
|
||||||
|
case LINEAR_MIPMAP_NEAREST:
|
||||||
|
case LINEAR_MIPMAP_LINEAR:
|
||||||
|
if (generateMipMapSupported) {
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
|
||||||
|
}
|
||||||
|
else glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, LINEAR);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// not mip mapping so no problems.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// allocate the texture memory.
|
// allocate the texture memory.
|
||||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
|
glTexImage2D( GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
|
||||||
@ -271,11 +289,27 @@ void Font::GlyphTexture::apply(osg::State& state) const
|
|||||||
// reuse texture by binding.
|
// reuse texture by binding.
|
||||||
glBindTexture( GL_TEXTURE_2D, handle );
|
glBindTexture( GL_TEXTURE_2D, handle );
|
||||||
if (getTextureParameterDirty(contextID))
|
if (getTextureParameterDirty(contextID))
|
||||||
|
{
|
||||||
applyTexParameters(GL_TEXTURE_2D,state);
|
applyTexParameters(GL_TEXTURE_2D,state);
|
||||||
|
|
||||||
|
// need to look at generate mip map extension if mip mapping required.
|
||||||
|
switch(_min_filter)
|
||||||
|
{
|
||||||
|
case NEAREST_MIPMAP_NEAREST:
|
||||||
|
case NEAREST_MIPMAP_LINEAR:
|
||||||
|
case LINEAR_MIPMAP_NEAREST:
|
||||||
|
case LINEAR_MIPMAP_LINEAR:
|
||||||
|
if (generateMipMapSupported) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
|
||||||
|
else glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, LINEAR);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// not mip mapping so no problems.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
|
|
||||||
|
|
||||||
// now subload the glyphs that are outstanding for this graphics context.
|
// now subload the glyphs that are outstanding for this graphics context.
|
||||||
GlyphPtrList& glyphsWereSubloading = _glyphsToSubload[contextID];
|
GlyphPtrList& glyphsWereSubloading = _glyphsToSubload[contextID];
|
||||||
|
Loading…
Reference in New Issue
Block a user