View Full Version : invalid value with glCopyTexSubImage3D

09-06-2014, 03:55 AM
I am trying to copy my rtt result in slot 0 of a 512x512 texture array with :

int slot = 0;
glBindTexture(GL_TEXTURE_2D_ARRAY, texture_array );
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
glCopyTexSubImage3D( GL_TEXTURE_3D, 0, 0, 0, slot, 0, 0, 512, 512 );

I get an "invalid value" error from glCopyTexSubImage3D and I cannot figure out why.
The texture array is 512x512 and so is the texture attached to my fbo.
I want to copy the whole square in mipmap level 0 from 0,0 to 0,0 slot=0 with width=512 and height=512.
Thanks in advance.

carsten neumann
09-06-2014, 04:07 AM
I think you are missing a glReadBuffer(GL_COLOR_ATTACHMENT0) after binding the fbo. Also, why not use GL_TEXTURE_2D_ARRAY as the target for the glCopyTexSubImage3D call?

09-06-2014, 06:20 AM
Same result with glReadBuffer(GL_COLOR_ATTACHMENT0) after fbo binding.

I am using GL_TEXTURE_3D because the specs ask for it:

target Specifies the target texture. Must be GL_TEXTURE_3D

(edit) I just tried with GL_TEXTURE_2D_ARRAY and it works now. Thanks for your help. The function spec is very misleading especially considering this:
GL_INVALID_ENUM is generated if /target is not GL_TEXTURE_3D.
I was getting an invalid value, not an invalid enumerant. Invalid value is supposed to be returned if the x,y,width height params are bogus, and invalid enumerant if the target type is wrong.

carsten neumann
09-06-2014, 07:12 AM
You are looking at an old version of the reference pages (in particular I suspect at one for a version of OpenGL that had no support for array textures) ;)
The most recent page for glCopyTexSubImage3D (http://www.opengl.org/sdk/docs/man/html/glCopyTexSubImage3D.xhtml) mentions GL_TEXTURE_2D_ARRAY as a valid target value.