Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Complete library to use DarkGDK from any .net language

Author
Message
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Apr 2009 02:36 Edited at: 15th Apr 2009 20:34
I made this library to allow you to use any .net language capable of producing a dll to program DarkGDK with.

The program works by having a generic executable, written in unmanaged C++ and using DarkGDK, which then runs a managed dll, which provides your class library with functions to call any DarkGDK command.

According to this thread:
http://forum.thegamecreators.com/?m=forum_view&t=127379&b=22
I am allowed to distribute this, as long as all code using DarkGDK is in source code only, with no compiled programs, which means that you must download DarkGDK and agree to the DarkGDK license before you can compile and use this library.

Required software/libraries:
Microsoft Visual C++ (any edition, 2005 or above)
[Any .net programming language capable of producing dlls]
SlimDX
DarkGDK
DirectX SDK August 2007

To start, open the file 'DarkManagerDarkManager.sln', and choose build. If DarkGDK is installed correctly, it will build and copy its output to 'ExampleGDKProgram.exe'. Double clicking this will run the example application (which should draw random lines).

To see and edit the code for the example application, open 'ExampleGDKProgramExampleGDKProgram.sln'.

To setup a new project to use this library, create a class library, and then add a reference to 'ManagedWrapper.dll'.
Add a class to your class library which inherits from 'DarkManager.DarkGDKProgram', and implement the Run method. This is where all your code goes.

Copy the executable file 'ExampleGDKProgram.exe' to your project's output directory, and rename it so that it has the same name as the dll file which your project creates.
The 'ManagedWrapper.dll' file should also be in that folder.

To start your program, just run the executable.

All DarkGDK commands can be accessed using the same name, but with a . after the 'db'.

eg.
db.Sync()


Here is some example C# code:


Before distributing your complete application you should add code to the C++ executable to get a hash of the your dll, and compare it against the known hash, so that other people can't use the DarkGDK library without downloading and compiling it, and agreeing to its license.

There are plenty of C++ libraries to do this for you, free on the internet, but I will try to provide an example soon

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!

Attachments

Login to view attachments
Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 7th Apr 2009 02:40
Diggsey man, I love you. This is what I really needed and what I've always wanted. It is soooooo cool!

Everybody should download this because it is truly awesome!

Go Diggsey!I'm so happy because of this!

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 7th Apr 2009 19:31 Edited at: 7th Apr 2009 19:31
Well you kinda of screwed DarkGDK.net up , but owell You gave it away for free so.. I guess thats good

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Apr 2009 21:06 Edited at: 7th Apr 2009 21:07
No, DarkGDK.net has many more features than this. For example, DarkGDK.net allows you to drag a control containing the GDK window onto a form to use, and has a whole load of classes wrapping up the functionality.
Currently, this just exposes the commands themselves.

One good thing is that the input isn't messed up with this one though!

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 9th Apr 2009 13:13 Edited at: 9th Apr 2009 13:27
I cannot run this at all! I only get an error that says: "...cannot be opened because the .vcproj file is not supported by this version of Visual Studio..."
And I have the 2008 version.

Now I try to build with VC++. And now it almost works. But I get different errors:

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 9th Apr 2009 17:26
@CheatCat

The vcproj problem might be caused because I originally created the solution in VS 2008 express, and then I manually edited the project files after so I could open them in VS 2005 (which I own the standard version of, and needed some of its extra debugging functionality)

The error must be because you have a different version of DarkGDK from me.

On the lines where it says that error, either comment out the line as the easy option, or add in a cast to the second parameter which looks like this:


So if the GDK command being casted returns an int, and takes two float parameters, it would look like this:


And so the whole line would look like this:


