How to create GL window in Windows Forms App?

I’ve done a lot of OpenGL work in Java using JOGL and in Maya using their API, but this is the first time I’ve ever tried creating a project from scratch using Visual Studio Express 2010.

I’d like to write a Hello World program using Windows Forms where I:

  • Create a control that I can draw to with OpenGL
  • Add the control to my form
  • Use OpenGL to clear the background and draw a triangle

I’d like to have the OpenGL area be a control within my form so that I can easily add other controls for user input and display.

I’m finding most of what I find on Google to be out of date and/or confusing. Is there an easy way to write my Hello World program?

I don’t know what exactly a “Windows Forms” is. Is that some c# or VB.NET thing? You can go with OpenTK for your “forms” need.

If it is classical Win32, then you get the HDC of your form and setup a pixel format and create a GL context.

The bottom line is : people call things buttons and windows and forms but they are all windows and have a HDC.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.