View Full Version : bitblt to window with opengl context
06-21-2004, 07:21 AM
Ive just used BitBlt to a window that has an opengl double buffered context and (surprisingly) it worked.
I thought this wasn't possible! :confused:
Was I wrong or is this most likely a 'feature' of my cards opengl implementation?
Any help greatly appreciated!
06-21-2004, 07:44 AM
can you publish the specific code please?
06-22-2004, 08:58 AM
I suppose I should explain a bit more, sorry!
I can't put all the code up but basically Ive been using code similar to below in a well tested app for the past few years. The opengl context in this case is:
cols 32, Z 24, alpha 8
The card is a (dont laugh) GeForce2 Mx 200 on xp pro.
RenderScene(); //all opengl calls
This works ok until I get overlapping windows and the scene is complicated and of course it slows down (but thats another story). Anyway, in the msdn docs it states you can't perform gdi calls on a double buffered window but the other day I thought Id give it a go. Not as a replacement for the old code but just to see if it would work:
hdcSrc = CreateCompatibleDC(ghDC);
hbmOld = SelectObject(hdcSrc, ghCaptureBmp);
BitBlt(ghDC, 0, 0, swidth, sheight, hdcSrc, 0, 0, SRCCOPY);
ghCaptureBmp = SelectObject(hdcSrc, hbmOld);
where ghCaptureBmp is a handle to a bitmap that has the same color depth as the system (and consequently the opengl context).
Anyway it worked - which was a bit of a surprise.
Now either 1) Ive always misunderstood the limitation on gdi calls to windows with opengl contexts that are double buffered or 2) the docs are wrong or 3) my card is odd.
Anybody any ideas?
Thanks in advance!
06-28-2004, 03:47 PM
GDI calls on on a double buffer don't work in the sense that the drawing doesn't occur on the backbuffer, since GDI is not aware of the backbuffer.
The second problem is that swapbuffer and GDI are not synced so you may see some flashing when you use GDI.
It's best not to mix them, cause even if it works with some card and driver, the next card or next driver update will give different behavior.
Hope this helps explain MSDN better.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.