CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2009
    Posts
    12

    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.

  2. #2
    Join Date
    Mar 2004
    Location
    KL, Malaysia
    Posts
    63

    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?

  3. #3
    Join Date
    Feb 2009
    Posts
    12

    Re: GDI over OpenGL in Vista

    Quote Originally Posted by ckweius View Post
    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

  4. #4
    Join Date
    Mar 2004
    Location
    KL, Malaysia
    Posts
    63

    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.

  5. #5
    Join Date
    Mar 2009
    Posts
    12

    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
  •  





Click Here to Expand Forum to Full Width

Featured