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.

PureGDK / PureGDK for C++, future additions from Dark GDK

Author
Message
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th Dec 2011 23:58
I've recently started to re-write a large section of my code in PureGDK when I had a thought. So I looked through the header files and compared them properly this time to the Dark GDK ones. There's lots missing that's in the Dark GDK headers, and I was only originally after the "bitmap" and "image" extras.

If the libraries are the same ones that are with GDK and DBP (hopefully) then would it be simple enough to make the template functions as in the PureGDK .cpp files to call those missing functions? Originally I wanted to look at grabbing the direct x surface, but there the low level handling of objects and matrix's I need to do for extra speed in a number of things.

Also the GlobStruct I cannot find either. Is there a way of getting this?

Understandably for other languages like Pure Basic, etc these will not be used whatsoever but in C/C++ it would be handy to get those extra low level commands for low level, get your hands dirty programming in direct x and manual manipulation of other data such as 3d models and matrices, etc.

I could write a simple piece of code that takes the Dark GDK headers and create similar template functions in .cpp file and the .h files to the ones that are already there, but are these available in the compiled dll?

If so then this would be so awesome and I can get straight on to writing the conversion code.

For example:

"DarkSDKBitmap.h" from Dark GDK ( missing dbSetBitmapFormat() )


"pgdk-bitmap.h" from PureGDK


Although the important one at the time for me was the "image" functions and now the GlobStruct and 3d functions.

I'd love to be able to go through the Dark GDK headers and add these functions.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 19th Dec 2011 00:38
Hey WLGfx...
Just tagging along for this one as I wish to grow mg PGDK knowledge...

Now let me get the story straight... you made PureGDK?

Is there a centric website for it?

Thanks in advance... you can see I am quite keen at this moment.

Also I would really love for PGDK 2.0 to support all of DBPro's plugins that would make me buy PGDK long before I consider toying with it

WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Dec 2011 02:11 Edited at: 19th Dec 2011 02:13
If you've used Dark GDK with C++ before then PureGDK is the same with a number of advantages. It's much faster and does support all the plugins that come with Dark Basic Pro. There's a thread that covers this on the main PureGDK forum page. http://forum.thegamecreators.com/?m=forum_view&t=187939&b=38

Mistrel is the guy who's behind it and has done a fantastic job of putting it all together.

I'm asking my question mainly because I recently had to go back to Dark GDK to write my bike game as the beta stopped working for me at the time. While I was working with Dark GDK I noticed that there were a few things missing that gives the C++ programmer in depth access to the internals of the engine.

I'm hoping it's as simple as creating all the template functions like the ones already in the PureGDK .cpp files.

@MrValentine - Honestly though, if you're into C/C++, there really couldn't be an easier engine API to work with. I've recently tried getting my head round OpenGL, easy enough but what the DBP and GDK engine API's have is everything you need without having to spend months googling to do it yourself.

I'll have to wait til well after the new year before I can buy PureGDK. :-(

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 19th Dec 2011 02:28
Cheers

my software programming skills sit with DBPro at present... I will later look at Unity scripting and possibly its ability to use its functions or so I have heard to *assist* dbpro development... but I intend to just into C/C++ when I feel comfortable and require the move (ie: a large project) and eventually as skills increase with experience (not to mention time {years}) I will leap into other mainstream languages such as OpenGL Java C#...

If you have any further input please do share... on the above...

One worrying thing you mentioned was months googling...

I just need to wait for more official detail on version 2.0 ... and I am still confused which editor would be best to code with it for best compatibility and support.

Best regards

WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Dec 2011 02:46 Edited at: 19th Dec 2011 02:49
The closest thing that OpenGL has to a good API is OpenSceneGraph but it is a similar layout, using namespaces and tons of different classes like Ogre3D. Ogre has a lot going for it but takes a long time to learn, that's why I keep coming back time and time again to DBP, PureGDK and C++. C/C++ is my main language for programming, so when you have a good API behind it you can't help but to feel as comfortable as you would playing with Dark Basic.

Both DarkGDK and PureGDK use the same functions as Dark Basic Pro. C/C++ is generally faster because it's as low level programming as you can get before you hit the realm of assembly language.

Dark GDK you have to use Visual Studio 2008 C++ (or use the setup instructions for 2010) and throws you right in the middle which is very handy because you just start programming as you would in Dark Basic Pro. Whereas PureGDK leaves you open to choose what compiler you wish, I use both Code::Blocks and Visual Studio. It also leaves you open to the windows environment more giving you more freedom to go in depth into other API's. It's also more multi-thread safe. I've tested multi-threaded with PureGDK and it's a dream and so easy to do.

