Jump to content
  • Advertisement
Sign in to follow this  
golgoth13

OpenGL FBO Mechanic!

This topic is 3953 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 everyone! This must be a dummy issue but I can’t find the way out yet… when rendering with a FBO, everything that it is rendered is not written into the frame buffer. 1- SetFrameBuffer(m_FrameTexture, AX6_COLOR_ATTACHMENT0_EXT, true); 2- Render 3d 3- UnsetFrameBuffer(m_FrameTexture); 4- Render 2d What am I missing here? BTW: I know the process is correct because I display the 3d objects on a textured 2d plane. But beside the plane, the actual 3d elements are not visible. Here is some code:
void OpenGL::SetFrameBuffer(Texture *in_texture, e_Attachments in_attachment, Bool in_generate)
{
	UInt &l_id = in_texture->GetBufferId();
	if (l_id == 0)
	{
		AX6_RENDERER()->GenerateTexture(in_texture);
		AX6_RENDERER()->DisableTexture(in_texture);

		if (in_generate)
			glGenFramebuffersEXT(1, &l_id);

		glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, l_id);
		glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, l_id);

		glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, in_attachment, in_texture->GetDimension(), in_texture->GetId(), 0);
		OPENGL_CHECK_FRAME_BUFFER_STATUS();
	}
	else
	{
		glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, l_id);
		glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, l_id);
	}
}

void OpenGL::UnsetFrameBuffer(Texture *in_texture)
{
	if (in_texture->GetBufferId() != 0)
	{
		glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
		glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
	}
}





[Edited by - golgoth13 on February 12, 2008 9:48:32 PM]

Share this post


Link to post
Share on other sites
Advertisement
The GL_READ_FRAMEBUFFER_EXT and GL_DRAW_FRAMEBUFFER_EXT targets are only used for framebuffer blitting.

If you're doing normal rendering then you just need bind to GL_FRAMEBUFFER_EXT.

So:


void OpenGL::SetFrameBuffer(Texture *in_texture, e_Attachments in_attachment, Bool in_generate)
{
UInt &l_id = in_texture->GetBufferId();
if (l_id == 0)
{
AX6_RENDERER()->GenerateTexture(in_texture);
AX6_RENDERER()->DisableTexture(in_texture);

if (in_generate)
glGenFramebuffersEXT(1, &l_id);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, l_id);

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, in_attachment, in_texture->GetDimension(), in_texture->GetId(), 0);
OPENGL_CHECK_FRAME_BUFFER_STATUS();
}
else
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, l_id);
}
}

void OpenGL::UnsetFrameBuffer(Texture *in_texture)
{
if (in_texture->GetBufferId() != 0)
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
}

Share this post


Link to post
Share on other sites
Humm… thx… I did try this and I still can’t see anything…

The steps I m doing looks like this:

1 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
2 glClearColor();
3 SetFrameBuffer(m_FrameTexture, AX6_COLOR_ATTACHMENT0_EXT, true);
4 Render 3d
5 UnsetFrameBuffer(m_FrameTexture);
6 Render 2d
7 SwapBuffers

I did swap step 1,2 and 3 in any order possible…

I this point I really don’t know but I m still digging. any suggestion would be appreciated.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!