LWJGL Forum

Programming => OpenGL => Topic started by: pobrien on March 07, 2010, 03:53:29

Title: FBO/texture problem
Post by: pobrien on March 07, 2010, 03:53:29
Hi,

  I'm having trouble with framebuffers. I've successfully done framebuffers in c/c++ and openGL, but I'm missing something. I get this error:
GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT

I think it has something to do with the textureID. In c, I create a GLuint, and then do a glGenTextures, which is then
used for the fbo.

Any help is much appreciated, I've tried a bunch of things and nothing works!

Here is the code. Its pretty much straight from the wiki.
  IntBuffer texID = ByteBuffer.allocateDirect(1*4).order(ByteOrder.nativeOrder()).asIntBuffer();
GL11.glGenTextures(texID);
   
   boolean FBOEnabled = GLContext.getCapabilities().GL_EXT_framebuffer_object;

IntBuffer buffer = ByteBuffer.allocateDirect(1*4).order(ByteOrder.nativeOrder()).asIntBuffer(); // allocate a 1 int byte buffer
EXTFramebufferObject.glGenFramebuffersEXT( buffer ); // generate
int myFBOId = buffer.get();

EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId );
EXTFramebufferObject.glFramebufferTexture2DEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT,
               GL11.GL_TEXTURE_2D, texID.get(0), 0);

int framebuffer = EXTFramebufferObject.glCheckFramebufferStatusEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT );
switch ( framebuffer ) {
case EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT:
break;
case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
throw new RuntimeException( "FrameBuffer: " + myFBOId
+ ", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception" );
case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
throw new RuntimeException( "FrameBuffer: " + myFBOId
+ ", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception" );
case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
throw new RuntimeException( "FrameBuffer: " + myFBOId
+ ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception" );
case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
throw new RuntimeException( "FrameBuffer: " + myFBOId
+ ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception" );
case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
throw new RuntimeException( "FrameBuffer: " + myFBOId
+ ", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception" );
case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
throw new RuntimeException( "FrameBuffer: " + myFBOId
+ ", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception" );
default:
throw new RuntimeException( "Unexpected reply from glCheckFramebufferStatusEXT: " + framebuffer );
}

Title: Re: FBO/texture problem
Post by: Kai on March 07, 2010, 17:52:07
Hi,

as you would have to do it in C, too, you need to initialize the texture first before attaching it to the FBO with glTexImage2D after you generate the texID.
Title: Re: FBO/texture problem
Post by: pobrien on March 07, 2010, 18:59:58
i feel stupid, thanks for pointing that out, I'm not getting that error now.