PDA

View Full Version : OpenGL MFC components?



Eggman
12-22-2003, 12:34 PM
I would like to create an MFC interface with an OpenGL window embedded in it. Is there an existing component that I can use? I am looking for a dialog driven application, rather than a single or multi document interface. If there is such a component, where can I find it?

Note: I will be using VC++ v. 6 to work with MFC.

Thanks,
Eggman

dorbie
12-22-2003, 12:53 PM
You can use the callbacks on the MFC objects to get the device context and create a graphics context specifying a pixel format descriptor. So in your oncreate callback you can create the context and in the ondraw (onpaint?) callback you can draw your OpenGL stuff.

It's pretty simple if you already know your way around MFC, look at the API calls:

ChoosePixelFormat

wglCreateContext

wglMakeCurrent

You also need to set the size on the onSize call and maybe in oncreate also, it's been a while since I did this. There's lot's of stuff online.

Hmm... a quick google shows Microsoft even has this info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnopen/html/msdn_gl1 .asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnopen/html/msdn_gl1.asp)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnopen/html/msdn_gl3 .asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnopen/html/msdn_gl3.asp)

See the other tutorials in the group for added fun.

This may be the easiest one stop shop for what you need though:
http://www.gamedev.net/reference/articles/article1802.asp



[This message has been edited by dorbie (edited 12-22-2003).]

12-22-2003, 03:19 PM
I have a mfc app, and I am having to call wglMakeCurrent every frame before rendering to ensure I have the context. Is there a way to avoid this? Is wglMakeCurrent expensive?