PDA

View Full Version : Accessing a DC's backbuffer



Punchey
11-05-2000, 01:27 PM
I'm using a hybrid OpenGL - DirectDraw/GDI approacn in my app. The problem is, does anyone know of a way to use GDI or anything else to access the backbuffer associated with a rendering context (device context) to render to it with something other than OpenGL? Or is there any way to use OpenGL to obtain a pointer to the back buffer? When I use the same HDC for GDI as I use for OpenGL, I can only get to the frontbuffer. Even if I swap the buffers back before I do my OpenGL rendering. Anyone have any ideas? Thanks!

Siwko
11-07-2000, 09:59 AM
You can't in OpenGL... any GDI operations in Windows always access the currently active page (front buffer).

A workaround exists, but it sucks (flicker and stuff). Render your scene and call SwapBuffers, THEN do your GDI calls.

Bass ackwards, but it works.

Siwko

Punchey
11-08-2000, 06:28 AM
Actually, it doesn't work. That's what I was talking about in my first post. I tried that. I tried using GDI, then swapping the buffers, then rendering with OpenGL, then swapping again. Should I omit the second swap? Would that make it work you think? So I guess there's no way to get rid of the flicker then huh? What about using DirectDraw? Does anyone know if you can use OpenGL with a DirectDraw surface's DC?

Siwko
11-09-2000, 08:34 AM
Originally posted by Punchey:
[B]Actually, it doesn't work. That's what I was talking about in my first post. I tried that. I tried using GDI, then swapping the buffers, then rendering with OpenGL, then swapping again. Should I omit the second swap? Would that make it work you think? So I guess there's no way to get rid of the flicker then huh?B]


Actually, yes, it does work. The key is, you render with OpenGL, swap, then do your GDI op's. After the GDI op's, you don't swap again.

The reason its not working for you is what I said earlier. In a double-buffered environment, OpenGL renders to the back buffer - thus the entire reason you call SwapBuffers : to get the image onto the screen. GDI _ALWAYS_ renders to the front buffer. Thus, if you call a swap AFTER your GDI calls, you erase what the GDI has done.

And no, OpenGL doesn't coexist (well, if at all) with DirectDraw.

Siwko