DirectX package for FPC
-----------------------
rel0rev11

Contains header translations of Erik Ungers DirectX for Delphi headers for
FPC. The following packages are already fully translated:

Direct3D
Direct3DRM
DirectDraw
DirectInput
DirectPlay
DirectSetup
DirectSound

The only missing is DirectMusic - but this one seems to use some ActiveX
specific stuff which FPC doesn't support. Hence it makes no sense porting
it.

Includes the first five official DDraw samples and an additional from me
showing DirectDraw operation in windowed mode. And a multi monitor 
enumeration sample program converted from the SDK docs.

This package have been tested using FPC 1.1 - but 1.0 or earlier up to 
0.99.15 should work fine.

NOTES / COMMENTS / USAGE

*) The original files used are the header translations from 30. July 2000.
They already include DirectX7.0a support.

*) Currently all DirectX interfaces up to version 6 are enabled. To change
this to e.g. DirectX3,5,6 or 7 change the line {$DEFINE DIRECTX6} to the
desired one in switches.inc and recompile.
Note that later versions include earlier interfaces, but not the other way
round.

*) This will probably the last header translation in that manner - native FPC
interfaces support is under way, so there is no need for these in the
future.

*) Don't be overwhelmed by the large source files. Due to FPC smartlinking
usually more than 99% won't be included in the resulting program.

*) Still 100% FPC code - absolutely no wrapper needed.

*) I changed the interfaces to be pointers to pointers to the actual methods.
(That's their actual memory representation). So interface method invocation
goes as follows:

var
	anyInterface : IDirectDrawSurface4;
	
	[...]
	anyInterface^^.SetSurfaceDesc(anyInterface, .... [other params] ....);
	[...]
	
I added special FPC wrapper functions to avoid the '^^'. These are always
called <Name_of_Interface>_<Name_of_Method>. As the first parameter you must
always pass the interface itself.

Example (calling the method SetSurfaceDesc() of the IDirectDrawSurface4
'interface'):

var
	anyInterface : IDirectDrawSurface4;

	[...]
	IDirectDrawSurface4_SetSurfaceDesc(anyInterface, ... [other params] ...);
	[...]

All these wrapper functions are included in the 
<Name_of_DirectX_package>FPC.pas source code file. If you don't use this
alternative calling scheme you don't need to add them to the uses clause !

	anyInterface^^.SetSurfaceDesc(anyInterface, ... [other params] ...);
	
does the same as above. The wrapper funcs internally actually just issue
the call in the same way as described last.
[This is similar to the way you have to call COM - Methods with C.

anyInterface->lpVtbl->SetSurfaceDesc(anyInterface, ... [other params] ...);

or 

anyInterface->SetSurfaceDesc(... [other params] ...);

would be the C++ syntax to call interface methods.

*((*anyInterface).lpVtbl).SetSurfaceDesc(anyInterface, 
	... [other params] ...);

the 'real' C one [at least I think so - it seems that eons passed since I did 
plain C programming ;]

Usually C programmers use the macros defined by Microsoft anyway.
The macros look like that:

IDIRECTDRAWSURFACE4_SETSURFACEDESC(anyInterface, ... [other params] ...);

Looks quite similar to the way you can use with the wrapper units, doesn't 
it ?

Don't ask me how you use to call interface methods with VB.... probably
with the IDispatch interface - but that's another topic.]

*) no DirectX docs included - get them yourselves (look at
http://www.delphi-jedi.org/DelphiGraphics/ enter the DirectX section and
other files or the Microsoft homepage (http://www.microsoft.com/directx/).
It's much too big for me to include (don't have that much webspace).
It's excellent btw and a must for a serious DirectX programmer.
There are enough DirectX tutorials in the web around (Note: DirectX methods
must be called like COM-Methods under C, see also demos and/or above)

*) I didn't do the demo programs. Complain to Microsoft except ddex6.pas
btw :) This one is rather a test program......

*) The Bin dir contains the compiled demos and the used resources (BMP files).
Take care of the latter when cleaning this directory)

*) To compile just change the first line of _all_ ppc386.cfg's to the path
of _your_ main ppc386 cfg file. Then enter 'ppc386 xyz.pas' and enjoy. If you
do your own programs, add the lib directory to your main ppc386.cfg file.

*) If you have created a program using this header translation and want to share
your code or just your knowledge, consider contacting me to add it to the DirectX 
corner section.


*) Thanks go to
XRay! (XRay49er@aol.com) - fixed to compile with FPC 1.0
Eero Tanskanen (yendor@nic.fi) - did RMBegin1 example program

Comments, suggestions and feedback are highly appreciated - just drop a
mail at tom_at_work@yline.com ;)

Thomas

12. September 2000

