Jump to content
  • Advertisement

OpenGL C# Windows Forms and OpenTK (glControl)

This topic is 510 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


I am working on a recent project and I have been learning how to code in C# using OpenGL libraries for some graphics. I have achieved some quite interesting things using TAO Framework writing in Console Applications, creating a GLUT Window. But my problem now is that I need to incorporate the Graphics in a Windows Form so I can relate the objects that I render with some .NET Controls.

To deal with this problem, I have seen in some forums that it's better to use OpenTK instead of TAO Framework, so I can use the glControl that OpenTK libraries offer. However, I haven't found complete articles, tutorials or source codes that help using the glControl or that may insert me into de OpenTK functions. Would somebody please share in this forum some links or files where I can find good documentation about this topic? Or may I use another library different of OpenTK?


Share this post

Link to post
Share on other sites

Seems you did not search enougth. I found THIS in the top 3 results from googel and it seems to be very very beginners friendly.

Ohterwise the native way round for GL in C# uses a window handle to generate the render target from. A Winforms control class has a property to grab its HWND Window Handle so you could pass that as IntPtr (or on the other side as void*) into some GL setup code. I did this a lot of times and it works regardless of the control you use.

To orevent flickering on frequent updates you need just to override some painting settings in your window

    ControlStyles.AllPaintingInWmPaint | 
    ControlStyles.UserPaint | 


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!