PDA

View Full Version : OpenGL with C# ?



earthgod
05-06-2002, 02:05 AM
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.

mikael_aronsson
05-06-2002, 04:28 AM
Hi !

If memory serves me right, I belive I saw an article about OpenGL on C# at:
http://www.codeguru.com

(It may also have been www.codeproject.com) (http://www.codeproject.com))

Mikael

Deiussum
05-06-2002, 05:04 AM
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.) http://www.opengl.org/discussion_boards/ubb/smile.gif

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.

mikael_aronsson
05-06-2002, 11:26 AM
This is it:
http://www.codeproject.com/csharp/exoengine.asp

Mikael

Deiussum
05-06-2002, 12:41 PM
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).]