This is implemented in terms of EGL Pbuffers, which turned out to be pretty simple and quick to do. The API is simple:
Code: Select all
pbuffer = eglCreatePbufferSurface(dpy, pbuffer_config, texture_attrib);
...
// make pbuffer the render target
eglMakeCurrent(dpy, pbuffer, pbuffer, ctx);
// render into pbuffer
// make screen the render target again
eglMakeCurrent(dpy, screen, screen, ctx);
glBindTexture(GL_TEXTURE_2D, texid)
eglBindTexImage(dpy, pbuffer, EGL_BACK_BUFFER);
// render using pbuffer texture
This is pretty similar to the standard EGL pbuffer API, but it imposes fewer restrictions; for example, you can use a surface for rendering, even if it is bound to a texture (though obviously you get pretty undefined results if you render from a texture into itself - though it might be worth trying). Other GL features, such as automatic mipmap generation, work with pbuffer-derived textures.
I'm still planning on implementing Pixel Buffer Objects and Frame Buffer Objects. These extensions also allow render-to-texture, but in a more standard and flexible way (though perhaps more complex to use and implement).