Probably the title is confusing, but I didn't know how to ask better, sorry about that. What I would like to do is get a bitmap texture that represents exactly what's rendered at one point in time and save it as a file (I know how to save it, I need only to find out how get the bitmap data form OpenGL) Like a screen shoot, sort of.
|
I think that changing the Render Target is what you're looking for. This is also known as "Render to texture". When you draw stuff in GLES (or GL, or DirectX, or whatever you use), the place the stuff you draw to is called the "Render Target". Usually you render on a backbuffer to be drawn onto the screen, but graphic engines also allow you to draw on a custom render target you can then use as a texture for drawing other stuff. Custom render textures are the key to enable interesting effects such as mirrors, shadow mapping, PiP, among many others. Here's another explanation of render buffers, for XNA. In particular, for GLES, you may want to look at Here's an example of how to do it in desktop OpenGL. |
|||||
|
|
glReadPixels can read back pixel values from the framebuffer, which you can then save out to disk. (Note that you don't want to use glReadPixels normally, as it makes your code stall while the GPU catches up, and reading pixels back from the GPU is usually a rather slow operation. But for the purposes of saving screenshots or debugging rendering issues, it's absolutely what you want to use. If the eventual goal is to feed rendered images back into the rendering system for use as a texture, then Panda's answer is the correct and performance-friendly way to do that. But if you need to get the pixel values back to the CPU so you can save them out, glReadPixels is really the only way to do that.) |
|||
|
|
