Commit 84096d44 authored by Janis Born's avatar Janis Born

add resize method to TextureBase

parent 82a2ef82
......@@ -177,6 +177,11 @@ public:
//! Generate mipmaps from the current base texture (i.e. the texture from level 0)
void generateMipmaps(void);
void resize(const glm::uvec3& _size) { resizeI(glm::uvec3(_size.x, _size.y, _size.z)); }
void resize(const glm::uvec2& _size) { resizeI(glm::uvec3(_size.x, _size.y, 1 )); }
void resize(const glm::uvec1& _size) { resizeI(glm::uvec3(_size.x, 1, 1 )); }
void resize( GLuint _size) { resizeI(glm::uvec3(_size, 1, 1 )); }
#ifndef ACGL_OPENGLES_VERSION_20
//! get one texture image:
TextureData *getTextureImageRAW( const Image &_image = Image(), GLenum _format = GL_RGBA, GLenum _type = GL_UNSIGNED_BYTE ) const;
......@@ -229,6 +234,9 @@ protected:
{
return (mWidth != 0);
}
//! Resizes the texture. Subclasses implementing this method may use only use the first entries of _size if they are of lower dimension
virtual void resizeI(const glm::uvec3& _size) = 0;
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureBase)
......@@ -270,7 +278,7 @@ public:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec2 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
private:
void generateMipmaps(void) { ACGL::Utils::error() << "Rectangle Textures don't support MipMaps!" << std::endl; }
......@@ -298,7 +306,7 @@ public:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const uint32_t _newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture1D)
......@@ -320,7 +328,7 @@ public:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec2 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture2D)
......@@ -346,7 +354,7 @@ public:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec3 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture3D)
......@@ -371,7 +379,7 @@ public:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec2 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture1DArray)
......@@ -397,7 +405,7 @@ public:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec3 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture2DArray)
......@@ -419,7 +427,7 @@ public:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec2 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
private:
bool cubeSideIsValid( const GLenum _cubeSide ) const;
......
......@@ -329,7 +329,7 @@ TextureData *TextureBase::getTextureImageRAW( const Image &_image, GLenum _forma
#endif // ES 2
void TextureRectangle::resize( const glm::uvec2 &_newSize )
void TextureRectangle::resizeI(const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight) {
SharedTextureData sTexData( new TextureData() );
......@@ -371,12 +371,12 @@ void Texture1D::setImageData( const SharedTextureData &_data, uint32_t _mipmapLa
}
}
void Texture1D::resize( const uint32_t _newSize )
void Texture1D::resizeI(const glm::uvec3 &_newSize )
{
if (_newSize != (unsigned int)mWidth) {
if (_newSize.x != (unsigned int)mWidth) {
SharedTextureData sTexData( new TextureData() );
sTexData->setData (NULL);
sTexData->setWidth (_newSize);
sTexData->setWidth (_newSize.x);
sTexData->setFormat(getCompatibleFormat( mInternalFormat ));
sTexData->setType (getCompatibleType( mInternalFormat ));
......@@ -394,7 +394,7 @@ void Texture2D::setImageData( const SharedTextureData &_data, uint32_t _mipmapLa
}
}
void Texture2D::resize( const glm::uvec2 &_newSize )
void Texture2D::resizeI( const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight) {
SharedTextureData sTexData( new TextureData() );
......@@ -434,7 +434,7 @@ void Texture3D::setImageData( const SharedTextureData &_data, uint32_t _mipmapLa
texSubImage3D( _data, _mipmapLayer, offset );
}
void Texture3D::resize( const glm::uvec3 &_newSize )
void Texture3D::resizeI( const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight || _newSize.z != (unsigned int)mDepth) {
SharedTextureData sTexData( new TextureData() );
......@@ -479,7 +479,7 @@ void Texture1DArray::setImageData( const SharedTextureData &_data, uint32_t _mip
texSubImage2D( _data, _mipmapLayer );
}
void Texture1DArray::resize( const glm::uvec2 &_newSize )
void Texture1DArray::resizeI(const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight) {
SharedTextureData sTexData( new TextureData() );
......@@ -506,7 +506,7 @@ void Texture2DArray::setImageData( const SharedTextureData &_data, uint32_t _arr
}
}
void Texture2DArray::resize( const glm::uvec3 &_newSize )
void Texture2DArray::resizeI( const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight || _newSize.z != (unsigned int)mDepth) {
SharedTextureData sTexData( new TextureData() );
......@@ -539,7 +539,7 @@ void TextureCubeMap::setImageData( const SharedTextureData &_data, GLenum _cubeS
//}
}
void TextureCubeMap::resize( const glm::uvec2 &_newSize )
void TextureCubeMap::resizeI(const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight) {
SharedTextureData sTexData( new TextureData() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment