-
February 17th, 2009, 05:22 AM
#1
GDI over OpenGL in Vista
I’ve got problem with using GDI on top of OpenGL in Windows Vista. I’ve found that if GDI graphic would be drawn before any drawing operation of OpenGL than everything what was drawn by GDI would be cleared and would be drawn everything what was drawn by OpenGL before and after. It looks like OpenGL is drawn in separate buffer which after each calling of glFlush function drawn on a screen while clearing what was drawn by GDI. One of easiest solution of the problem is to draw any GDI objects after drawing OpenGL elements, but appears the same problem when the screen spitted on 4 sides. After drawing of one screen, drawing of OpenGL elements next screen clearing GDI objects previous screen. I tried to draw everything on the screen and the copy everything to memory buffer using CDC::BitBlt and then draw this buffer using OpenGL function glDrawPixels. But I found that GDI objects are drawn after exit from CView::OnDraw function, means catch of screen using CDC::BitBlt at the end of CView::OnDraw function do not include GDI objects.
Other case is to draw GDI objects to memory and the draw them by using OpenGL functions did not tested. I am trying to find much easiest way to solve the problem.
Please, help to solve the problem.
-
February 18th, 2009, 12:49 AM
#2
Re: GDI over OpenGL in Vista
I’ve got problem with using GDI on top of OpenGL in Windows Vista. I’ve found that if GDI graphic would be drawn before any drawing operation of OpenGL than everything what was drawn by GDI would be cleared and would be drawn everything what was drawn by OpenGL before and after. It looks like OpenGL is drawn in separate buffer which after each calling of glFlush function drawn on a screen while clearing what was drawn by GDI.
Is there a reason to mix GDI and OpenGL?
-
February 18th, 2009, 04:25 AM
#3
Re: GDI over OpenGL in Vista
Originally Posted by ckweius
Is there a reason to mix GDI and OpenGL?
It is bad idea to do that. But big part of code is already implemented. And to rewrite everything to OpenGL will take huge amount of time. So, I am looking for easest way to solve the problem
-
February 19th, 2009, 12:55 AM
#4
Re: GDI over OpenGL in Vista
I don't think there is an easy way out from what you are trying to achieve, because GDI has no way to target the OpenGL backbuffer directly.
Making GDI calls after buffer flips is not correct either because that will introduce flickering.
I think it's doable to draw GDI objects to memory and let OpenGL does the final rendering.
-
March 4th, 2009, 02:49 PM
#5
Re: GDI over OpenGL in Vista
Are you drawing in 2D?
Draw GDI to memory DC with attached bitmap, then load bitmap into OpenGL texture (32-bit RGBA).
Enable OpenGL alpha-blending, then draw texture transparently to backbuffer.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|