Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


invalid framebuffer operation with FBO


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 alb   Members   -  Reputation: 107

Like
0Likes
Like

Posted 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

Sponsor:

#2 FXACE   Members   -  Reputation: 182

Like
0Likes
Like

Posted 04 July 2012 - 05:09 PM

I believe it more looks syntax call error than frame buffer problem. Your code:

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); // <--- You saved viewport bits
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(); // <-- You restored previous attribute values (viewport bits)
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);

gl.glPopAttrib(); // <-- What it does restore???
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);

Best wishes, FXACE.

Edited by FXACE, 04 July 2012 - 05:10 PM.


#3 alb   Members   -  Reputation: 107

Like
0Likes
Like

Posted 05 July 2012 - 08:18 AM

I believe it more looks syntax call error than frame buffer problem. Your code:


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); // <--- You saved viewport bits
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(); // <-- You restored previous attribute values (viewport bits)
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);

gl.glPopAttrib(); // <-- What it does restore???
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);

Best wishes, FXACE.



No the last two rows are a copy&paste error:

gl.glPopAttrib(); // <-- You restored previous attribute values (viewport bits)
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);


#4 Alukien   Members   -  Reputation: 123

Like
0Likes
Like

Posted 05 July 2012 - 10:52 AM

A couple of things..
gl.glGenTextures(4, textures, 0);

is allocating 4 texture objects, and placing them into the array "textures".

Right after you've set up your color texture for your FBO, you call:
		gl.glGenTextures(5, textures, 0);

This is creating 5 new texture objects, and putting their handles in the same array (textures). This means that when you say tex1 = textures[3] later on, you're getting the handle to a texture with no image data backing it. It'll let you bind the texture, but drawing to it will cause an error. If you need 5 textures, just one call to glGenTextures(5,textures,0) at the beginning should work for you.

Second, I see you're attaching to the color and depth attachments, but not to the stencil. If memory serves, all three attachments are required for OpenGL to allow drawing to an FBO.

Do you need to read from your depth texture? If not, then you should probably generate a Renderbuffer, call glRenderbufferStorage() to set it up with a type such as GL_DEPTH24_STENCIL_8, and attach it to GL_DEPTH_STENCIL_ATTACHMENT instead of using your current depth texture. If you DO need to sample your depth buffer, then you'll still need to generate a renderbuffer, but of a type like GL_STENCIL_INDEX8, and attach it to just GL_STENCIL_ATTACHMENT.

EDIT: The following is probably irrelevant to JOGL, since it appears to only support up to OpenGL 2.0
One last thing: FBOs haven't been an extension for quite some time now. You might try removing the EXT from your calls/constants and see if that still works. (If you're using OpenGL 3 or 4 it should). I know that back when FBO's were still an extension they were a bit harder to work with.

Good luck, I hope this helps!

Edited by Alukien, 05 July 2012 - 11:04 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS