Commit e56585ad authored by Robert Menzel's avatar Robert Menzel
Browse files

texture saving parameter type fixed and made uniform buffer parameter const

parent 1f350574
......@@ -352,7 +352,7 @@ public:
}
//! Returns a TextureData objects holding the contents of the texture
SharedTextureData getImageData(GLint _lod = 0, GLint _type = 0) const;
SharedTextureData getImageData(GLint _lod = 0, GLenum _type = GL_INVALID_ENUM) const;
//! Generate mipmaps from the current base texture (i.e. the texture from level 0)
//! Note: The function is not const, because it changes the corresponding GPU data
......
......@@ -59,7 +59,7 @@ public:
{}
//! inits the uniformbuffer to be used with the given shaderprogram, _uboName is the name of this buffer in the shader
UniformBuffer( const ptr::shared_ptr<ShaderProgram> &_shaderProgram, const std::string &_uboName );
UniformBuffer( const ptr::shared_ptr<const ShaderProgram> &_shaderProgram, const std::string &_uboName );
// ==================================================================================================== \/
// ============================================================================================ GETTERS \/
......
......@@ -75,20 +75,23 @@ void Texture::setAnisotropicFilter( GLfloat _sampleCount )
}
}
SharedTextureData Texture::getImageData(GLint _lod, GLint _type) const
SharedTextureData Texture::getImageData(GLint _lod, GLenum _type) const
{
if(_type == 0) _type = mType;
if(_type == GL_INVALID_ENUM) _type = mType;
// determine the required buffer size to hold the requested LOD level
bind();
GLint width, height, depth;
glGetTexLevelParameteriv(mTarget, _lod, GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(mTarget, _lod, GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(mTarget, _lod, GL_TEXTURE_HEIGHT, &height);
glGetTexLevelParameteriv(mTarget, _lod, GL_TEXTURE_DEPTH, &depth);
glGetTexLevelParameteriv(mTarget, _lod, GL_TEXTURE_DEPTH, &depth);
// fetch the image data
GLubyte* imageData = new GLubyte[width * height * getGLTypeSize(_type) * 4];
glGetTexImage(mTarget, _lod, GL_RGBA, _type, (GLvoid*)imageData);
int channels = 4;
if (mFormat == GL_RGB) channels = 3; // TODO: check the other channel types
GLubyte* imageData = new GLubyte[width * height * getGLTypeSize(_type) * channels];
glGetTexImage(mTarget, _lod, GL_RGB, _type, (GLvoid*)imageData);
// store the image data and meta information in a TextureData object
SharedTextureData dataObject = SharedTextureData(new TextureData());
......@@ -96,7 +99,7 @@ SharedTextureData Texture::getImageData(GLint _lod, GLint _type) const
dataObject->setHeight(height);
dataObject->setDepth(depth);
dataObject->setType(_type);
dataObject->setFormat(GL_RGBA);
dataObject->setFormat(GL_RGB);
dataObject->setData(imageData); // dataObject will take care of freeing imageData
return dataObject;
......
......@@ -11,7 +11,7 @@ using namespace ACGL::OpenGL;
#if (ACGL_OPENGL_VERSION >= 31)
UniformBuffer::UniformBuffer( const ptr::shared_ptr<ShaderProgram> &_shaderProgram, const std::string &_uboName ) : Buffer(GL_UNIFORM_BUFFER)
UniformBuffer::UniformBuffer( const ptr::shared_ptr<const ShaderProgram> &_shaderProgram, const std::string &_uboName ) : Buffer(GL_UNIFORM_BUFFER)
{
reserveMemory( _shaderProgram->getUniformBlockSize( _uboName ) );
setUniformOffsets( _shaderProgram->getUniformOffsetsOfBlock( _uboName ) ); // to enable intuitive setUniform functions
......
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