[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 12th Apr 2009 20:35 Edited at: 12th Apr 2009 20:36
Okey, now manged to make the line drawing program and I am trying to make a program in C#:



I get an Access Volition error when I run this.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 12th Apr 2009 21:54 Edited at: 12th Apr 2009 22:04
You have to make a dll, not an exe. DarkGDK defines the entry point, so you can't. You must copy the unmanaged executable file you compiled before, and rename it to the name of your dll. Put that and ManagedWrapper.dll into the same folder as your project's dll, and to start the project, run that exe.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 13th Apr 2009 05:04
Genius. Simply genius.


CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 14th Apr 2009 13:56 Edited at: 14th Apr 2009 13:56
I don't understand! Should I make a dll file? How?
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 14th Apr 2009 14:37 Edited at: 14th Apr 2009 14:39
Quote: "
To setup a new project to use this library, create a class library, and then add a reference to 'ManagedWrapper.dll'.
Add a class to your class library which inherits from 'DarkManager.DarkGDKProgram', and implement the Run method. This is where all your code goes.

Copy the executable file 'ExampleGDKProgram.exe' to your project's output directory, and rename it so that it has the same name as the dll file which your project creates.
The 'ManagedWrapper.dll' file should also be in that folder.

To start your program, just run the executable.
"


To create a class library, go into visual studio, and click on 'file -> new project'. It will then ask you to choose the project type. On the left you should pick your desired language, and on the right, choose 'class library'. Create your project, and then follow the rest of the instructions above.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
lesPaul456
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location:
Posted: 14th Apr 2009 20:29
Quote: "I cannot run this at all! I only get an error that says: "...cannot be opened because the .vcproj file is not supported by this version of Visual Studio..."
And I have the 2008 version.

Now I try to build with VC++. And now it almost works. But I get different errors:

+ Code Snippet
error C2664: 'RegisterCommand' : cannot convert parameter 2 from 'overloaded-function' to 'void *'"


I get the same error. When I comment out the lines, though, I get two new errors:



and



Does anyone know what's happening? I'd really like to use this.

Thanks!
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 14th Apr 2009 22:28 Edited at: 14th Apr 2009 22:41
If I want to use DarkManager with C#, should I have made class library with C# or VC++?
How I add a class which inherits from 'DarkManager.DarkGDKProgram'? Where I find the 'DarkManager.DarkGDKProgram' thing?
And how I implement the Run method?

Can anyone could explain the steps in detail, please? I am relly dumb..
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Apr 2009 01:10
@lesPaul456
The problems are because you are using a different version of DGDK from me. To solve those linker errors, do this:
Go to the 'RegisterCommands' function, and do a search for 'dbDLLLoad'. Comment out any lines which have it.

@CheatCat
You should create it in C#.
You need to add a reference to ManagedWrapper.dll. In the solution explorer, under your project there should be an item called 'References'. Right click and choose 'Add reference'. Then when the dialog comes up (it may take a while) click on the 'Browse' tab, and choose ManagedWrapper.dll from the location where you saved it, and then click OK.
You now have access to DarkManager.DarkGDKProgram.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
lesPaul456
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location:
Posted: 15th Apr 2009 03:14
Thanks Diggsey, that did it.

Great job!
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 15th Apr 2009 20:07
And then? I have write the code to implement the Run method, but I get this error:
"ClassLibrary1.Class1' does not implement inherited abstract member 'DarkManager.DarkGDKProgram.Run()"

And here is the code:
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Apr 2009 20:19 Edited at: 15th Apr 2009 20:21
Implement is not the same as 'call'

Implement means make your own version of the function which overrides one in a base class (in this case, you should be overriding the 'Run()' method in DarkManager.DarkGDKProgram.

Get rid of your 'main' function, and add a function that looks like this:

public override void Run()
{
<your code here>
}

edit:
It may save you a lot of typing if you write:
using DarkManager;

At the top of your source file.
That means you can refer to 'DarkManager.DarkGDKProgram' as just 'DarkGDKProgram' and 'DarkManager.db.Sync()' as just 'db.Sync()', etc.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 20th Apr 2009 13:27
Oh, should I do the game in a dll file or what?
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Apr 2009 19:05
In a dll.

Maybe it would be easiest if you made a copy of the demo project, and used that as a starting point

[b]Yuor signutare was aresed by a deslyxic mud...
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 29th Apr 2009 12:26
Oh! Easy! It works!
KraHen
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 29th Apr 2009 19:07
So basically now we can have DarkGDK in .NET for free? Without the drag controls and such which we don`t really have in the C++ version anyways?
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 29th Apr 2009 19:58
You still need to have downloaded and agreed to the DarkGDK license, but yes, that is what you get.

Login to post a reply

Server time is: 2024-09-30 23:13:50
Your offset time is: 2024-09-30 23:13:50