PDA

View Full Version : gl_CopyTexSubImage problem with FBO on NVidia card



Devdept2
01-16-2012, 03:53 AM
Hi,

my program works fine on ATI cards but I have problems on Nvidia cards.
I tried Geforce 8400GS with driver 266.58 and it has the problem but with the latest driver it seems to work fine.

I successfully create a FBO with Render Buffer storage of type gl_DEPTH_COMPONENT to store the shadow map:



_fbo = gl.GenFramebuffersEXT();
gl.BindFramebufferEXT(gl.FRAMEBUFFER_EXT, _fbo);
_renderBuffer = gl.GenRenderbuffersEXT(1)[0];
gl.BindRenderbufferEXT(gl.RENDERBUFFER_EXT, _renderBuffer);
gl.RenderbufferStorageEXT(gl.RENDERBUFFER_EXT, gl.DEPTH_COMPONENT, (int) shadowMapSize,
(int) shadowMapSize);
gl.FramebufferRenderbufferEXT(gl.FRAMEBUFFER_EXT, gl.DEPTH_ATTACHMENT_EXT, gl.RENDERBUFFER_EXT, _renderBuffer);

InitTexture(shadowMapSize, ref _texture);
gl.FramebufferTexture2DEXT(gl.FRAMEBUFFER_EXT, gl.DEPTH_ATTACHMENT_EXT, gl.TEXTURE_2D, _texture,
0);

gl.DrawBuffer(gl.NONE);
gl.ReadBuffer(gl.NONE);

The InitTexture() method above initializes the texture:



internal static void InitTexture(uint shadowMapSize, ref uint texture)
{
gl.GenTextures(1, names);
texture = names[0];

gl.ActiveTexture(TextureUnit);
gl.BindTexture(gl.TEXTURE_2D, texture);

gl.TexImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, (int) shadowMapSize, (int) shadowMapSize, 0,
gl.DEPTH_COMPONENT, gl.UNSIGNED_BYTE, null);

gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP);
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP);
gl.ActiveTexture(gl.TEXTURE0);

gl.BindTexture(gl.TEXTURE_2D, 0);
}


After the creation the Framebuffer status is gl_FRAMEBUFFER_COMPLETE_EXT.

Then I bind the Framebuffer object and draw my scene.

Now I want to copy the FBO picture on another texture (which have been previously created of the right size and type):



gl.BindTexture(gl.TEXTURE_2D, otherTexture);

gl.CopyTexSubImage2D(gl.TEXTURE_2D, 0, x, y, 0, 0, (int) shadowMapSize, (int) shadowMapSize);


After the gl.CopyTexSubImage2D call I have a GL_INVALID_OPERATION error.
Is this a known bug of the driver or am I doing something wrong?