Reputation: 3686
How do I pass on the data drawn to a frame buffer to a new openGL program or texture?
Use case of what I am doing now:
uniform sampler2D
by binding it as a GL_TEXTURE_2D
and processing itThis all works fine. The problem is that from here I would like to process all of the above using additional OpenGL shaders. Example a brightness/contrast filter. Not just for the image but to all of the added graphics and vignette. Once that has been added, I'd like to pass that to additional optional programs and so on.
But how is this done? I know I can read it back as a Texture Cache or using glReadPixels() and create a new texture to pass on but surely there is a better and more efficient way? One that uses GPU memory entirely?
Upvotes: 0
Views: 222
Reputation: 1260
you'll need to use framebuffer objects, which allow you to render to a render target other than the default framebuffer, e.g. a 2D texture.
here some sites where you can read more about them:
Upvotes: 0
Reputation: 45948
What you want to do is render something directly into a texture instead of the display framebuffer. This in turn is exactly what Framebuffer Objects (FBOs) are for. An FBO represents a complete framebuffer with all its sub-buffers (like multiple color buffers, a depth buffer, a stencil buffer, or a subset of those), but with the functionality to attach custom data containers (like renderbuffers or textures) as individual buffers and thus render directly into some GPU memory region controlled by you. For a tutorial on those see here or here for some more "official" and complete information (though the latter might also discuss features of modern desktop GL versions not present in ES), or here and here for some more ES related information (which shouldn't be much different from desktop GL, though)
Upvotes: 1