Jump to content

  • Log In with Google      Sign In   
  • Create Account

alb

Member Since 28 Jun 2012
Offline Last Active Jul 06 2012 10:33 AM

Topics I've Started

invalid framebuffer operation with FBO

04 July 2012 - 06:42 AM

I have a problem with this piece of code:

[source lang="java"]gl.glGenTextures(4, textures, 0); gl.glBindTexture(GL.GL_TEXTURE_2D, textures[3]); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, floorWidth, floorHeight,0, GL.GL_RGB, GL.GL_FLOAT, null); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP); gl.glGenTextures(5, textures, 0); gl.glBindTexture(GL.GL_TEXTURE_2D, textures[4]); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT16, floorWidth, floorHeight,0, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, null); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); int tex1=textures[3]; int tex2=textures[4]; //GENERATE FRAMEBUFFER gl.glGenFramebuffersEXT(1, frameBufferID, 0); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBufferID[0]); gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT,GL.GL_TEXTURE_2D, tex1, 0); gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_TEXTURE_2D, tex2, 0); if(gl.glCheckFramebufferStatusEXT(GL.GL_FRAMEBUFFER_EXT) == GL.GL_FRAMEBUFFER_COMPLETE_EXT) { System.out.println("[Viewer] GL_FRAMEBUFFER_COMPLETE!!"); } else System.out.println("..error"); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); [/source]
At the end of this initialization code, I have an FBO (frame buffer object) with no errors;
it prints "[Viewer] GL_FRAMEBUFFER_COMPLETE!!"

But when I try to render something:

[source lang="java"] GL gl = drawable.getGL(); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBufferID[0]); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glPushAttrib(GL.GL_VIEWPORT_BIT); gl.glViewport(0, 0, floorWidth, floorHeight); gl.glBegin(GL.GL_QUADS); gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3d(-1, -1, 0); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3d(-1, 1, 0); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3d(1, 1, 0); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3d(1, -1, 0); gl.glEnd(); gl.glPopAttrib(); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); gl.glPopAttrib(); gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); int errorCode = gl.glGetError(); if(errorCode!=0){ String errorStr = glu.gluErrorString( errorCode ); System.out.println("...error: "+ errorStr ); System.out.println("....errorCode: "+ errorCode ); } [/source]

It return the following error:

....error: invalid framebuffer operation
....errorCode: 1286

Do you know why?
Thanks.
Alberto

PARTNERS