Sign in to follow this  
Grazer2

fbo problems

Recommended Posts

hey there, i'm running into problems using regular frame buffer objects for use with a regular colour texture render target. After these few lines of initialization: GLuint fb_ = 0; GLuint tex_ = 0; glGenFramebuffersEXT(1, &fb_); glGenTextures(1, &tex_); glBindTexture(GL_TEXTURE_2D, tex_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb_); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex_, 0); i get the error constant "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT" when checking the FrameBuffer status by help of that check function. The ATI SDK pdf told me that this error means that the texture format isn't renderable. I took the Texture initialization code out of the samples chapter of the same pdf however. I'm currently on a ATI Radeon 9600 Pro and I'm wondering if my hardware isn't capable of this feature. Anybody got an idea what's causing this?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try setting the texture filter parameters like:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

This might help.

Share this post


Link to post
Share on other sites
yet another problem i ran into. so i got rtt set up properly and implemented a type of motion blur with it, looking like this:

http://www.fichtenmoped.at/maya_knight/cube_blur1.jpg

so far all i did is decrease opacity. now i'd like to start messing with a gaussian blur filter on the screen rendered to a texture. for now it's okay for me to just go with the slow texture copy functions to get the texture into the main memory and then do the gaussian filter there. but after plugging in this piece of code:

GLubyte tex_data_[TEX_SIZE][TEX_SIZE][4];
glBindTexture(GL_TEXTURE_2D, tex_]); //tex_ is the whole screen, rendered to this texture
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_data_);

//gaussian filter to be inserted here later.
//empty for now.

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_data_);

the result looks as follows:

http://www.fichtenmoped.at/maya_knight/cube_blur2.jpg

I didn't perform any manipulation of the texture at all yet. All i did was get the texture (which holds the current frame) into the main memory and then put the very same data back. This texture is then just drawn to the screen with a plane and an orthogonal view. So in theory it should look like the first pic, but something seems to be going wrong.
Could it be that glGetTexImage() is just too slow at copying, producing these results? It's still weird though that there's this pattern in the blur.

Share this post


Link to post
Share on other sites
Concerning your new problem, I think it is not only a problem of speed since the colors of the cube change over time (or did i misunderstood something?).
Concerning your approach for post processing the texture, i'm not sure if it is the best way to do this, but i think you could do it on the gpu. Bind your texture, set viewport size to match your texture size, render a quad on screen and in the pixel shader, apply the filter, using gl_FragCoord.xy as texture coordinates (if using GLSL) to read your texture.
If you don't want to use shader, my post is definitely useless, sorry.

Share this post


Link to post
Share on other sites
It looks to me like the red and blue channels are getting swapped during the copy.

When you copy out the first time red becomes blue and yellow becomes cyan. Then on the next frame, you copy out again and red/blue and yellow/cyan become inverted again and restore back to their original colors.

Not sure _why_ that would be happening, but that's what it looks like. :)

Edit: Now that I think about it, you might want to try glReadPixels instead of glGetTexture... I've never actually used glGetTexture though.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this