OpenGL: Texturing while Drawing an FBO

Does anyone know if it's possible to render a textured object while drawing a texture FBO? For example, I want to generate a FBO/texture that shows the rendering of a textured teapot. This could be used to show the mirror reflection of said teapot.

I've tried several times now and it always returns an invisible object. The FBO/texture shows lines and other non-textured shaded objects but not the textured ones. Strange...

-- Drawing the same scene directly on main framebuffer works fine. Textured & non-textured objects render fine.

-- The texture ID that I'm rendering to is not used when generating the FBO/texture. So, no circular binding.

-- glGetError doesn't return any error after glDrawElements, so that's not the source of the problem.

-- Texture coords are correct.

-- My graphic card (Intel x3100) does indeed support OpenGL 2.0 on Mac OS-X 10.6.7 and the FBO sample programs work fine (they do not feature texturing however).

This is probably something real simple, but I just can't find it...


If it is not possible, then what's the recommended way to do this? With shaders? Would this require some form of multi-texturing?


FBOs are in way different than other render targets, so texturing works just fine. The only reason is, that parts of the texture units may still be clogged by the FBO attachments. A FBO cannot be render target and texturing source at the same time, so if the OpenGL thinks this may be the case strage things may happen.

Make sure to render FBO used as a texture you first have to unbind the FBO and its attachments from all texture units it's used in, then bind the FBO as render draw buffer.

After finishing drawing to the FBO first unbind it as render buffer target, then bind it to the texturing units you want to use it in.

链接地址: http://www.djcxy.com/p/33916.html

上一篇: FBO:在绘制渲染纹理时渲染到纹理,错误的纹理映射

下一篇: OpenGL:绘制FBO时的纹理