Jump to content
  • Advertisement
Sign in to follow this  
PfhorSlayer

Anyone used FBOs?

This topic is 4796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to use frame buffer objects in my app, and I'm having some major difficulties. This is the code I'm using, which is copied directly from an Nvidia presentation:
#define TEX_SIZE	512

#define CHECK_FRAMEBUFFER_STATUS() 
{ 
	GLenum status; 
	status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); 
	switch(status) { 
		case GL_FRAMEBUFFER_COMPLETE_EXT: 
		std::cout << "Framebuffer status = complete" << std::endl; 
			break; 
		case GL_FRAMEBUFFER_UNSUPPORTED_EXT: 
		std::cout << "Framebuffer status = UNSUPPORTED" << std::endl; 
			break; 
		case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: 
		std::cout << "Framebuffer status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT" << std::endl; 
			break; 
		case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: 
		std::cout << "Framebuffer status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT" << std::endl; 
			break; 
		case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: 
		std::cout << "Framebuffer status = GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT" << std::endl; 
			break; 
		case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: 
		std::cout << "Framebuffer status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT" << std::endl; 
			break; 
		case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: 
		std::cout << "Framebuffer status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT" << std::endl; 
			break; 
		case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: 
		std::cout << "Framebuffer status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT" << std::endl; 
			break; 
		case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: 
		std::cout << "Framebuffer status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT" << std::endl; 
			break; 
		default: 
		printf ("return == 0x%x\n", status); 
			/* programming error; will fail on all hardware */
			assert(0); 
	} 
}

(The above source has the backslashes after each line, but it doesn't work with the source tag properly so I removed them)

...

	GLuint fb, depth_rb, tex;
	
	// create objects
	glGenFramebuffersEXT(1, &fb); // frame buffer
	glGenRenderbuffersEXT(1, &depth_rb); // render buffer
	glGenTextures(1, &tex); // texture
	
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
	
	// initialize texture
	glBindTexture(GL_TEXTURE_2D, tex);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, TEX_SIZE, TEX_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	
	// (set texture parameters here)
	// attach texture to framebuffercolor buffer
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);

	// initialize depth renderbuffer
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, TEX_SIZE, TEX_SIZE);
	
	// attach renderbuffer to framebuffer depth buffer
	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);

	CHECK_FRAMEBUFFER_STATUS();


Remember, this is copied directly from an Nvidia presentation, so in theory it SHOULD work. Unfortunately, CHECK_FRAMEBUFFER_STATUS() prints out that it is unsupported! I have a GeForce 6800 GT and the latest beta drivers (forceware 77.50!). Anyone have any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Since no one has tried to help on this, I'll offer the only thing I know on the subject. It looks like you're only trying to attach a depth buffer to the FBO (I may be wrong, I've never even worked with FBOs). Well, I read this is currently not supported, in order to attach a depth buffer you also have to attach a color buffer otherwise it will fail unsupported.

Share this post


Link to post
Share on other sites
Have you got an active gl render context when you call the macro?
Also another note - why are you using a macro? That should just be a normal function that returns void.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Im using FBO correctly. Probably you didn't specified the texture parameters (in the gdc presentation they didn't):

glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

and remember that the size must be equal between all renderbuffers (RB) and internal types between texture and RB must also be the sime.

If that doesn't help contact me: promag@di.uminho.pt

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!