EDIT: Amongst the many things with C/C++ programming, at least these forums are active to answer any problems too.

This might help you a tad: http://cslibrary.stanford.edu/101/EssentialC.pdf

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Dar13
15
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 19th Dec 2011 03:02
Quote: "Ogre has a lot going for it but takes a long time to learn"

It actually doesn't take too much time to learn the basics of Ogre, it's more the conversion to an Ogre-compatible workflow, and all the small but oh-so-useful details. By far, the hardest thing for me to wrap my head around was the resource system. Plus, you have to get yourself away from that tutorial framework ASAP otherwise you risk being dependent on it.

If you want something similar to Ogre3D, but not as difficult to master, then I think you might want to try out Irrlicht. It uses some of the same conventions as Ogre does(no IDs, uses C++ features to max, etc) while being more understandable and less immediately complex. I found it was a good transition engine to Ogre.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 19th Dec 2011 03:03
I agree with the multi thread part and I was considering Code:Blocks heard a lot about it on here... I have not used DBC... and umm yeah.. so looks like my plan is solid then minus OpenGL...

I am familiar that C/C++ is low level but thats gor reminding me its something that tends to slip memory... getting old now lol...

Hmm

WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Dec 2011 03:25
I'm just hoping that it is possible (I can't see why not) that I can get more in depth with PureGDK like DarkGDK does. I can use it with MSVC and Code::Blocks.

I've been getting more and more in depth with assembler programming lately and really want to tie up some of those bottlenecks I come across when it comes to using large matrices (Matrix functions in DBP) or rotating and transforming large amounts of 3D objects. If I can get access to the object data direct then I can write my own functions using assembler and directly access the FPU myself.

Irrlicht does do a lot but isn't very fast, although people do recommend IrrKlang for the audio library. Ogre3D seems to be the popular API but as you've said it has a hell of a lot to it and a large learning curve.

TGC software is as simple as make a cube and rotate it. Those other API's require that you initialise all kinds of scene stuff. Moving from DBPro straight into one of the GDK products is smooth.

And you're probably not as old as me

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 19th Dec 2011 03:44
Turning 26 on April 1 next year... yet feel 36...

WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Dec 2011 04:00
And you still feel younger lol... 11 months to go before I'm 40...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 19th Dec 2011 04:03
Quote: " 11 months to go before I'm 40.."


I'll drink to that!

Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 19th Dec 2011 04:05 Edited at: 19th Dec 2011 04:13
Quote: "Originally I wanted to look at grabbing the direct x surface, but there the low level handling of objects and matrix's I need to do for extra speed in a number of things."


You're talking about the matrix library not the matrix4 'ID', right?

Quote: "If the libraries are the same ones that are with GDK and DBP (hopefully) then would it be simple enough to make the template functions as in the PureGDK .cpp files to call those missing functions?"


WLGfx, I'll try to give you a simple overview of how to do this.

The easy way:

Download Dependency Walker (x86) and drag-and-drop the target plugin into it (DBProBitmapDebug.dll in this case). This will show you all of the 'C' exports for this plugin.

For some user and third-party plugins you will have to use the PureGDK tool "strtable.exe" to extract the string table, as non-mangled exports do not identify their parameters.

What you want to find is the export matching the function you want to wrap. To verify the parameters, right click in the area with all of the functions and choose: "Undecorate C++ Functions".

In this list we find:

Quote: "
?SetBitmapFormat@@YAXH@Z <- decorated
..
void SetBitmapFormat(int) <- undecorated"


Now to update the bitmap template, open this file:

Quote: "(Program Files)\PureGDK\templates\libraries\core\Bitmap.gdt"


The way to wrap this function is:

Quote: "DBProBitmapDebug.dll%dbBitmapFormat%L%?SetBitmapFormat@@YAXH@Z%Format"


For a complete breakdown of this line see the following section in the PureGDK documentation:

Quote: "How to > Engine Customization > PureGDK SDK > Wrapping DBP Plugins"


Then just rebuild the headers:

Quote: "Start > All Programs > PureGDK > Compile Headers And Libraries"


The hard way:

See this post where I was working on some other functions:
http://forum.thegamecreators.com/?m=forum_view&t=192116&b=38

I had to guess at the exports because none of them had the same name as the function you wanted. How to solve this?

First, download the DarkGDK source code from Google Code. Use 'grep' or some other search tool to find all references to that function name (-i is case-insensitive, -r is recursive search, see grep --help for more information):

Quote: "grep -ir dbGetImagePointer ."


The result is:



Lets examine "Image/CImageC.cpp":



Ok. Now seatch the same file for "GetPointer":



The 'DARKSDK' typedef means that this function should be exported for DarkGDK and DBP. You can confirm this by examining DBProImageDebug.dll to find this:

