Jump to content
  • Advertisement
Sign in to follow this  
AverageJoeSSU

OpenGL frame buffer object init error ... EDIT fixed =)

This topic is 3817 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

First of all, I would like to thank you guys for the help. I would not have gotten this far on my work if it wasnt for the great suggestions you all have given me, i am learning SO much every day from you guys, its only a matter of time before i'll be able to start helping people lol. Anyways, I am using the code from the FBO MRT example, and adding an extra texture to render to. I have an 8800 so i should be good on up to COLOR_ATTACHMENT15_EXT right? anyways... here is my code... its in a constructor of a class. (Does power of 2 textures have anything to do with it? width and height are screen mesurements) here are the vars in the .h (can you guess what the class is? haha) EDIT: I set width and height after initializing... DOH!
GLuint fbo;					// Our handle to the FBO
		GLuint depthBuffer;			// Our handle to the depth render buffer
		GLuint Pos0, Norm1, Diff2;	// Our handle to a textures

		int width;					// The hight of the texture we'll be rendering to
		int height;					// The width of the texture we'll be rendering to




here is the .cpp for the class

// Setup our FBO
	glGenFramebuffersEXT(1, &fbo);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);

	// Create the render buffer for depth	
	glGenRenderbuffersEXT(1, &depthBuffer);
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthBuffer);
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height);

	// Now setup the first texture to render to
	glGenTextures(1, &this->Pos0);
	glBindTexture(GL_TEXTURE_2D, this->Pos0);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	// And attach it to the FBO so we can render to it
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, this->Pos0, 0);

	// after that setup the second texture to render to
	glGenTextures(1, &this->Norm1);
	glBindTexture(GL_TEXTURE_2D, this->Norm1);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	// And attach it to the FBO so we can render to it
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, this->Norm1, 0);

	// after that setup the second texture to render to
	glGenTextures(1, &this->Diff2);
	glBindTexture(GL_TEXTURE_2D, this->Diff2);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

	// And attach it to the FBO so we can render to it
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, this->Diff2, 0);

	// Attach the depth render buffer to the FBO as it's depth attachment
	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthBuffer);

	// Define an array which contains the targets we wish to render to...
	GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT,  GL_COLOR_ATTACHMENT2_EXT};
	// ... then inform OpenGL that we wish to render to these three targets
	glDrawBuffers(3,mrt);

	GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
	
	if(status != GL_FRAMEBUFFER_COMPLETE_EXT){
		std::cout<< "FRAMEBUFFER INIT ERROR" << std::endl;
		system("pause");
		exit(1);
	}

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);	// Unbind the FBO for now

	//mrtprogram = new GLSLProgram("mrt.vs","mrt.fs");



}





Thanks for all the help. [Edited by - AverageJoeSSU on January 10, 2008 12:22:44 AM]

Share this post


Link to post
Share on other sites
Advertisement
That your frame buffer is not complete. Check the spec for more specific information about what it requires to be complete.

Start debugging it by simplifying it so that you only do the COLOR and DEPTH attachments.

EDIT : you already set it as fixed, didn't notice. :)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!