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 / Accessing Basic3D functions in GDK

Author
Message
Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 12th Jan 2009 01:18
I need to access some functions that are not defined in the GDK. eg. ?CreateNewObject@@YA_NHPADH@Z

The problem is that although g_pGlob is defined the address of Basic3d is NULL, therefore I can't access any functions within Basic3d.

Am I missing a step that would fill the globstruct structure with this address?

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Jan 2009 14:36
There is no DLL within the GDK so there's nothing to fill that variable in with.

I've been having this same problem myself - in some cases it's not so easy to fix, but this is easy.

Just declare the function in your code:


sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 12th Jan 2009 15:11
Am I understanding this correctly?

With the current updated release of DarkGDK, all we have to do is provide declarations for the functions that are missing from DarkGDK, but are present in DBpro 7.0 .

IE: the functions exist in the new library, but are just not declared?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Jan 2009 18:16
Almost, but not quite. All you have to do is provide the declarations of the functions that are in the library files - that equates to MORE than is available from DBPro. TGC haven't taken any special measures to ensure that these 'internal' functions are hidden, so they're fair game in my eyes, but you take the obvious risk when using them.

I haven't gone much beyond the basics yet, but I do have an untested header file containing the majority of the 3D functions if anyone wants a copy.

Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 12th Jan 2009 21:25
Ian,

I'd most certainly like a copy please

I have tried adding the following line to my library source code



But when I debug my code the function is always showing as 0x0000000

Maybe I'm just not doing things right. I may have produce the D3Dfunc dll but I don't really know what I'm doing with c++.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Jan 2009 21:33 Edited at: 12th Jan 2009 21:35
Why are you compiling as a DLL? You should be compiling as a static library - that's the only way to get everything linked together properly.

If you compile as a DLL, your DLL will have its own copy of the GDK functions and runtime that won't be initialised correctly. You DLL will use those, while the main program will use it's own copy.

The header is attached ... remember, mostly untested and only contains a chunk of the 3D functions - no terrains, matrixs, cameras, lights etc. And if TGC change things in the future, no guarantee it'll continue to work (unless I hack together another one).

Attachments

Login to view attachments
Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 12th Jan 2009 21:44 Edited at: 12th Jan 2009 21:53
Ian,

This is a dll that I am converting to a library. I was just pointing out that althouth I created the original d3dfunc.dll, I'm still a bit of a c++ noob.

Thanks for the header, I'll have a look and see what I can do with it.

EDIT - I've added the functions I require from the header you provided but although it compiles the function CreateNewObject is still NULL. Not sure where I can go with this now!

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Jan 2009 22:21 Edited at: 12th Jan 2009 22:22
It's definitely something you are doing wrong, because it works fine for me:


I'm even using it successfully in a static library myself.


Attachments

