Regarding render to texture
i am implementing render to texture concept and have doubt regarding scope of a FBOs. After i am done with glDrawArrays call on default FBO with render to texture, i am deleting texture and non default FBO. Then i am calling glReadPixels to read contents on default FBO. So, my question is am i doing it right i mean should i call readpixel before deleting FBO and texture?
What i was assuming that after drawing it on default FBO we dont need non default FBO and texture but later some developer of OpenGL told me i am doing some strange things in my application referring to above. Please help me to understand this.
Here are the steps i am following:
Now, as i have rendered on system FBO and it. why do we still need that texture and other FBO which were used as textures?
Note: I am using terms system FBO to just differentiate between two FBOs its my terminology.
I suggest reading this: http://www.songho.ca/opengl/gl_fbo.html
but all in all here is a bit of pseudo code for Render To Texture in OpenGL
init() {
// setup FBO, attachments, etc...
}
render() {
glBindFramebuffer(your_fbo);
glClearBuffer(...);
renderScene();
glBindFramebuffer(0); // setup default, system FBO
glBindTexture(texture_id_that_was_attached_to_FBO);
renderSecondScene();
}
there is no need to delete textures or fbo after you render your scene, delete them at the end of application in some cleanup proc.
链接地址: http://www.djcxy.com/p/33924.html下一篇: 关于渲染到纹理