New update: Version 2.0xb (9.Feb.99)!
DirectX for Delphi 2-4
Version Changes:
Click here
Version 1.8 is the last release of the converted DirectX 5 units for Delphi 2, 3 and 4.
Version 2.0 is DirectX 6.0 for Delphi 2, 3 and 4.
You can download an adaption of Hori's DX 5 Media SDK units here.
Known problems:
DInput and Delphi 2: I have made a workaround, which should solve the problems with D2's internal error(s).
Delphi 2 and 3/4 COM syntax:
In future versions (DX 6.1 and 7.0) I will not support Delphi2 COM-syntax anymore !
All units can be used with Delphi 2, 3 and 4.
Because Delphi 3/4 has a new syntax for COM-interfaces,
I have implemented a mechanism that allows you to choose
between the old Delphi 2 and the new Delphi 3/4 COM-syntax.
(See Delphi documentation for more information about COM-interfaces)
If the compiler-symbol D2COM is defined in the file
COMSWITCH.INC (included by all units),
then the old syntax (which is compatible with Delphi 2 and 3/4) is used.
Else you need Delphi 3 or 4 to compile the units.
You can use the AddCOM and ReleaseCOM functions of DXTools
for version-independent COM managment.
UNICODE and ANSI strings:
Some DirectX-objects can handle UNICODE and ANSI strings.
The names of interfaces and records that use (PWideChar) UNICODE-strings
end with a 'W' and their ( PAnsiChar) ANSI-pendants with an 'A'.
You can select UNICODE as default stringtype by defining
the compiler-symbol UNICODE in the file STRINGSWITCH.INC.
If UNICODE is not defined, then ANSI is the default stringtype.
The default stringtype is used, when you use interface
and record-names that don't end with A or W.
(In some cases that's different to the original headers, which
use only 'Name' and 'NameA', where 'Name' is the UNICODE version)
Delphi look and feel typenames:
I have modyfied the names of records, enumerated-,
and other types, so that they look like 'default Delphi' typenames.
Here is a list with representative examples:
| C | Delphi |
Record types | D3DCOLORVALUE | TD3DColorValue |
Pointer types | LPD3DCOLORVALUE | PD3DColorValue |
Enumerated types | D3DLIGHTTYPE | TD3DLightType |
Enumerated values | D3DLIGHT_SPOT | D3DLIGHT_SPOT * |
Constants | D3DENUMRET_OK | D3DENUMRET_OK * |
Interfaces | LPDIRECTDRAW2 | IDirectDraw2 |
Procedural types | D3DVALIDATECALLBACK | TD3DValidateCallback |
* no changes
Parameters passed as pointer-types in the C-headers got converted to var/const-parameters,
if nil won't be passed as value.
procedure foo(Arg: PRect) // C-style
procedure foo(var Arg: TRect) // Pascal-style used in the conversion
Note that you have to pass the first field of an array in many cases
where the C-version expects the address of a buffer !
Helper unit DXTools:
The unit DXTools gives you some useful tools that
make DirectX-coding a little bit more handy.
The procedure which you will use very often is DXCheck.
It takes a HResult value returned by a DX-call
as argument, and raises an exception with a short description
of the error if necessary. DDCheck, D3DCheck, ... will do this
only for a particular DirectX API.
The procedure InitRecord fills a record with zero, and writes
the recordsize into the first DWord.
ReleaseCOM releases Delphi 2 and 3/4 COM-interfaces
(and sets the pointer to nil), even when they are not initialised.
ReleaseCOMe does the same, but raises an excepten
if the interface is not initialised.
DXTools has also some matrix-functions for 3D applications:
ProjectionMatrix and ViewMatrix calculate homogenius-matrices
for your virtual camera.
Copyrights and JEDI:
You may use the conversion like freeware :-)
I am a member of the JEDI-Project
(a non-profit organisation that adapts Microsoft API's for Delphi),
therefore these units are the official JEDI-DirectX API.
Contact me !
It would be great to get some feedback from you.
Tell me what you think about the conversion,
if there are problems and what could be done better.
Thanks in advance for your bug-reports :-)
My E-Mail address is: ungerik@bigfoot.com
Download:
You can download the files DirectX5.zip and DirectX6.zip (>100kB) from my
Delphi Graphics Homepage
Credits:
I want to thank
Blake Stone for his initial
DX3 conversion, which was the base for my first steps,
David Sisson for his generic conversions with PERL,
Hiroyuki Hori whose DX5 conversion was helpful in some cases,
the JEDI graphics team and and many other guys for bug-reports and fixes.
Have fun,
Erik Unger.