Tuesday 19 January 2010

Runtime linking to Direct3D DLLs

I've added optional runtime linking to the Direct3D DLLs. By runtime linking I mean the linking is done when the application requests it, rather than when the application loads. When runtime linking is enabled, applications which use Direct3D DLLs will still load even if the DLLs are not present.

Typical situations where this is useful are:

1) Enabling applications which require a particular version of DirectX to display an accurate message about the problem - e.g. "Direct3D 11 is not installed".

2) Enabling Applications which work with a range of Direct3D versions (e.g. 9, 10, 10.1, 11) to be run even if one or more versions are not present.

To enable runtime linking:

1) Specify the conditional define "UseRuntimeLinking" in the base build configuration of the Delphi project.

2) Early on in your application, call the Link method (procedure) for each Direct3D header file that you are using.

E.g.

try
  DXGI_JSB.Link;
  D3D10_JSB.Link;
  D3D10_1_JSB.Link;
  D3DX10_JSB.Link;
except
  raise Exception.Create('Direct3D 10.1 is not installed.');
end;

Notes:
 
1) Call "Link" for later versions of Direct3D first, so that the user is instructed to install the latest required version of Direct3D. Typically all the Link calls and associated logic can be put in a single place such as your graphics library and called from many applications.
 
2) Call "Link" only once for each run of the application.
 
3) A special exception "E_Effects11" is raised by D3DX11_JSB if d3dx11Effects_JSB.dll is not present. The reason for this is that this DLL needs to be installed as part of the application and so requires a specific message about this file to be given to the user. (This DLL is typically put in System32 or the application folder).
 
JB.

1 comment:

  1. Thanks for sharing your views about lDelphi . really your post great helpful topics.

    ReplyDelete