From Brad Colbert/Robert Osfield: added s/getSourceFormat and s/getSourceType to osg::Texture
along with support for this Texture1D, 2D, 3D, TextureCubeMap and TextureRectangle. The new SourceFormat and SourceType parameters are only used when no osg::Image is assigned to an osg::Texture, and main use is for render to texture effects. Added support for --hdr option in osgprerender, which utilises the new Texture::setSourceFormat/Type() methods.
This commit is contained in:
@@ -345,6 +345,8 @@ Texture::Texture():
|
||||
_borderWidth(0),
|
||||
_internalFormatMode(USE_IMAGE_DATA_FORMAT),
|
||||
_internalFormat(0),
|
||||
_sourceFormat(0),
|
||||
_sourceType(GL_UNSIGNED_BYTE),
|
||||
_use_shadow_comparison(false),
|
||||
_shadow_compare_func(LEQUAL),
|
||||
_shadow_texture_mode(LUMINANCE),
|
||||
@@ -368,6 +370,8 @@ Texture::Texture(const Texture& text,const CopyOp& copyop):
|
||||
_borderWidth(text._borderWidth),
|
||||
_internalFormatMode(text._internalFormatMode),
|
||||
_internalFormat(text._internalFormat),
|
||||
_sourceFormat(text._sourceFormat),
|
||||
_sourceType(text._sourceType),
|
||||
_use_shadow_comparison(text._use_shadow_comparison),
|
||||
_shadow_compare_func(text._shadow_compare_func),
|
||||
_shadow_texture_mode(text._shadow_texture_mode),
|
||||
@@ -398,6 +402,9 @@ int Texture::compareTexture(const Texture& rhs) const
|
||||
COMPARE_StateAttribute_Parameter(_internalFormat)
|
||||
}
|
||||
|
||||
COMPARE_StateAttribute_Parameter(_sourceFormat)
|
||||
COMPARE_StateAttribute_Parameter(_sourceType)
|
||||
|
||||
COMPARE_StateAttribute_Parameter(_use_shadow_comparison)
|
||||
COMPARE_StateAttribute_Parameter(_shadow_compare_func)
|
||||
COMPARE_StateAttribute_Parameter(_shadow_texture_mode)
|
||||
|
||||
@@ -158,6 +158,28 @@ void Texture1D::apply(State& state) const
|
||||
non_const_this->_image = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else if ( (_textureWidth!=0) && (_internalFormat!=0) )
|
||||
{
|
||||
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(
|
||||
contextID,GL_TEXTURE_1D,_numMipmapLevels,_internalFormat,_textureWidth,1,1,0);
|
||||
|
||||
textureObject->bind();
|
||||
|
||||
applyTexParameters(GL_TEXTURE_1D,state);
|
||||
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
glTexImage1D( GL_TEXTURE_1D, 0, _internalFormat,
|
||||
_textureWidth, _borderWidth,
|
||||
_sourceFormat ? _sourceFormat : _internalFormat,
|
||||
_sourceType ? _sourceType : GL_UNSIGNED_BYTE,
|
||||
0);
|
||||
|
||||
if (_readPBuffer.valid())
|
||||
{
|
||||
_readPBuffer->bindPBufferToTexture(GL_FRONT);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -222,8 +222,8 @@ void Texture2D::apply(State& state) const
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, _internalFormat,
|
||||
_textureWidth, _textureHeight, _borderWidth,
|
||||
_internalFormat,
|
||||
GL_UNSIGNED_BYTE,
|
||||
_sourceFormat ? _sourceFormat : _internalFormat,
|
||||
_sourceType ? _sourceType : GL_UNSIGNED_BYTE,
|
||||
0);
|
||||
|
||||
if (_readPBuffer.valid())
|
||||
|
||||
@@ -240,6 +240,29 @@ void Texture3D::apply(State& state) const
|
||||
non_const_this->_image = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else if ( (_textureWidth!=0) && (_textureHeight!=0) && (_textureDepth!=0) && (_internalFormat!=0) )
|
||||
{
|
||||
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(
|
||||
contextID,GL_TEXTURE_3D,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,_textureDepth,0);
|
||||
|
||||
textureObject->bind();
|
||||
|
||||
applyTexParameters(GL_TEXTURE_3D,state);
|
||||
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
extensions->glTexImage3D( GL_TEXTURE_3D, 0, _internalFormat,
|
||||
_textureWidth, _textureHeight, _textureDepth,
|
||||
_borderWidth,
|
||||
_sourceFormat ? _sourceFormat : _internalFormat,
|
||||
_sourceType ? _sourceType : GL_UNSIGNED_BYTE,
|
||||
0);
|
||||
|
||||
if (_readPBuffer.valid())
|
||||
{
|
||||
_readPBuffer->bindPBufferToTexture(GL_FRONT);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -264,8 +264,8 @@ void TextureCubeMap::apply(State& state) const
|
||||
// no image present, but dimensions at set so less create the texture
|
||||
glTexImage2D( faceTarget[n], 0, _internalFormat,
|
||||
_textureWidth, _textureHeight, _borderWidth,
|
||||
_internalFormat,
|
||||
GL_UNSIGNED_BYTE,
|
||||
_sourceFormat ? _sourceFormat : _internalFormat,
|
||||
_sourceType ? _sourceType : GL_UNSIGNED_BYTE,
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,8 @@ void TextureRectangle::apply(State& state) const
|
||||
// no image present, but dimensions at set so lets create the texture
|
||||
glTexImage2D( GL_TEXTURE_RECTANGLE, 0, _internalFormat,
|
||||
_textureWidth, _textureHeight, _borderWidth,
|
||||
_internalFormat,
|
||||
GL_UNSIGNED_BYTE,
|
||||
_sourceFormat ? _sourceFormat : _internalFormat,
|
||||
_sourceType ? _sourceType : GL_UNSIGNED_BYTE,
|
||||
0);
|
||||
|
||||
if (_readPBuffer.valid())
|
||||
|
||||
Reference in New Issue
Block a user