Jump to content
  • Advertisement
Sign in to follow this  
zny_sssa2000

two fbo problem

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

hi,i want to save screen to 2 texture,one texture is 1024*1024,the other one is 512*512. so i use two fbo. when i init fbo, i use this code:
bool InitFbo(unsigned int iWidth,unsigned int iHeight)
{
	CreateEmptyTexture(img,iWidth,iHeight);
	// 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_COMPONENT16, iWidth, iHeight);

	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, img, 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);


	GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
	if(status != GL_FRAMEBUFFER_COMPLETE_EXT)
		exit(1);

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);	
	return true;
}



bool InitFbo2(unsigned int iWidth,unsigned int iHeight)
{
	CreateEmptyTexture(img2,iWidth,iHeight);
	// Setup our FBO
	glGenFramebuffersEXT(1, &fbo2);
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo2);

	// Create the render buffer for depth	
	glGenRenderbuffersEXT(1, &depthBuffer2);
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthBuffer2);
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, iWidth, iHeight);

	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, img2, 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, depthBuffer2);


	GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
	if(status != GL_FRAMEBUFFER_COMPLETE_EXT)
		exit(1);

	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);	
	return true;
}


but every time initfbo2() can not successful, i find it has something to do with the GL_COLOR_ATTACHMENT1_EXT, and i has no idea about this. [Edited by - zny_sssa2000 on November 4, 2007 3:20:55 AM]

Share this post


Link to post
Share on other sites
Advertisement
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!