GDR Forum Index
Podcast Podcast
Dev Dev Logs
Search Search
RSS RSS
Register Register
Log in Log in
Reply to topic GDR Forum Index -> Game Developer's Refuge -> Development Log - 3DGamestudio in C#
View previous topic :: View next topic  
Author Message
Gil
Developer

Joined: 14 Nov 2005
Posts: 2341
Location: Belgium
PostPosted: Sun Nov 23, 2008 5:41 pm    Post subject: Development Log - 3DGamestudio in C# Reply with quote

http://www.3dgamestudio.com/

3DGamestudio is basically a full 3D engine with some added tools to create worlds, etc. I have some experience with it and because I'm a bit masochistic (there are probably other better engines for me to fool around with), I'm writing a C# version of the SDK.

Basically, I'm writing a class library that talks with the unmanaged DLL. This class library consists of a few parts:

A layer that talks with the DLL and handles memory
A layer of OO that wraps the first layer into an OO representation

The first layer is a bunch of [DLLImport()] methods. Added to it is a memory handling portion. Basically, when using certain methods, you need to pass pointers to the DLL. The DLL might store those pointers and change them later, so using the "fixed" keyword to make sure the garbage collector doesn't invalidate them would be very clunky, as it would turn the whole class library, even the OO part into unsafe code. What I do is allocate some memory myself through marshaling, and provide a class that keeps the pointer to that and a managed (GCed) copy. When changing the copy, the class also changes the real version and the pointer and backwards.

My goal was to keep instances of these classes away from the user as much as possible, since they more than double the memory needed, but I'm now leaning towards at least giving the user access to them, for advanced use.

It's a bit of a crazy project, but I love working on it :)

I can only release screenshots of examples due to licensing, but I'll try to give a simple example later :)
_________________
PoV: I had to wear pants today. Fo shame!
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4955
Location: Silicon Valley!
PostPosted: Thu Nov 27, 2008 8:57 pm    Post subject: Reply with quote

A bit of this is over my head, but I get the impression that you're almost reverse engineering this thing to get some C# bindings to work? Maybe it's the wrong impression.

The whole reverse propagation stuff freaks me out. What happens when changing the copy isn't pushed back to the real version, but by the time it gets there the real version has been "modified" or doesn't exist any more. Not sure if I'm thinking about it the right way, but to me it reeks of (potential) race conditions.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
Gil
Developer

Joined: 14 Nov 2005
Posts: 2341
Location: Belgium
PostPosted: Wed Dec 10, 2008 8:21 am    Post subject: Reply with quote

I think I'm slowly turning insane here. There just isn't a nice way to do things this way.

I just want a variable in C# which points to unmanaged memory. That's it. Apparently that's not a feasible question to ask Microsoft, so I'm stuck with having to marshal pointers to structures back to pointers. This also means the user of the library can only get copies of stuff, so he has to poll the engine for a new struct every time he/she wants to check something.

Add to that the race conditions you mention.

I just want a freaking variable with a handle to outside memory. Bleh.
_________________
PoV: I had to wear pants today. Fo shame!
View user's profile Send private message Visit poster's website
Madgarden
Contributor

Joined: 31 Aug 2005
Posts: 324
Location: Kitchener, ON, CA
PostPosted: Wed Dec 10, 2008 9:14 pm    Post subject: Reply with quote

It's called C. ;)
_________________
I know it sounds crazy, but it JUST MIGHT WORK
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Gil
Developer

Joined: 14 Nov 2005
Posts: 2341
Location: Belgium
PostPosted: Thu Dec 11, 2008 5:41 am    Post subject: Reply with quote

Yeah, that's the solution, let's go ultra low level :p

No, I think I have some form of solution, I'll be testing it tonight. Basically, I'm going to try to get a reference to outside memory, then I'll try to marshal that in small pieces. What I have in mind should be decent, but it'll depend on some parts of the structure I'm using.
_________________
PoV: I had to wear pants today. Fo shame!
View user's profile Send private message Visit poster's website
Reply to topic GDR Forum Index -> Game Developer's Refuge -> Development Log - 3DGamestudio in C#

Use this link to get a Sign-On Bonus when you get started!

All trademarks and copyrights on this page are owned by their respective owners. All comments owned by their respective posters.
phpBB code © 2001, 2005 phpBB Group. Other message board code © Kevin Reems.