PDA

View Full Version : Draw on Form



appdeveloper
09-03-2009, 02:07 AM
I see a lot of OpenGL examples on how to use OpenGL on a black window and using OpenGL on a standard window, but now i need to use OpenGL on the same form (Visual C++ 2008) where i created buttons for the user to click and i don't see how.
One example would be Maya or 3D studio Max where you have one or several toolbars and the drawing are in the middle. How can this be made?


My thanks in advanced

MarkZ3
09-03-2009, 06:19 PM
I'm assuming you are using Windows Forms?

First, you have to get a window handle (HWND) from the Form instance you want to draw in:

(HWND)ownerForm->Handle.ToPointer();

Then you do the usual wgl stuff:
- GetDC
- Create a PIXELFORMATDESCRIPTOR ...
- ChoosePixelFormat
- SetPixelFormat
- wglCreateContext
- wglMakeCurrent

Check this page for more details:
http://www.codeproject.com/KB/miscctrl/OpenGLViewWinForms.aspx