OpenGL with C# ?

I intend to write 1 simple OpenGL application in C# but I don’t know how to do this.
Do you know how to write OpenGL by C# ?

Hope to receive your reply.
Thanks a lot.

Hi !

If memory serves me right, I belive I saw an article about OpenGL on C# at:

(It may also have been


I started to play with OpenGL in C# once. Mainly just to see if I could get it to work. I ran into problems where SetPixelFormat always seemed to fail, but it would return a success code and then wglCreateContext would fail. (I tried using GetPixelFormat after a supposedly succesful SetPixelFormat call and got the wrong answer.)

I did find a library someone had written for doing OpenGL in C# and looked at his code. He actually had put his Choose/Describe/SetPixelformat stuff in a separate C dll, though. Make me think that there is some problem with the managed to unmanaged code in trying to call these functions.

A quick search on Codeproject and Code guru didn’t turn up much on OpenGL and C#, and Google pretty much just turns up the library I found. If anyone has a direct link to an example of using OpenGL directly in C# I’d be interested in seeing that as well.

This is it:


Thanks. That project also appears to use C/C++ to create it’s own DLL for the OpenGL initialization. The C# project then calls into that. It appears you probably can’t do what I was hoping for… (i.e. using the DllImport attribute to directly load the OpenGL stuff from opengl32.dll)

Edit: Just noticed too that the author of the project says he uses the CsGL library by Lloyd Dupont. That seems to be the standard way most people use OpenGL in C#.

[This message has been edited by Deiussum (edited 05-06-2002).]