Jump to content
  • Advertisement
Sign in to follow this  
LackOfGrace

OpenGL Bad Framebuffer Behavior

This topic is 4079 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! Ive been messing around with frambuffers (so i would be able to speed up texture rendering) so i wrote a wrapper class for it... and then i got into trouble. firstly the code Header
class CTextureRenderer
{
public:
	//==========================================================//
	//Constructor / Destructor
	//==========================================================//
	CTextureRenderer( void );
	~CTextureRenderer( void );

	//==========================================================//
	//Handling
	//==========================================================//
	void BindTexture( GLuint TextureHandle , unsigned int TextureWidth , unsigned int TextureHeight );

	void BeginRender( void );
	void EndRender( void );

private:
	//==========================================================//
	//Storage
	//==========================================================//
	GLuint mFrameBuffer;	

	//==========================================================//
	//Properties
	//==========================================================//
	static bool mBound;
	unsigned int mTextureWidth;
	unsigned int mTextureHeight;
};

And the source
#include "CTextureRenderer.h"

//==========================================================//
//Static Initialization
//==========================================================//
bool Feat::CTextureRenderer::mBound = false;

//==========================================================//
//Constructor / Destructor
//==========================================================//
CTextureRenderer::CTextureRenderer( void )
{
	glGenFramebuffersEXT( 1 , &mFrameBuffer );
}
CTextureRenderer::~CTextureRenderer( void )
{
	glDeleteFramebuffersEXT( 1 , &mFrameBuffer );
	mFrameBuffer = 0;
}

//==========================================================//
//Handling
//==========================================================//
void CTextureRenderer::BindTexture( GLuint TextureHandle , unsigned int TextureWidth , unsigned int TextureHeight  )
{
	Assert( !mBound , "Cant bind texture to renderer ; Currently rendering to a texture" );

	glBindFramebufferEXT( GL_FRAMEBUFFER_EXT , mFrameBuffer );
	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT , 
							   GL_TEXTURE_2D , TextureHandle , 0 );
	glBindFramebufferEXT( GL_FRAMEBUFFER_EXT , 0 );

	mTextureWidth = TextureWidth;
	mTextureHeight = TextureHeight;
}

void CTextureRenderer::BeginRender( void )
{
	Assert( !mBound , "Already rendering to a texture" );
	mBound = true;	
	glBindFramebufferEXT( GL_FRAMEBUFFER_EXT , mFrameBuffer );
	glViewport( 0,0, mTextureWidth , mTextureHeight );
}
void CTextureRenderer::EndRender( void )
{
	Assert( mBound , "Not rendering to a texture" );
	mBound = false;
	glBindFramebufferEXT( GL_FRAMEBUFFER_EXT , 0 );
	glViewport( 0,0, 500 , 500 );
}

And the renderloop looks like this (psuedo) bind texture renderer 1 render decals unbind texture renderer bind texture renderer 2 render scene unbind texture renderer process texture through filters render result and the problem. when running one instance of the texturerenderer it all work fine when starting from visual studio (Hooked or unhooked) if i run the executable some things dont get rendered. i dont know why some of them dont get rendered, though it is always the same objects. if i try to use two texturerenderes the one that is created first throws a opengl error. can anyone shed some light here? /Victor

Share this post


Link to post
Share on other sites
Advertisement
i need to bump this.
still have the problem

i read some other forum posts wich stated that ati drivers might be broken.
this isnt the problem here since ive tested the program on both an ati card and an nvidia card.

anyone had the same problems?

Share this post


Link to post
Share on other sites
A couple of things

1. Are you attaching non power of 2 textures to the FBO. If you are then try using a texture that has dims is power of 2, 128x128, 256x256 and so on.

2. Are you checking FBO for completeness, glCheckFramebufferStatusEXT before rendering to it?

3. Are you sure its not some sort of other problem like a memory leak or buffer overwrite. Your statement
Quote:

when running one instance of the texturerenderer it all work fine when starting from visual studio (Hooked or unhooked)

makes me suspect that it might be one. Such bugs show up in strange places.

Can't think of anything else atm.

Share this post


Link to post
Share on other sites
Quote:
Original post by _neutrin0_
A couple of things

1. Are you attaching non power of 2 textures to the FBO. If you are then try using a texture that has dims is power of 2, 128x128, 256x256 and so on.

2. Are you checking FBO for completeness, glCheckFramebufferStatusEXT before rendering to it?

3. Are you sure its not some sort of other problem like a memory leak or buffer overwrite. Your statement
Quote:

when running one instance of the texturerenderer it all work fine when starting from visual studio (Hooked or unhooked)

makes me suspect that it might be one. Such bugs show up in strange places.

Can't think of anything else atm.


Only using pow2 textures

all fbos are complete

checked program for mem leaks


didnt make it work :(

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!