Fixes to osg::Texture's handling of anisotropy updating and

hardware generate mip mapping.

Added switching off generate mip map from osgText::Font.cpp.

Changed savedmodel.osg to saved_model.osg in ViewerEventHandler.
This commit is contained in:
Robert Osfield
2003-04-01 20:32:57 +00:00
parent b59760482f
commit 5a974ab091
4 changed files with 219 additions and 33 deletions

View File

@@ -350,7 +350,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
glTexParameteri( target, GL_TEXTURE_MIN_FILTER, _min_filter);
glTexParameteri( target, GL_TEXTURE_MAG_FILTER, _mag_filter);
if (_maxAnisotropy>1.0f && extensions->isTextureFilterAnisotropicSupported())
if (extensions->isTextureFilterAnisotropicSupported())
{
// note, GL_TEXTURE_MAX_ANISOTROPY_EXT will either be defined
// by gl.h (or via glext.h) or by include/osg/Texture.
@@ -442,7 +442,12 @@ void Texture::applyTexImage2D_load(GLenum target, const Image* image, State& sta
if( _min_filter == LINEAR || _min_filter == NEAREST || useHardwareMipMapGeneration)
{
if (useHardwareMipMapGeneration) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
bool hardwareMipMapOn = false;
if (_min_filter != LINEAR && _min_filter != NEAREST)
{
if (useHardwareMipMapGeneration) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
hardwareMipMapOn = true;
}
if ( !compressed_image)
{
@@ -468,7 +473,7 @@ void Texture::applyTexImage2D_load(GLenum target, const Image* image, State& sta
data);
}
if (useHardwareMipMapGeneration) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
if (hardwareMipMapOn) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
}
else
{
@@ -572,12 +577,13 @@ void Texture::applyTexImage2D_subload(GLenum target, const Image* image, State&
// image size has changed so we have to re-load the image from scratch.
if (image->s()!=inwidth || image->t()!=inheight)
{
applyTexImage2D_subload(target, image, state, inwidth, inheight,numMimpmapLevels);
applyTexImage2D_load(target, image, state, inwidth, inheight,numMimpmapLevels);
return;
}
// else image size the same as when loaded so we can go ahead and subload
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
@@ -649,7 +655,14 @@ void Texture::applyTexImage2D_subload(GLenum target, const Image* image, State&
if( _min_filter == LINEAR || _min_filter == NEAREST || useHardwareMipMapGeneration)
{
if (useHardwareMipMapGeneration) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
bool hardwareMipMapOn = false;
if (_min_filter != LINEAR && _min_filter != NEAREST)
{
if (useHardwareMipMapGeneration) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
hardwareMipMapOn = true;
}
if (!compressed_image)
{
@@ -671,7 +684,7 @@ void Texture::applyTexImage2D_subload(GLenum target, const Image* image, State&
data );
}
if (useHardwareMipMapGeneration) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
if (hardwareMipMapOn) glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
}
else
{
@@ -732,7 +745,8 @@ void Texture::applyTexImage2D_subload(GLenum target, const Image* image, State&
{
if (!compressed_image)
{
numMimpmapLevels = 0;
numMimpmapLevels = 0;
int width = s_powerOfTwo;
int height = t_powerOfTwo;

View File

@@ -672,7 +672,7 @@ void DrawCallback::createStatsText()
ViewerEventHandler::ViewerEventHandler(OsgCameraGroup* cg):
_cg(cg),
_writeNodeFileName("savedmodel.osg"),
_writeNodeFileName("saved_model.osg"),
_displayHelp(false),
_frameStatsMode(NO_STATS)
{

View File

@@ -388,6 +388,8 @@ void Font::GlyphTexture::apply(osg::State& state) const
// get the globj for the current contextID.
GLuint& handle = getTextureObject(contextID);
bool generateMipMapOn = false;
if (handle == 0)
{
// being bound for the first time, need to allocate the texture
@@ -395,6 +397,7 @@ void Font::GlyphTexture::apply(osg::State& state) const
glBindTexture( GL_TEXTURE_2D, handle );
applyTexParameters(GL_TEXTURE_2D,state);
// need to look at generate mip map extension if mip mapping required.
switch(_min_filter)
@@ -403,8 +406,10 @@ void Font::GlyphTexture::apply(osg::State& state) const
case NEAREST_MIPMAP_LINEAR:
case LINEAR_MIPMAP_NEAREST:
case LINEAR_MIPMAP_LINEAR:
if (generateMipMapSupported) {
if (generateMipMapSupported)
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
generateMipMapOn = true;
}
else glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, LINEAR);
break;
@@ -419,6 +424,7 @@ void Font::GlyphTexture::apply(osg::State& state) const
GL_LUMINANCE_ALPHA,
GL_UNSIGNED_BYTE,
0 );
}
else
@@ -428,21 +434,26 @@ void Font::GlyphTexture::apply(osg::State& state) const
if (getTextureParameterDirty(contextID))
{
applyTexParameters(GL_TEXTURE_2D,state);
}
bool generateMipMapOn = false;
// need to look at generate mip map extension if mip mapping required.
switch(_min_filter)
// 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)
{
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);
generateMipMapOn = true;
}
else glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, LINEAR);
break;
default:
// not mip mapping so no problems.
break;
}
}
@@ -468,6 +479,15 @@ void Font::GlyphTexture::apply(osg::State& state) const
{
//std::cout << "no need to subload "<<std::endl;
}
if (generateMipMapOn)
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
}
}
// all the methods in Font::Glyph have been made non inline because VisualStudio6.0 is STUPID, STUPID, STUPID PILE OF JUNK.