Skip to main content
gamedev.net
🔒 Locked

Render to memory

Started by methinks Oct 29, 2005 at 11:17 AM 4 replies 800+ views
Original Post
methinks
methinks
I'm working on a graphic tool right now, and I was wondering if it was possible to render back to the system memory so that the rendered image can be manipulated, rather than being sent directly to the screen. I know that with D3D, it's not possible as communication is "One way" from the system to the video card. But because this isn't a game, the latency involved would be acceptable... if it's possible at all.
Yann L
Yann L
Directly rendering to system memory is not possible, at least not with hardware accelerated pixel formats. But nothing prevents you from rendering to an offscreen surface (most likely a pbuffer), and reading the results back to system memory (via glReadPixels). The performance won't be great, but not that bad either.
methinks
methinks
Thanks, that's what I was looking for! (I think)
Yann L
Yann L
Also note that there are many different ways to implement offscreen buffers. PBuffers are the most widely available and most compatible approach. They're not easy to setup though, and not the fastest (although in your case, this really won't be your bottleneck).

A different and more modern approach are Framebuffer objects. They're much more elegant and faster than pbuffers, yet not as widely supported. Some drivers and hardware combinations will also have very bad performance when reading back from a framebuffer object to main memory.

Your choice. Just ask if you have any additional questions.
markr
markr
Another way of rendering to an offscreen buffer is to use the normal back-buffer - this is certainly the easiest to set up (compared to FBO and Pbuffer), although a little inconvenient if you're using it for something else.

Also, in windowed mode, opengl does not guarantee that areas of the window that are obscured are correctly rendered (even in the back buffer).

Mark
Yann L
Yann L
Quote:
Original post by markr
Also, in windowed mode, opengl does not guarantee that areas of the window that are obscured are correctly rendered (even in the back buffer).

And this is precisely why you should not do it. Contrary to popular belief (and regardless of the fact that it will sometimes work on some hardware), the backbuffer is not a multipurpose offscreen surface. As soon as you start using it that way, you are left alone on the thin ice of undefined behaviour.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.