Jump to content
  • Advertisement
Sign in to follow this  
DanielPharos

OpenGL Delphi: Dynamically linking DirectX

This topic is 4101 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm working on a Delphi project, and I'm using both OpenGL and DirectX as renderers. Recently, someone pointed out my program didn't startup on Windows NT4. I traced it to the fact that there are static links into DirectX 9, which is unavailable on Win NT4. I really don't want to force people to use DirectX 9, or non-Win NT4, since OpenGL can be used in the program as an alternative. I'm using Clootie's DirectX Headers; how to do make sure it's linking dynamically to the DirectX dlls, instead of statically (and then crashing the app)? Or are there any others ways of using DirectX in Delphi (up-to-date please, I've already found tons of outdated projects). Greetz, DanielPharos (PS. I've already send an email to Clootie about it some time ago, but I haven't gotten any response (yet?).) (Edit: Delphi 7 by the way) [Edited by - DanielPharos on September 19, 2007 5:13:38 AM]

Share this post


Link to post
Share on other sites
Advertisement
If you haven't done so, open "Direct3D9.pas" and find this code (it's on top):

// Remove "dots" below to force some kind of dynamic linking
{.$DEFINE DIRECT3D9_DYNAMIC_LINK}
{.$DEFINE DIRECT3D9_DYNAMIC_LINK_EXPLICIT}

As the comment says, remove the dot to enable some kind of dynamic linking. [wink]

Share this post


Link to post
Share on other sites
Yeah, I spotted those before, but since that's their ONLY mention in the entire code, I didn't think they'd do something. But OK, I've tried them, and unless I'm doing something wrong, that doesn't work... I'm still getting the error about d3d9.dll when trying to start the program (yes, I did a full rebuild).

Share this post


Link to post
Share on other sites
I guess the only way to completely remove the dependency is to link the DLL's at runtime, i.e. by using LoadLibrary() and mapping the functions yourself. Perhaps it's easier to provide separate executables for DX and OpenGL, maybe with some stub application to select one automatically.

Share this post


Link to post
Share on other sites
Hmm, I'll probably just write a quick program to convert all the static links into dynamic ones, using LoadLibrary. Weird; if that's going to work, why didn't Clootie use it in his files?
The stub program: I thought about it, but it kinda makes a mess out of things, especially if it's not absolutely necessary. I'll try using LoadLibrary first, thanks!

Share this post


Link to post
Share on other sites
Note that dynamic linking is not the same as runtime linking. With dynamic linking, the code is loaded when your program starts but you cannot run without the existence of the DLL it refers to.

Perhaps this Wikipedia article explains it better than I can:
Linky

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!