Skip to main content
gamedev.net
🔒 Locked

Newbie C# Question

Started by Exellon Apr 21, 2002 at 1:16 PM 3 replies 450+ views
Original Post
Exellon
Exellon
I''m just getting into C# and I''m wondering if you can do the same thing as you can with C++ or C where the definition of a type or function is separate from it''s declaration like this: public class Application { public static void Main( string[] Args ) { // Main execution code. } public void Fx(); public void Fy(); public void Fz(); } void Application.Fx() { } void Application.Fy() { } void Application.Fz() { } And my other question is about interoperation with COM components. From what the documentation says, it seems to me that you are required to use type libraries. Now the only type libraries I am aware of for DirectX are the ones used by Visual Basic clients.
Dean Harding
Dean Harding
No, it all goes together. C# isn''t a single-pass compiler like C++ is, so you don''t need forward declarations (which is what declaring a class in a header is).

And yes, you use the VB type libraries.


codeka.com - Just click it.
Arild Fines
Arild Fines
If you ask me, its a pure blessing. Forward declarations are nothing but metadata - best maintained by someone more suited for boring and errorprone tasks(eg a computer). Single pass compilers suck.
As for the DirectX thing, there is another approach. You can write a wrapper for DirectX using Managed C++, then expose those classes to C#. This should perform a lot better, since COM interop has some overhead. There is an example of that approach here: http://sunlightd.virtualave.net/Windows/DirectX.NET/
Isn''t cross language interoperability great?

--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Exellon
Exellon
Are there any consortiums or anything currently making a DX8 wrapper with Managed C++ or is it easy enough to do by yourself? I''m the kind of person who likes to reinvent the wheel a lot but in this case I''d make an exception if there was already something out there. Done searches on Google turned up nothing.
Arild Fines
Arild Fines
Eh... did you look at the link?

I dont think there are any "heavy" efforts to make such a wrapper, outside of projects like the one I listed. The fact that DX9 will contain managed wrappers doesnt make it worthwhile.

As for doing it yourself, it should be fairly trivial if you already know how to use DirectX from C++. Its just a matter of throwing on a couple of __gc and __nogc here and there to your .NET-visible classes. The thing I linked to explains this pretty well.

And of course, there''s always OpenGL: csgl.sourceforge.net
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.