Login to view attachments
chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 12th Jan 2009 23:26
@IanM
how do you find the unknown functions/params in a static lib ?
Just by searching with notepad or some software , have searched on google but i can`t find nothing.

@Cloggy
Glad to see your porting d3dfunc to gdk ,good luck from another dll creating c++ noob.

sorry about hijacking the thread .
chunks

nvidia geforce 8600gt + amd athlon 64
windows xp pro.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Jan 2009 09:16
I used DUMPBIN, along with a little creative use of the VIM editor to do regexpr searches/substitutions - it was all very manual.

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 13th Jan 2009 14:32 Edited at: 13th Jan 2009 14:34
Cloggy,

have you tried to take out all the dll stuff from the code?
I mean all those 'EXPORT's, 'APIENTRY', etc.
Perhaps that is part of the problem...

[Edit: Also, I think you changed the D3Dfunc project to be managed code, is that right? Perhaps a managed code library cannot be used, as DGDK uses un-managed code (as far as I know).]
Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 13th Jan 2009 20:25 Edited at: 13th Jan 2009 20:30
What I am doing is attempting firstly to convert d3dfunc.dll to a static library to use with DGDK.

My aim is to then wrap this in a managed code wrapper to create a DGDK.Net version. I started creating a version using slimdx but run into trouble as some of the functions I need are not available in DGDK.Net.

EDIT - I've added the line



to a DGDK windows app and called it using



And that works fine.

If I add the following



and call it using



This fails compilation with the following error.



I've checked the lib and it's definately showing in there.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Jan 2009 20:43
Quote: "void __cdecl SetFOV(int,float)
I've checked the lib and it's definitely showing in there."

Not in any of the GDK libraries I have.
You can't just add prototypes - there needs to be a function in one of the lib files that is an exact match.

There's also already an existing function for the camera FOV (which is what I assume that you were trying to access) - 'void dbSetCameraFOV( float fAngle )'. Just use that.

Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 13th Jan 2009 20:48
Ian,

I'll try that. Strange but when i hexedit camera.lib i can find an entry for setFOV I find the following text ?SetFOV@@YAXHM@Z

I assumed that meant it was exported. But then again what do I know?

Thanks for all you help.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Jan 2009 21:06
Actually, I do see that in there, but DUMPBIN shows it as a 'static' symbol, not 'external'. In C and C++, static variables and functions are never exposed outside of their module - my assumption was (and still is) that static for DUMPBIN has the same meaning.

Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 13th Jan 2009 21:21
That's where I'm going wrong then ! Anyway I have got it working using the DGDK commands dbSetCameraFOV and dbGetImagePointer.

I am still getting a problem when I compile the library in debug mode. It compiles, but when I compile the app using it I get the following error.



I've looked it up, but nothing suggested seems to work. BTW sorry to keep pestering you, but you are the c++ guru around here

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Jan 2009 22:32
Guru is strong ... but I am a good hacker (in the original sense).

For each of the release or debug builds, set the following properties:
C/C++ -> Code Generation -> Runtime Library = Multi-threaded
Linker -> Input -> Ignore Specific Library = libcmtd, msvcrt, atls

That second one isn't available for static libraries, but I think if you set it for your exe builds everything should compile cleanly.
Not selecting the debug runtime doesn't mean you can't debug - it means that you can't debug the runtime library easily. You can still debug your own code.

Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 14th Jan 2009 00:12
Set to Multi-threaded, libcmtd,msvcrt,atls all ignored.

Tried these settings in both my library and exe and still get same problem. Looks like I'll have to live with it.

Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 14th Jan 2009 00:27
Sorry, Got Duplicat post error

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Jan 2009 14:24
Hmmm, I guess I must have made some other changes as well somewhere along the line.

I'll try and work it out on a new project and get back to you with the results.

Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 14th Jan 2009 14:29
Ian,

Last thing I did last night was to create a brand new empty static lib which worked fine, even when I added references to the GDGK functions.

I also tried commenting out my whole project and added back in things until I got the error. It seemed to occur when I included DBOdata.h

I will try to isolate this further tonight as I added DBOdata.h to my test libe and this was fine.

Definately seems like a code thing rather than a linking problem. Only thing is the errors seem to indicate the reverse.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Jan 2009 22:56 Edited at: 14th Jan 2009 22:58
For the static library, set these for both Debug and Release modes:
General -> Character set = Use Multi-byte Character Set
C/C++ -> Preprocessor -> Preprocessor Definitions = WIN32;_LIB;_CRT_SECURE_NO_WARNINGS
C/C++ -> Code Generation -> Runtime Library = Multi-threaded

If you use the DEBUG flag for specific settings when compiling in debug mode, then add it to the preprocessor definitions.

Once that is set, I'll use the following on the exe:
General -> Character set = Use Multi-byte Character Set
C/C++ -> Preprocessor -> Preprocessor Definitions = WIN32;_CRT_SECURE_NO_WARNINGS
C/C++ -> Code Generation -> Runtime Library = Multi-threaded
Linker -> Input -> Ignore specific library = libcmtd, msvcrt, atls

Again, you can add the DEBUG definition to the preprocessor definitions if you use it.

I will then use a header file to ensure that the correct library is linked when building the exe:


That's the reason for the DEBUG definition, and the pragma is only active when NOT building the static library

Give that a go and see if it works for you.

Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 15th Jan 2009 00:17
Ian,

I'm still having problems. Here is a very small lib project that exibits the problem when used in a DGDK project.

I added this code straight into the DGDK source.



and obviously added this as well



the problem is caused by



presumably because that is linking to the C++ runtime.

Would you be able to have a look for me if you have the time?

You help is much appreciated

Attachments

Login to view attachments
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Jan 2009 23:15
Ok, what I've done is created a solution (attached) for you to start with, with 2 projects - one is configured to generate your static libraries for both release and debug, and the other is configured to generate an exe so that you can test the library. I've set it up so that the exe depends on the lib, and will automatically build the lib when you build the exe, if it needs it.

I'm not going to go through all the settings I changed again, because it's basically a repeat of what I've already posted. The thing that was holding you up the most is that you hadn't changed your lib to be compiled using the multithreaded runtime.

Next, the code ...

Forget EXPORT - this isn't a DLL, it's a static library. Unless you specify otherwise, EVERYTHING is exposed, i.e. it uses the opposite default to DLLs.

You stop things being exposed by either making them static, or by putting them into an anonymous namespace:


Anyway, check out the changes I've made to your code, check out the settings, check out the directory structure etc.
Once you are done, you just ship the contents of the lib & include folders for people to use, or the whole thing if you decide to give away the code again.

Attachments

Login to view attachments
Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 16th Jan 2009 00:48
Ian,

Thanks once more for your all your help. I'll have a look at what you have sent me.

On the positive side, I have managed to get my library working in a release build. Gradually going through all the functions to rename them in the same style as DGDK. ie. SetTextFont becomes d3dFont.

Should have something to release soon. Then it's on to converting to .net which be even more fun and games.

Not trying to sound cheesy, but on a very helpful forum you are one of the most helpful users. Cheers!

Cloggy
19
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 16th Jan 2009 22:04 Edited at: 16th Jan 2009 22:14
Still not working, I've decided not to worry about debug at the moment. However I have another stragnge problem now!

I have 2 functions defined in the library



They are in my include file which is referenced in my test project



I then add a line to call each function in the test app



but when I compile I get this error.



It's definately there, but I'm not sure why it can't see it. I have tried giving it a completely different name to no avail.

Does anyone have any ideas what I'm doing wrong?

EDIT - Sorry! Please ignore this post as it would appear that somehow the output path for the release version of the library got corrupted which meant the application was picking up and older version that didn't have the function defined in it.

Login to post a reply

Server time is: 2024-09-30 15:22:27
Your offset time is: 2024-09-30 15:22:27