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?
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.
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?