Matt N.
Matt N.

Reputation: 1239

Trying to understand Open GL

I am reading the Open GL ES guide provided by Apple but I don't understand it in full detail and have a question. I am very grateful if you help me understand. On page 28, the chapter about drawing, it says the following:

To correctly create a framebuffer:

  1. Create a framebuffer object.
  2. Create one or more targets (renderbuffers or textures), allocate storage for them, and attach each to an attachment point on the framebuffer object.
  3. Test the framebuffer for completeness.

My question is: In point 2, shouldn't it say "create one or more sources..."? As I currently understand it, the frame buffer is what will be rendered to the screen in my draw method. Therefore it would make sense to me if we specify what images we want to have rendered by attaching them to the frame buffer. Clearly, I am misunderstanding something fundamental since in what I describe, the target is the screen and everything else is a source.

Upvotes: 1

Views: 132

Answers (5)

datenwolf
datenwolf

Reputation: 162164

Clearly, I am misunderstanding something fundamental since in what I describe, the target is the screen and everything else is a source.

Yes you fundamentally misunderstood something. A Framebuffer Object is used when you want to render things not to the screen but to some off-screen image. For example a texutre, or some image later being post-processed. If you want to render just to the screen, you don't need a FBO.

Therefore it would make sense to me if we specify what images we want to have rendered by attaching them to the frame buffer.

No. A framebuffer object is not a source of image content, but a "canvas", a receiver, you can draw on. Or more precisely "frame" for the actual canvas, where the target is the canvas to draw on.

Upvotes: 2

Felix K.
Felix K.

Reputation: 6281

The framebuffer sources have nothing to do with the stuff you render. You can attach multiple render targets to each framebuffer and switch between them. However, this is something you don't need actually and it has nothing to do with the rendering step itself until you use multiple passes or need some other render to texture stuff.

I would skip this part of your OpenGL learning and start directly with VBO's and shaders and just use some template for the framebuffers at this point. Later you may need them but not now.

Upvotes: 1

Bartek Banachewicz
Bartek Banachewicz

Reputation: 39370

The framebuffer attachment is first the target of the writes, then the source of the reads. Note that when the spec says "target", it's usually the active object that's being processed or changed, regardless of actual operation.

Upvotes: 2

Nikolai Ruhe
Nikolai Ruhe

Reputation: 81848

Target is correct. A framebuffer renders to a region of memory that later will either be used to be composited to the screen (renderbuffer) or will be used as texture in a secondary render pass.

Upvotes: 2

unwind
unwind

Reputation: 399713

Your program renders into the framebuffer, by executing actions that cause OpenGL to rasterize fragments into the framebuffer.

But, the framebuffer isn't displayed anywhere, unless you do as the documentation says and send it out to a target.

It's a bit like this (very very rough and off the top of my head):

+----------+   +--------+   +---------------------+   +----------------------+
|draw calls|---|pipeline|---|pixels in framebuffer|---|pixels in renderbuffer|
+----------+   +--------+   +---------------------+   +----------------------+

Upvotes: 2

Related Questions