Jump to content
  • Advertisement
Sign in to follow this  
NagD

OpenGL Problem in combining GDI with OpenGL

This topic is 828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hai All,
i am using openGL in MFC VC++ vs2008. In onDraw method I am drawing grid using CPen object and then I am drawing something using openGL API then i called SwapBuffer(hDc) then the previous drawings were erased and only the drawings which is drawn using openGL API is remaining. 
If i didn't put the SwapBuffer(hDc) then the openGL drawings are not rendered. How can i get the combined output. Is it possible to keep OpenGL drawing on background.
 
Best Regards
Nageswara Rao

Share this post


Link to post
Share on other sites
Advertisement
First two hits on Google for "GDI OpenGL":

http://www.gamedev.net/topic/558160-2d-rendering-with-windows-gdi-on-top-of-3d-opengl/

https://www.opengl.org/discussion_boards/showthread.php/175512-RE-mixing-GDI-with-OpenGL

They indicate that:

(1) You have to draw with GDI _after_ drawing with OpenGL, since SwapBuffers does exactly what it's name implies and swaps in a new buffer replacing the old one.
(2) There's some extra trickery you have to do on WDDM-based OSes (Vista and up) to make the legacy crufty GDI functions play nicely.
(3) Mixing GDI and GL/D3D is going to work poorly no matter what you do and you should really just let GDI sleep peacefully in its grave and stop trying to resurrect dead APIs. :P

Share this post


Link to post
Share on other sites

Hi ,

      Thanks a lot for your response.it was working on calling glFinish() after SwapBuffers. But more there are  flickers and crashes. I just found one application which contains the similar functionality.I have shared the video at below link. Can you please tell me how could they have done it?. Thank you.

 

     video   https://drive.google.com/file/d/0B0MUXp49k3d8T3d5NGRuVDZTejA/view?usp=sharing

Share this post


Link to post
Share on other sites

What makes you think that app contains similar functionality? I don't see any indication they are combining GDI and OpenGL.

Share this post


Link to post
Share on other sites

I mean they are displaying 3D model in background(first view) and 3D view contains vertical ,horizontal ruler. 

 

Maybe my interpretation was wrong.Can you please tell me how they could display 3D model on background and switch to opengl view.

Edited by NagD

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!