Jump to content
  • Advertisement

OpenGL C# Windows Forms and OpenTK (glControl)

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!