Jump to content
  • Advertisement
mapra99

OpenGL C# Windows Forms and OpenTK (glControl)

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

Hello

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?

Thanks!

Share this post


Link to post
Share on other sites
Advertisement

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

this.SetStyle(
    ControlStyles.AllPaintingInWmPaint | 
    ControlStyles.UserPaint | 
    ControlStyles.DoubleBuffer, 
    true);

 

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!