Quote: "
?GetPointer@@YAPAUIDirect3DTexture9@@H@Z
..
struct IDirect3DTexture9 * GetPointer(int)"



The way to wrap this function is:

Quote: "DBProImageDebug.dll%dbBitmapFormat[%PL%?GetPointer@@YAPAUIDirect3DTexture9@@H@Z%ImageID"


Alternatively, you can call the function directly like this:



WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Dec 2011 04:54 Edited at: 19th Dec 2011 04:55
Yep, the DBP's matrix library, so I can get the pointer to the sObject or whatever that is for a matrix when I come to experiment.

I'll definitely go down the easier route as I've looked into dll's before for their function declarations. I take it I'm safe to add my own .gdt files to the build?

Thanks again Mistrel, you've helped a lot and I'll have a full blast at it with a clearer brain cell later on today.

Oh yeah, almost forgot. What about the GlobStruct? (actually thinking about it, that would just be a function ReceiveCorePointer or something similar.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 19th Dec 2011 05:38 Edited at: 19th Dec 2011 05:39
Quote: "I take it I'm safe to add my own .gdt files to the build?"


The only thing you should be aware of is that this file will be overwritten if you reinstall PureGDK.

Quote: "What about the GlobStruct?"


DBProCore.dll:

?GetGlobPtr@@YAKXZ
..
unsigned long GetGlobPtr(void)



WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Dec 2011 05:53 Edited at: 20th Dec 2011 08:00
So far I have everything working, the menu shows up, objects load fine. This was after swapping function calls round and dbCloneObject() and dbInstanceObject() got me stumped for a while.

I've added:

to my own gdt file and recompiled everything but the function just returns a NULL pointer when I try:



EDIT: Before I check the dll's I'm just going to do a quick temp on my temporary image as I don't think the dbMakeImageUsage() or dbMakeImage() could be working. I'll keep you posted. Fingers crossed.

EDIT2: That's bits now solved... Wasn't using ID=dbLoadImage() and ID=dbLoadBitmap... Whoops... Now for the other bugs...

EDIT3: dbTimer() is also missing from the standard calls so instead I'm using <time.h> and the clock() function which I'm hoping does the same thing. Key inputs using dbKeyState(VK_ID) did cause me some problems but I got the reference from the Microsoft website to help with that. Eventually I sussed out I hadn't run the windowEvent() on each update. However, I'm still getting a very odd glitch when I switch from the menu to the actual game, the screen and camera jumps around until a collision occurs. I'm looking into it and should have it all up and running finally.

LAST EDIT: Yay!!! Got the PureGDK version of the game working!!! Post it up tomorrow after tidying some things up in the code.

By the looks of things it is running at the same speed as the DBPro version and still so much faster than the Dark GDK version. So I'n going to optimise some of the bottlenecking code and speed it up.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 20th Dec 2011 18:48 Edited at: 20th Dec 2011 18:51
Quote: "dbTimer() is also missing from the standard calls so instead I'm using <time.h> and the clock() function"


As far as I'm aware, there is no portable way to use clock() to achieve milliseconds which is what dbTimer() uses. The replacement for this function is GetTickCount() from Win32.

See here:

http://forum.thegamecreators.com/?m=forum_view&t=188628&b=38&msg=2250924#m2250924

If things appear to be kind of borked, make sure to set up dbSetRuntimeErrorCallback()dbGetErrorString() so you can log any errors which may occur during runtime. This would have informed you of the erroneous ImageID and the mismatched parameters.

I'm glad to hear you got everything working. PureGDK definitely doesn't do the same kind of hand-holding that DarkGDK does.

Here is my favorite Win32 reference. It's not as complete as MSDN but it contains enough information to answer most general questions and it's easier to navigate than a website:

http://www.zerorev.net/reversing/Reversing%20Site%20Mirrors/IT-Assembly/BC52HLP1.ZIP

WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 22nd Dec 2011 11:10
That's the same winapi docs I've been using as my reference, if I need any extra information which is usually rare then I'll go on-line to the MSDN docs.

Got my internet connection back and working properly and finally finished my update to the game. I've posted the benchmarking results here - http://forum.thegamecreators.com/?m=forum_view&t=192633&b=5 for the comparison between Dark Basic Pro, Dark GDK and Pure GDK. I did try to pull out as many stops as possible to up the FPS to get it to beat Dark Basic Pro.

I'll be building up my own gdt file with any extra commands I need as I go along now I know how to do it.

Got to say, I'm still loving Pure GDK. Now for a 3D Scene Editor V2.

Thanks Mistrel...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2024-03-29 02:01:15
Your offset time is: 2024-03-29 02:01:15