Commit 7def3797 authored by Robert Menzel's avatar Robert Menzel

fixed texture upload bug for texture2d arrays

parent 229a3569
......@@ -6,6 +6,7 @@
#include <ACGL/OpenGL/Objects/Texture.hh>
#include <ACGL/OpenGL/glloaders/extensions.hh> // for anisotrophic filtering
#include <ACGL/Math/Math.hh>
using namespace ACGL::OpenGL;
......@@ -615,11 +616,13 @@ void TextureBase::texImage1D( const SharedTextureData &_data, GLint _mipmapLevel
void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLevel, uint32_t _offset )
{
bind();
GLsizei w = std::min( mWidth, _data->getWidth() );
glTexSubImage1D(
mTarget,
_mipmapLevel,
_offset,
mWidth,
w,
_data->getFormat(),
_data->getType(),
_data->getData() );
......@@ -646,14 +649,15 @@ void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel
void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset )
{
// TODO: test if the size is correct?
GLsizei w = std::min( mWidth, _data->getWidth() );
GLsizei h = std::max( std::min( mHeight, _data->getHeight() ), 1);
bind();
glTexSubImage2D(
mTarget,
_mipmapLevel,
_offset.x, _offset.y,
mWidth, mHeight,
w,h,
_data->getFormat(),
_data->getType(),
_data->getData() );
......@@ -683,11 +687,15 @@ void TextureBase::texImage3D( const SharedTextureData &_data, GLint _mipmapLevel
void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset )
{
bind();
GLsizei w = std::min( mWidth, _data->getWidth() );
GLsizei h = std::max( std::min( mHeight, _data->getHeight() ), 1);
GLsizei d = std::max( std::min( mDepth, _data->getDepth() ), 1);
glTexSubImage3D(
mTarget,
_mipmapLevel,
_offset.x, _offset.y, _offset.z,
mWidth, mHeight, mDepth,
w,h,d,
_data->getFormat(),
_data->getType(),
_data->getData() );
......
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