(*******************************************************************************
                       EXTEND UNIT DXDRAWS FROM DELPHIX PACK

 *  Copyright (c) 2004-2005 Jaro Benes
 *  All Rights Reserved
 *  Version 1.06
 *  D2D Hardware module
 *  web site: www.micrel.cz/Dx
 *  e-mail: delphix_d2d@micrel.cz

 * DISCLAIMER:
   This software is provided "as is" and is without warranty of any kind.
   The author of this software does not warrant, guarantee or make any
   representations regarding the use or results of use of this software
   in terms of reliability, accuracy or fitness for purpose. You assume
   the entire risk of direct or indirect, consequential or inconsequential
   results from the correct or incorrect usage of this software even if the
   author has been informed of the possibilities of such damage. Neither
   the author nor anybody connected to this software in any way can assume
   any responsibility.


   Sorry for any future errors but I first saw DelphiX in 17-3-2004 and DirectX
   began learn some month later.
   First work started at 13.9.2004.
   All units in this pack contain last changes and was added very interesting
   units (for study or inspiration)
   Tested in Delphi 5, 6, 7 and Delphi 2005

 * FEATURES:
   a) Implement Hardware acceleration for critical function like DrawAlpha {Blend},
      DrawSub and DrawAdd for both way DXIMAGELIST and DIRECTDRAWSURFACE with rotation too.
   b) Automatic adjustement for texture size different 2^n.
   c) Minimum current source code change, all accelerated code added into:
      DXDraw.BeginScene;
      //code here
      DXDraw.EndScene;
   d) DelphiX facade continues using still.

 * HOW TO USE
   a) Design code like as DelphiX and drawing routine put into
      DXDraw.BeginScene;
      //code here
      DXDraw.EndScene;
   b) setup options in code or property for turn-on acceleration like:
      DXDraw.Finalize; {done DXDraw}
      If HardwareSwitch Then
      {hardware}
      Begin
        if NOT (doDirectX7Mode in DXDraw.Options) then
          DXDraw.Options := DXDraw.Options + [doDirectX7Mode];
        if NOT (doHardware in DXDraw.Options) then
          DXDraw.Options := DXDraw.Options + [doHardware];
        if NOT (do3D in DXDraw.Options) then
          DXDraw.Options := DXDraw.Options + [do3D];
        if doSystemMemory in DXDraw.Options then
          DXDraw.Options := DXDraw.Options - [doSystemMemory];
      End
      Else
      {software}
      Begin
        if doDirectX7Mode in DXDraw.Options then
          DXDraw.Options := DXDraw.Options - [doDirectX7Mode];
        if do3D in DXDraw.Options then
          DXDraw.Options := DXDraw.Options - [do3D];
        if doHardware in DXDraw.Options then
          DXDraw.Options := DXDraw.Options - [doHardware];
        if NOT (doSystemMemory in DXDraw.Options) then
          DXDraw.Options := DXDraw.Options + [doSystemMemory];
      End;
      {to fullscreen}
      if doFullScreen in DXDraw.Options then
      begin
        RestoreWindow;
        DXDraw.Cursor := crDefault;
        BorderStyle := bsSingle;
        DXDraw.Options := DXDraw.Options - [doFullScreen];
        DXDraw.Options := DXDraw.Options + [doFlip];
      end else
      begin
        StoreWindow;
        DXDraw.Cursor := crNone;
        BorderStyle := bsNone;
        DXDraw.Options := DXDraw.Options + [doFullScreen];
        DXDraw.Options := DXDraw.Options - [doFlip];
      end;
      DXDraw1.Initialize; {up DXDraw now}

 * NOTE Main form has to declare like:
      TForm1 = class(TDXForm)

 * KNOWN BUGS OR RESTRICTION:
   1/ Cannot be use DirectDrawSurface other from DXDraw.Surface in HW mode.
   2/ New functions was not tested for two and more DXDraws on form. Sorry.

 * HISTORY
 1.01 28.03.2005 JB.
   Fix bug in Restore image procedure, when is picture change under HW mode.
 1.02 29.05.2005 Takanori Kawasaki
   Fix bug in TD2D.D2DFreeTextures memory leak.
 1.03 03.06.2005 JB.
   Partially corrected transparent color area when display on 16 bit screen.
  +Added full support for Delphi3 (overrides removed, dynarray supplement).
 1.04 11.06.2005 JB.
   Fix bug in bitmap mapping (8, 16, 32 bit) to DIB 24 bit.
   Fix bug in test transparent color from changed DIB.
  +Added D3D support for Draw() routine.
 1.05 19.06.2005 JB.
  +Function for D3D Draw() conditional switch off/on added, because not work
   properly on some adapters (Draw() accelerated in DirectDrawSurface yet).
   Can be turn on please uncomment {$Define DrawHWAcc} in DelphiXcfg.inc


 ******************************************************************************

 * PACK NOTE for (un)DelphiX pack recompilation with hardware acceleration

   For simple application start can be use the prototype application in this pack

 * PACK HISTORY
 09.06.2005 JB.
 + Better compatibility with Delphi 4.
 + Some .dpk files revised, installation for all the same.
 + added the DXMisc.pas file contain some useful functions.
 + DXSprite.pas file revised for support under Delphi 3;
   Under Delphi 3 cannot be use colli3DX.pas, isn't adapt still, sorry.
 12.06.2005 JB.
 + Improvement of hardware acceleration and fix-bug.
 19.06.2005 JB.
 + Fix-bug in Draw() function.
 23.10.2005 JB.
 + DXSpriteEngine improvement
   Isn't necessary derive classes sprite, it is possible use DrawAdd, DrawAlpha and DrawSub also for BackgroundSprite.
   New proposal sprite from editor, sorting into the collection (likewise as with DXImageList or DXWaveList), generation Events.


 