Hello All,
I am calling two shader functions in a loop. Just before calling shader function I prepare resources for it to compute on.
Assume 3 textures of equal dimensions are to be attached to FBO fb
Steps:
1. Enable Texture GL_TEXTURE_RECTANGLE_2D
2. Bind to off-screen frame buffer.
glBindFrameBufferEXT(GL_FRAMEBUFFER_EXT, fb); [Assumed that fb was generated in some contstructor] and change viewport settings.
3. set up textures
setTexture(W , H, data , texture unit number , tex) ;
where parameters are self explanatory.
4. Attach to FBO
glFrameBufferTextureEXT(..)
5. Call shader function to perform calculations
6. unbind texture units.
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_RECTANGLE , 0);
....
[same for GL_TEXTURE1 and GL_TEXTURE2 ]
7. disable texture
glDisable(GL_TEXTURE_RECTANGLE_ARB) ;
8. switch to on-screen or main frame buffer
glBindFrameBuffer(.. , 0);
..... [Rest of the code]
Note: After this I do not plan to delte texture ids and fbo id as I am calling shader in a loop.
9. //to solve other problem using a different shader
switch back to off-screen FBO and change viewport settings
10 . set up 2 textures of same dimensions but different from that used previously ( for previous shader)
11. call shader function number 2
12. same steps as 1-8 , but no FBO will have two attachments.
The Problem:
Q1 . I know that EXT version FBO does not permit 2 attachments of different formats and dimensions, but I need to know that after applying step no. 6 and step no.7 , why there should be any complaints of different dimensions attachment prohibited – by the same FBO identifier named “fb” ???
The error is thrown at step 10 when I am trying to attach my first texture identified by tex[0] at GL_COLOR_ATTACHMENT0_EXT to the FBO?
One of the solutions can be to go for ARB_FBO but that is supported at OGL 3.0 and + . I have OGL 3.0+ but need to know why there be an error of different dimensionality when I am removing textures from the attachments and then disabling GL_TEXTURE_RECTANGLE_ARB ???
Q2. Or is there another way to remove attachments from FBO ?
I used reference: http://www.opengl.org/wiki/GL_EXT_framebuffer_object
Q3. When I write
//assuming this is done when current frame buffer is "fb" [Off-screen frame buffer]
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE , 0);
..
Will it remove the attachment from FBO or just detach texture data from texture unit GL_TEXTURE0???
Q4. If for Q3, texture data is removed from GL_TEXTURE0 then how come FBO remembers previously attached texture’s dimensions ?
Help appreciated.