Skip to main content
gamedev.net
🔒 Locked

frame buffer object

Started by 7Days Apr 25, 2006 at 8:31 AM 2 replies 600+ views
Original Post
7Days
7Days
HI, I am new so i don't know exactly who i should ask!!! I would like to know how to have access to the frame buffer object. Here is my code: // texture glGenTextures(1,&tex); //initialize textures glBindTexture(GL_TEXTURE_2D,tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,256,256,0,GL_RGB,GL_FLOAT,color_YUV444); //FBO glGenFramebuffersEXT(1, &fb); //initialize frame buffers glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,tex, 0); check();//chek if the frame buffer object is well attached // render to the FBO glBindTexture(GL_TEXTURE_2D, tex); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); // render to the window, using the texture glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindTexture(GL_TEXTURE_2D, tex); I would like to know how I can have access to the texture. My goal is to write my figure in the frame buffer object(the color), and then pass it as a texture to my fragment shader in order to filter it??? But I don't know how to access the frame buffer as a texture??
MARS_999
MARS_999
Maybe I am not 100% sure on what you are doing, but all you need to do is render the image you want into the FBO and then shutdown the FBO render a quad or some mesh call the texture object that you bound to the color attachment in the FBO, as a texture sampler in your shader... AFAIK you can't have direct access to the FB but you can have access to the textures all you want that the FBO renders to...
7Days
7Days
thanks for your reply.

My problem is actually that I don't know how to shutdown the FBO.
Furthermore I don't know how to pass the texture to my shader.

My goal is actually to downsample the texture, in order to make convertion from RGB to YUV422. So I want to have access in the CPU to my texture, is it possible.
For the moment I use "glReadpixel", and I store theresult in an array that I downsample, but it is not really efficient I think....
zedzeek
zedzeek
u need to unbind the current fbo (thus it will render to the framrbuffer)

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

+ just bind that FBO texture to a texture unit
glBindTexture(GL_TEXTURE_2D,tex);

but it looks like youre doing this, perhaps theres something wrong with the FBO try a GL_UNSIGNEDBYTE instead of GL_FLOAT texture first

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.