7

I'm considering refactoring a large part of my rendering code and one question popped to mind: Is it possible to render to both the screen and to a texture using multiple color attachments in a Frame Buffer Object? I cannot find any information if this should be possible or not even though it has many useful applications. I guess it should be enough to bind my texture as color attachment0 and renderbuffer 0 to attachment1?

For example I want to make an interactive application where you can "draw" on a 3D model. I resolve where the user draws by rendering the UV-coordinates to a texture so I can look up at the mouse-coordinates where to modify the texture. In my case it would be fastest to have a shader that both draws the UV's to the texture and the actual texture to the screen in one pass.

Are there better ways to do this or am I on the right track?

Andos
  • 202
  • 3
  • 12

1 Answers1

6

There is no such thing as "default renderbuffer" in OpenGL. There is the window system provided default frame buffer with reserved name zero, but that basically means "no FBO enabled". So no, unfortunately normal OpenGL provides no method to somehow use its color buffer as a color attachment to any other FBO. I'm not aware of any extensions that could possible provide this feature.

With render buffers there is also the reserved name zero, but it's only a special "none" variable and allows unbinding render buffers.

Tonttu
  • 1,811
  • 10
  • 8
  • 4
    indeed. section 4.4 of the glspec reads: "Initially, the GL uses the default framebuffer. The storage, dimensions, allocation, and format of the images attached to this framebuffer are managed entirely by the window system. Consequently, the state of the default framebuffer, including its images, can not be changed by the GL, nor can the default framebuffer be deleted by the GL." – Shezan Baig Jan 24 '11 at 13:15
  • so that means you can't even add your own renderbuffer to the default framebuffer. to solve your issue, depending on the use case, you can try lookup "gluUnProject", which converts window coordinates to object coordinates – Shezan Baig Jan 24 '11 at 13:18
  • Thanks for the answers. I guess I got confused about the default framebuffer and the "default renderbuffer" which doesn't exist. – Andos Jan 24 '11 at 14:29