• Create Account

## FBO Question

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.

7 replies to this topic

### #1mikeman  Members

Posted 10 May 2005 - 05:19 AM

I'm following one example I found in the FBO spec to render to a depth texture using FBO. However, it doesn't seem to work. The fbo is created, but when I try to render anything, I get an INVALID_FRAMEBUFFER_OPERATION_EXT error. Is there something I'm missing?
glGenFramebuffersEXT(1,&fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_2D,depth_tex, 0);

glDrawBuffer(GL_NONE);

//Draw something here...

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);



### #2Nithos  Members

Posted 10 May 2005 - 05:38 AM

Hi,

First of all what hardware are you using? If you are doing this on an ATI card then it wont work, their drivers currently dont support the FBO extension. If its an NV card then you need to use the beta drivers as official drivers currently dont support it either.

Assuming the above is not the problem, then the following may be your problems.

1. Are you generating textures?
2. Depth buffer enabled?
3. in your initialization of the fram buffers are you using glFramebufferRenderbufferEXT?

The following code is what I am using and it works for me on NV 6800GT hope this helps.


glGenTextures(numBuffers,&color_tex);
//initialize textures
glBindTexture(GL_TEXTURE_2D,color_tex);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,512,512,0,GL_RGBA,GL_INT,0);

glGenRenderbuffersEXT(1, &depth_rb);
//initialize depth renderbuffer
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 512, 512);

glGenFramebuffersEXT(numBuffers, &fb);
//initialize frame buffers
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,color_tex[i], 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);



### #3mikeman  Members

Posted 10 May 2005 - 05:55 AM

I have a GFX5200 which supports this extension. However, with both your code and mine I get FRAMEBUFFER_UNSUPPORTED_EXT with CheckFrameBufferStatus. Using your code, if I omit the depth attachment, it works. I tried using different depth formats, but to no avail, nothing is supported.

### #4Nithos  Members

Posted 10 May 2005 - 06:09 AM

That is strange, I think I did have problems with that at some point, however I do not remember of hand what fixed it but this code works for me fine.

One edit, if you havent already found this error in my code, the last line should have &color_tex instead of color_tex[i] (the latter is for mutliple textures)

Oh, i just realized i may have missed one line of code, add this to the end after glFramebufferTexture2DEXT.

[source lang=cpp"]glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);



this may fix that depth problem. Hopefully. :)

Nevermind that line was there it just didnt scroll, but make sure u have it. You may have missed it.

### #5mikeman  Members

Posted 10 May 2005 - 06:22 AM

Ok, to summarize this is what I have now:

GLuint color_tex,depth_rb,fb;glGenTextures(1,&color_tex);//initialize texturesglBindTexture(GL_TEXTURE_2D,color_tex);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,512,512,0,GL_RGB,GL_UNSIGNED_BYTE,0);glGenRenderbuffersEXT(1, &depth_rb);//initialize depth renderbufferglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 512, 512);glGenFramebuffersEXT(1, &fb);//initialize frame buffers glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,color_tex, 0);glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);               char str[255];sprintf(str,"Error: %Xh",glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));MessageBox(0,str,"Message",MB_OK);

I use GL_DEPTH_COMPONENT16,24, and 32. The error code I get in all occasions is 0x8CDD, which is FRAMEBUFFER_UNSUPPORTED_EXT.

Any ideas?

### #6Nithos  Members

Posted 10 May 2005 - 06:53 AM

It seems fine to me, u sure your check works correctly, this is what I use to check the status of FBO.

I simply call the following macro

CHECK_FRAMEBUFFER_STATUS() { 	printf("Checking framebuffer status.\n");	GLenum status; 	status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); 	switch(status) { 		case GL_FRAMEBUFFER_COMPLETE_EXT: 		printf("Framebuffer complete.\n");		break; 		case GL_FRAMEBUFFER_UNSUPPORTED_EXT:		printf("Framebuffer unsupported.\n");		/* choose different formats */ 		break; 		default: 		/* programming error; will fail on all hardware */ 		assert(0); 	}}RenderTarget::RenderTarget(){	glGenTextures(1,&color_tex);	//initialize textures	glBindTexture(GL_TEXTURE_2D,color_tex);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);	glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,512,512,0,GL_RGBA,GL_INT,0);			glGenRenderbuffersEXT(1, &depth_rb);        //initialize depth renderbuffer        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 512, 512);	glGenFramebuffersEXT(1, &fb);	//initialize frame buffers		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);                 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,color_tex, 0);	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);	CHECK_FRAMEBUFFER_STATUS();	}

Not sure what to say, but the above code works for me. And from the code you posted its pretty much the exact same thing.

### #7Anonymous Poster_Anonymous Poster_*  Guests

Posted 10 May 2005 - 08:34 AM

make sure you use the latest beta drivers.
Besides that no clue...

### #8mikeman  Members

Posted 10 May 2005 - 10:24 AM