Monday, May 24, 2010

Using glut.dll in C#?

Is there a way to convert glut.dll lybrary for visual C++ so that it can be used in C#?

Using glut.dll in C#?
Conversion isn't what you're looking for here, but rather "wrapping". The API calls have to be wrapped in C# so it's convenient to use. You'll find that mainstream OpenGL %26amp; .NET integration hasn't been a topic of great interest in several years - most hobbyists opt for Direct3D in .NET and development shops have their own methods for tying the two together.





That having been said, the largest project is/was http://csgl.sourceforge.net/ I've used this in the past to a very limited degree. GLUT is fully supported.





A much simpler and smaller project is http://www.colinfahey.com/csharp_wrapper... - all GLU functions are supported.





Both of these projects work well, but active development has ceased. Hope that helps - good luck.
Reply:Well, you can get ahold of the glut source and turn on the CLR flag in the C++ compiler and recompile it into a managed assembly, but that's going to be a lot of work.





Or you can use P/Invoke to call the glut methods.





I know there are managed OpenGL libraries available for C#.





But actually the best is to use managed direct X, as it will allow you to do the same things. Since you're using C#, you're stuck with Windows, so you don't need the portability that the OpenGL platform provides.
Reply:yes.





dunno if it's a good idea or not (due to interop), but you could use the type-library import tool (tlbimp.exe or something like that, it comes with .Net) to create an assembly you can use as a reference.





it will spit out a new dll that you can link to in your project, with no need to do DllImports etc.
Reply:c# really isnt a good platform for 3d graphics programming because you surrender a lot of power for greater simplicity. i suspect that you may have trouble compiling the c++ glut header files in c#. and as far as the .dll goes it sounds like it may be a proprietary .dll for vc++. however i dont really use vc++ for my purposes so i could be proven wrong.


No comments:

Post a Comment