2
\$\begingroup\$

I need to do some offscreen render to use the rendered image in something different from OpenGL context (for instance I need to use the image in a QListWidgetItem inside a Qt application). After documenting a little bit I've found that Frame Buffer Object (FBO) is what I have to use in combination with glReadPixels for getting the raw image from OpenGL/GPU into my application. So, here I am against FBO.

I've found that I need to attach the FBO to a texture otherway it does not work and glCheckFramebufferStatus gives me: GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER. So when I try to init the FBO I need to add also glGenTextures and glBindTexture etc..

But.. why? I don't need a texture for now.. why do I have to declare/init/bind (don't know what is the best word here) a texture?

What is the "minimal" FBO setting for get the images? And what about if in my application I need also stencil or depth images? Are things different?

And using back buffer instead of FBO? Is it slower? Do I still need a texture?

I'm kind of afraid of using textures because of a lot of parameters () I don't understand for now..

Sorry for confusion..

\$\endgroup\$
3
  • \$\begingroup\$ If you don't understand the "lot of parameters" that textures have, what makes you think you're ready to understand Framebuffers? Or do you just want some code you can copy-and-paste into your application? \$\endgroup\$ Jul 16, 2013 at 11:57
  • \$\begingroup\$ No I don't understand why for get an image from OpenGL I need also a texture and not only a frame buffer object.. My code actually works, I just want to understand why the need of a texture (that in what I have understand from the render pipeline is something more) \$\endgroup\$
    – nkint
    Jul 16, 2013 at 12:13
  • \$\begingroup\$ Related: stackoverflow.com/questions/3191978/… \$\endgroup\$ Mar 26, 2016 at 15:30

1 Answer 1

1
\$\begingroup\$

In OpenGL terms, a "Framebuffer" is an object that holds references to images which can be used as render targets. "Framebuffer Objects" are user-created framebuffers who's image references come from images you explicitly allocate (as different from the "Default Framebuffer", who's images come from the OpenGL context).

Framebuffers are not the sources of images; they only hold references to existing images, like pointers.

There is no "image object" in OpenGL. There are objects that contain one or more images. FBOs can therefore take their images from one of these objects. The object can be a texture or a renderbuffer. Textures can have one or more images (array levels, mipmap layers, cubemap faces), while renderbuffers only have a single image.

It sounds like you just want a renderbuffer or two for your color and depth/stencil images.

\$\endgroup\$
5
  • \$\begingroup\$ ok, thanks! a little bit more clear.. so I can use FBO with texture OR with render buffer.. It seems like I didn't noticed this in all the pages I've found till now, and the answer to my question "Why do I need a texture" is simple: "you don't need it, you can do render off-screen with a render buffer" \$\endgroup\$
    – nkint
    Jul 16, 2013 at 12:42
  • \$\begingroup\$ Ok good! I've managed to use Render Buffer (and not texture) for both color and depth buffer! but now.. how can I read the depth buffer only? Is it possible with glReadPixels? If I use only glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer); before glReadPixels I get only some glitch and if before I use glBindFramebuffer(GL_FRAMEBUFFER, fboId); I get only the colour buffer.. \$\endgroup\$
    – nkint
    Jul 16, 2013 at 15:17
  • \$\begingroup\$ @nkint: That's a new question. You were asking about the images in a framebuffer, not how to read data from a framebuffer. Also, feel free to look at any of the actual information in those links, like for example, the section on reading data from a framebuffer. \$\endgroup\$ Jul 16, 2013 at 18:15
  • \$\begingroup\$ yes, I was thinking about a new question! \$\endgroup\$
    – nkint
    Jul 16, 2013 at 22:01
  • \$\begingroup\$ here it is: stackoverflow.com/questions/17711673/… \$\endgroup\$
    – nkint
    Jul 17, 2013 at 22:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .