invalid value with glCopyTexSubImage3D

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 );
gl.printError();

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.

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?

Same result with glReadBuffer(GL_COLOR_ATTACHMENT0) after fbo binding.

I am using GL_TEXTURE_3D because the specs ask for it:
http://https://www.opengl.org/sdk/docs/man2/xhtml/glCopyTexSubImage3D.xml

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.

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) :wink:
The most recent page for glCopyTexSubImage3D mentions GL_TEXTURE_2D_ARRAY as a valid target value.