Fixed handling of TextureCubeMap's with mipmapped/ImageSequence/PBO's.
This commit is contained in:
@@ -26,7 +26,7 @@ void ImageSequence::UpdateCallback::operator () (osg::StateAttribute* attr, osg:
|
||||
{
|
||||
osg::Texture* texture = attr ? attr->asTexture() : 0;
|
||||
|
||||
//osg::notify(osg::NOTICE)<<"ImageSequence::UpdateCallback::"<<texture<<std::endl;
|
||||
// osg::notify(osg::NOTICE)<<"ImageSequence::UpdateCallback::"<<texture<<std::endl;
|
||||
if (texture)
|
||||
{
|
||||
for(unsigned int i=0; i<texture->getNumImages(); ++i)
|
||||
|
||||
@@ -42,7 +42,7 @@ using namespace osg;
|
||||
#define GL_STORAGE_SHARED_APPLE 0x85BF
|
||||
#endif
|
||||
|
||||
// #define DO_TIMING
|
||||
//#define DO_TIMING
|
||||
|
||||
ApplicationUsageProxy Texture_e0(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAX_TEXTURE_SIZE","Set the maximum size of textures.");
|
||||
|
||||
@@ -1015,11 +1015,15 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
|
||||
}
|
||||
|
||||
bool mipmappingRequired = _min_filter != LINEAR && _min_filter != NEAREST;
|
||||
bool useHardwareMipMapGeneration = mipmappingRequired && (!image->isMipmap() && isHardwareMipmapGenerationEnabled(state));
|
||||
bool useGluBuildMipMaps = mipmappingRequired && (!useHardwareMipMapGeneration && !image->isMipmap());
|
||||
|
||||
unsigned char* dataMinusOffset = 0;
|
||||
unsigned char* dataPlusOffset = 0;
|
||||
|
||||
const PixelBufferObject* pbo = image->getPixelBufferObject();
|
||||
if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale)
|
||||
if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale && !useGluBuildMipMaps)
|
||||
{
|
||||
state.bindPixelBufferObject(pbo);
|
||||
dataMinusOffset = data;
|
||||
@@ -1033,16 +1037,9 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
pbo = 0;
|
||||
}
|
||||
|
||||
bool useHardwareMipMapGeneration = !image->isMipmap() && isHardwareMipmapGenerationEnabled(state);
|
||||
|
||||
if( _min_filter == LINEAR || _min_filter == NEAREST || useHardwareMipMapGeneration)
|
||||
if( !mipmappingRequired || useHardwareMipMapGeneration)
|
||||
{
|
||||
|
||||
if (_min_filter == LINEAR || _min_filter == NEAREST)
|
||||
{
|
||||
useHardwareMipMapGeneration = false;
|
||||
}
|
||||
|
||||
GenerateMipmapMode mipmapResult = mipmapBeforeTexImage(state, useHardwareMipMapGeneration);
|
||||
|
||||
if ( !compressed_image)
|
||||
@@ -1136,7 +1133,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
gluBuild2DMipmaps( target, _internalFormat,
|
||||
inwidth,inheight,
|
||||
(GLenum)image->getPixelFormat(), (GLenum)image->getDataType(),
|
||||
data -dataMinusOffset+dataPlusOffset);
|
||||
data);
|
||||
|
||||
int width = image->s();
|
||||
int height = image->t();
|
||||
@@ -1264,13 +1261,16 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image*
|
||||
|
||||
}
|
||||
|
||||
bool useHardwareMipMapGeneration = !image->isMipmap() && isHardwareMipmapGenerationEnabled(state);
|
||||
|
||||
unsigned char* dataMinusOffset=0;
|
||||
unsigned char* dataPlusOffset=0;
|
||||
|
||||
bool mipmappingRequired = _min_filter != LINEAR && _min_filter != NEAREST;
|
||||
bool useHardwareMipMapGeneration = mipmappingRequired && (!image->isMipmap() && isHardwareMipmapGenerationEnabled(state));
|
||||
bool useGluBuildMipMaps = mipmappingRequired && (!useHardwareMipMapGeneration && !image->isMipmap());
|
||||
|
||||
unsigned char* dataMinusOffset = 0;
|
||||
unsigned char* dataPlusOffset = 0;
|
||||
|
||||
const PixelBufferObject* pbo = image->getPixelBufferObject();
|
||||
if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale)
|
||||
if (pbo && pbo->isPBOSupported(contextID) && !needImageRescale && !useGluBuildMipMaps)
|
||||
{
|
||||
state.bindPixelBufferObject(pbo);
|
||||
dataMinusOffset = data;
|
||||
@@ -1284,12 +1284,10 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image*
|
||||
pbo = 0;
|
||||
}
|
||||
|
||||
if( _min_filter == LINEAR || _min_filter == NEAREST || useHardwareMipMapGeneration)
|
||||
if( !mipmappingRequired || useHardwareMipMapGeneration)
|
||||
{
|
||||
|
||||
bool hardwareMipMapOn = _min_filter != LINEAR && _min_filter != NEAREST;
|
||||
|
||||
GenerateMipmapMode mipmapResult = mipmapBeforeTexImage(state, hardwareMipMapOn);
|
||||
GenerateMipmapMode mipmapResult = mipmapBeforeTexImage(state, useHardwareMipMapGeneration);
|
||||
|
||||
if (!compressed_image)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ bool ImageSequence_writeLocalData(const Object& obj, Output& fw)
|
||||
itr != names.end();
|
||||
++itr)
|
||||
{
|
||||
fw.indent()<<*itr<<std::endl;
|
||||
fw.indent()<<fw.wrapString(*itr)<<std::endl;
|
||||
}
|
||||
|
||||
fw.moveOut();
|
||||
@@ -100,7 +100,7 @@ bool ImageSequence_writeLocalData(const Object& obj, Output& fw)
|
||||
itr != images.end();
|
||||
++itr)
|
||||
{
|
||||
if (!(*itr)->getFileName().empty()) fw.indent()<<(*itr)->getFileName()<<std::endl;
|
||||
if (!(*itr)->getFileName().empty()) fw.indent()<<fw.wrapString((*itr)->getFileName())<<std::endl;
|
||||
}
|
||||
|
||||
fw.moveOut();
|
||||
|
||||
@@ -30,15 +30,17 @@ RegisterDotOsgWrapperProxy g_TextureCubeMapProxy
|
||||
{\
|
||||
if (fr[2].matchWord("ImageSequence") || fr[2].matchWord("Image")) \
|
||||
{ \
|
||||
fr += 2;\
|
||||
osg::Image* image = fr.readImage(); \
|
||||
if (image) texture.setImage(osg::TextureCubeMap::FACE,image); \
|
||||
\
|
||||
iteratorAdvanced = true; \
|
||||
matched = true;\
|
||||
} \
|
||||
else if (fr[2].isString())\
|
||||
{ \
|
||||
Image* image = fr.readImage(fr[2].getStr());\
|
||||
if (image) texture.setImage(osg::TextureCubeMap::FACE,image);\
|
||||
fr += 2;\
|
||||
fr += 3;\
|
||||
iteratorAdvanced = true; \
|
||||
matched = true;\
|
||||
}\
|
||||
@@ -73,6 +75,7 @@ bool TextureCubeMap_readLocalData(Object& obj, Input& fr)
|
||||
const osg::ImageSequence* is = dynamic_cast<const osg::ImageSequence*>(image); \
|
||||
if (is) \
|
||||
{ \
|
||||
fw.indent() << "image "<<#FACE<<std::endl; \
|
||||
fw.writeObject(*is); \
|
||||
} \
|
||||
else \
|
||||
|
||||
Reference in New Issue
Block a user