SundayMonday
SundayMonday

Reputation: 19727

Scaling the contents of OpenGL ES framebuffer

Currently I'm scaling down the contents of my OpenGL ES 1.1 framebuffer like this:

  1. save current framebuffer and renderbuffer references
  2. bind framebuffer2 and smallerRenderbuffer
  3. re-render all contents
  4. now smallerRenderbuffer contains the "scaled-down" contents of framebuffer
  5. do stuff with contents of smallerRenderbuffer
  6. re-bind framebuffer and renderbuffer

What's an alternative way to do this? Perhaps I can just copy and scale the contents of the original framebuffer and renderbuffer into framebuffer2 and smallerRenderbuffer. Hence avoiding the re-render step. I've been looking at glScalef but I'm not sure where to go from here.

Note: this is all done in OpenGL ES 1.1 on iOS.

Upvotes: 0

Views: 765

Answers (1)

Tommy
Tommy

Reputation: 100622

You could do an initial render to texture, then render from that to both the frame buffer that you want to be visible and to the small version. Whatever way you look at it, what you're trying to do is use the data that has been rendered as the source for another rendering so rendering to a texture is the most natural thing to do.

You're probably already familiar with the semantics of a render to texture if you're doing work on the miniature version, but for completeness: you'd create a frame buffer object, use glFramebufferTexture2DOES to attach a named texture to a suitable attachment point, then bind either the frame buffer or the texture (ensuring the other isn't simultaneously bound if you want defined behaviour) as appropriate.

Upvotes: 1

Related Questions