OpenGL and the GDI

Hi,

How can I use the GDI commands or commands of some description of 2D graphics such as BitBlt, MoveTo, LineTo, Rectangle, and SetPixel, to modify the image which is in the OpenGL backbuffer before I swap them around with:

SwapBuffers(…);

Any help would be grealy appreciated!

Yours Sincerely,
Lea Hayes

I don’t think you can. Here’s a passage from the Win32 documentation referring to the dwFlags member of the PIXELFORMATDESCRIPTOR struct:

PFD_SUPPORT_GDI - The buffer supports GDI drawing. This flag and PFD_DOUBLEBUFFER are mutually exclusive in the current generic implementation.
I suppose it’s possible for a different implementation to support both double buffered OpenGL drawing and GDI, but you probably can’t count on it.

Well you can’t do it directly…

the only way i know of doing it is to do all your OpenGL drawing to a bitmap and then do your gdi drawing to this same bitmap before bliting it to screen. It is important to note that you will loose hardware acceleration if you do this as you have to select at pixel format which is capable of drawing to bitmap and this will not be supported in hardware - also it will not be a double buffered context so you wont need SwapBuffers()

lookup the following article on MSDN
(note you will have to use DIB’s instead of normal bitmaps!)

OpenGL VI: Rendering on DIBs with PFD_DRAW_TO_BITMAP

[This message has been edited by Kev~ (edited 10-24-2002).]