Commit f02e3497 authored by Janis Born's avatar Janis Born

remember and restore previoulsy bound texture state in Texture::getImageData

parent 5094dc90
......@@ -79,6 +79,17 @@ SharedTextureData Texture::getImageData(GLint _lod, GLenum _type) const
if(_type == GL_INVALID_ENUM) _type = mType;
// remember the previously bound texture
GLint prevTexture;
if (mTarget == GL_TEXTURE_1D) glGetIntegerv(GL_TEXTURE_BINDING_1D, &prevTexture);
else if(mTarget == GL_TEXTURE_2D) glGetIntegerv(GL_TEXTURE_BINDING_2D, &prevTexture);
else if(mTarget == GL_TEXTURE_3D) glGetIntegerv(GL_TEXTURE_BINDING_3D, &prevTexture);
else if(mTarget == GL_TEXTURE_1D_ARRAY) glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY, &prevTexture);
else if(mTarget == GL_TEXTURE_2D_ARRAY) glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &prevTexture);
else if(mTarget == GL_TEXTURE_RECTANGLE) glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE, &prevTexture);
else if(mTarget == GL_TEXTURE_2D_MULTISAMPLE) glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE, &prevTexture);
// determine the required buffer size to hold the requested LOD level
GLint width, height, depth;
......@@ -93,6 +104,9 @@ SharedTextureData Texture::getImageData(GLint _lod, GLenum _type) const
GLubyte* imageData = new GLubyte[width * height * getGLTypeSize(_type) * channels];
glGetTexImage(mTarget, _lod, GL_RGB, _type, (GLvoid*)imageData);
// revert to the previously bound texture
glBindTexture(mTarget, prevTexture);
// store the image data and meta information in a TextureData object
SharedTextureData dataObject = SharedTextureData(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