Jump to content
  • Advertisement
Sign in to follow this  
Khaos

OpenGL OpenGL in C#

This topic is 4803 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 trying to understand this. If I want to use OpenGL in C# (and .NET, not Mono), what am I required to do to get started? The documentation seems minimal. I assume I need to download the Tao.OpenGL framework. Right? Well, which parts? I see Tao.OpenGL.cs and it is a HUGE file that I can't even begin to make sense of. How do I start an application and get started with that file? I don't even know what to do.. is there a list of basic function calls and constants to get started with simple things? It all seems so overwhelming. I would just like someone to break it down for me, in simple steps because files that large with thousands of constants just seems impossible to understand. Does this file just translate native windows OpenGL calls to the .NET framework, or something? Lots of externs, etc. And what is Tao.Glut and such? Thanks in advance for any help.

Share this post


Link to post
Share on other sites
Advertisement
You're on the right track. :)

Each section is a wrapper for some API, including OpenGL, OpenAL, etc, etc. To use OpenGL with C#, I would recommend downloading the *.cs files (with the possible exception of the AssemblyInfo.cs files) under Tao.OpenGl and Tao.Platform.Windows.

If you open up the files, here's some of what you can expect to see:

[DllImport("opengl32.dll", EntryPoint="glColorPointer"), SuppressUnmanagedCodeSecurity, CLSCompliantAttribute(true)]
public static extern void glColorPointer (int size, int type, int stride, bool [] pointer);

Here's a basic breakdown of what it all means:
As for the DllImport statement, it basically sets up the following statement to go into the "opengl32.dll" at a specific point, "glColorPointer," passing certain arguments and with a return value (in this case, void). So the answer to your question is yes, it translates native OpenGL calls to .NET by "wrapping" them in a way that .NET languages can access.

The second statement serves as a function prototype for you to use, just like all the original OpenGL function calls.

To get started working with Tao.OpenGl, you might want to take a look at the NeHe tutorials that have been coverted to C# (also in the Tao SVN repository).

Basically, what you are going to end up doing is creating a UserControl that inherits from Tao.Platform.Windows.SimpleOpenGlControl. You might want to take a look at that class to see how to get the contexts to be current, make your OpenGl calls, and swap the buffers.

After you have your control set up, you can simply attach it to a window and watch it go (provided you render it continuously, of course)!

Again, I would definitely look at the NeHe conversions and even check out NeHe's website, hosted by our friendly GameDev.net. NeHe's website splits everything up into tutorials and explains everything quite well.

Awhile back, I posted a SimpleTaoExample on my website. The version of Tao is a little bit older (a couple of months old now), but it works just fine. It just creates a custom OpenGL control, attaches it to a window, and displays a white triangle on a black background (with the process I just described). It might be enough to get you going. :)

I hope I didn't muddy the waters with this post, and I hope it helps!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!