Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: FBO + Picking questions

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2013
    Posts
    4

    FBO + Picking questions

    So I have a few, kind of strung out questions that I have been writing down as I was reading some stuff. Basically I'm dropping a simple graphics library that I've been using in lieu of QT + raw OpenGL, and while I have come to understand a lot of the ideas surrounding openGL, a little bit is still unclear.

    - What's the difference between a frame buffer object and a render object (in terms of drawing ability)? Doesn't an FBO have several rendering objects?
    - Does a window (say, a GLUT or QT window) have a single FBO? How many render objects does it have (by default)?
    - If the above question is yes, can I create another render object to do off-screen rendering to, or must I create a whole new FBO?
    - Can I blit an FBO/Render object to another?
    - If I'm understanding this correct, an FBO has several render objects, one of which is drawn to the actual window (when it is created, it creates an FBO/render object). Can other render objects have other contexts, and therefore be multi-threaded? Am I totally off-base with this?

    Also, another kind of irrelevant question:

    - Is picking (selection mode) the preferred/efficient (if done properly) way to find which objects on the screen are being clicked/moused over?
    - Does it have any marginal speed increase over other, CPU-bound hit testing methods? What about for purely 2D orthographic applications?

    I couldn't find any yays/nays about picking - only tutorials, so I thought I'd ask.

    Thank you in advance for any information!

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    I'm going to assume that your use of the term "render object" really means "renderbuffer object".

    What's the difference between a frame buffer object and a render object (in terms of drawing ability)? Doesn't an FBO have several rendering objects?
    Framebuffer objects are containers. They store references to images (from textures or renderbuffer objects), which you can render to. You create an FBO, then attach images from textures/renderbuffers to it, and then you can render to those textures/renderbuffers via the FBO.

    An FBO may reference multiple images, textures or RBOs, or some combination of both.

    Does a window (say, a GLUT or QT window) have a single FBO?
    No. A window has a Default Framebuffer. While this is given the FBO object number 0, it is not like a regular FBO at all. You cannot change the attachments to the default framebuffer. The names of the default framebuffer's attachment points are different from those of FBOs. The default framebuffer's images are automatically resized as the window is resized. And so forth.

    In short, default framebuffers have little in common with FBOs, besides the fact that they're both framebuffers.

    Can I blit an FBO/Render object to another?
    Yes, assuming you follow the appropriate formatting and multisample rules.

    If I'm understanding this correct, an FBO has several render objects, one of which is drawn to the actual window (when it is created, it creates an FBO/render object).
    An FBO has multiple attachment points, which may have images attached to them. None of these images are the actual window. Only the default framebuffer represents the actual window.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2013
    Posts
    4
    Ohh alright, that makes much more sense.

    However;

    You cannot change the attachments to the default framebuffer
    How come I can attach textures to a window's frame buffer, then? And if you don't render to a framebuffer (but instead of a render buffer), what am I rendering to when I'm rendering in the window's context?

    Also, speaking of contexts, is a context just a framebuffer (or, what's the ultimate connection)?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Now you seem to be making less sense. You can't attach textures to a window's framebuffer. You can attack textures to an FBO, but not to a window's default framebuffer. If you have code that you think does this, post it; it almost certainly does not.

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2013
    Posts
    4
    So what am I attaching a texture to when I create one in the default window's context? Or is it not 'attached' to anything?

  6. #6
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Now you're confusing "context" with "framebuffer".

    A framebuffer is a series of images that you can render to. This can be the context's default framebuffer or an FBO. The OpenGL context is all of the state (and objects) associated with an active instance of OpenGL. Each context has its own separate default framebuffer, but contexts are more than that.

    You can not attach a texture to the default framebuffer. If you think that you have done this, then you are mistaken. A texture does not have to be attached to a framebuffer at all; they're freestanding objects. You only attach a texture to a framebuffer if you want to render to it.

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2013
    Posts
    4
    Ohhh okay, that makes much more sense. That's what I needed to know.

    Now, what about the picking end of the post?

  8. #8
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    456
    No, you shouldn't use selection or feedback mode, since it'll typically be really slow. There's a couple of suggestions at http://www.opengl.org/wiki/Common_Mi..._Feedback_Mode
    1) Render each object a unique color + use glReadPixel to read back this color and hence determine the object (only need to render the part of the screen actually involved in picking).
    2) Use a 3rd party mathematics library to do the picking.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •