⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directdraw.pas

📁 delphi编的不错的贪吃蛇
💻 PAS
📖 第 1 页 / 共 5 页
字号:
(*)
 [------------------------------------------------------------------------------
 [  DirectDraw 7.0 Delphi Adaptation by Erik Unger
 [------------------------------------------------------------------------------
 [  Files    : ddraw.h
 [           : dvp.h
 [  Modified : 11-Sep-2002 
 [  E-Mail   : Ampaze@gmx.net
 [  Download : http://www.crazyentertainment.net
 [------------------------------------------------------------------------------
(*)
(*)
 [------------------------------------------------------------------------------
 [ History :
 [----------
 [ 11-Sep-2002 (Tim Baumgarten) : Delphi7 Changes
 [ 11-Sep-2002 (Tim Baumgarten) : Cosmetic Changes 
 [------------------------------------------------------------------------------
(*)
 
unit DirectDraw;

interface

{$MINENUMSIZE 4}
{$ALIGN ON}

{$IFDEF VER150}
  {$WARN UNSAFE_CODE OFF}
  {$WARN UNSAFE_TYPE OFF}
  {$WARN UNSAFE_CAST OFF}
{$ENDIF}

uses
  Windows;

var
  DDrawDLL : HMODULE = 0;

function DDErrorString(Value: HResult) : string;

function MAKEFOURCC(ch0, ch1, ch2, ch3: Char) : LongWord;

(*
 * FOURCC codes for DX compressed-texture pixel formats
 *)
const
  FOURCC_DXT1 = 'DXT1';
  FOURCC_DXT2 = 'DXT2';
  FOURCC_DXT3 = 'DXT3';
  FOURCC_DXT4 = 'DXT4';
  FOURCC_DXT5 = 'DXT5';

(*
 * GUIDS used by DirectDraw objects
 *)
const
  CLSID_DirectDraw        : TGUID = '{D7B70EE0-4340-11CF-B063-0020AFC2CD35}';
  CLSID_DirectDraw7       : TGUID = '{3c305196-50db-11d3-9cfe-00c04fd930c5}';
  CLSID_DirectDrawClipper : TGUID = '{593817A0-7DB3-11CF-A2DE-00AA00b93356}';

const
  DD_ROP_SPACE = (256 div 32);       // space required to store ROP array

  MAX_DDDEVICEID_STRING	= 512;

(*
 * Flags for the IDirectDraw4::GetDeviceIdentifier method
 *)

(*
 * This flag causes GetDeviceIdentifier to return information about the host (typically 2D) adapter in a system equipped
 * with a stacked secondary 3D adapter. Such an adapter appears to the application as if it were part of the
 * host adapter, but is typically physcially located on a separate card. The stacked secondary's information is
 * returned when GetDeviceIdentifier's dwFlags field is zero, since this most accurately reflects the qualities
 * of the DirectDraw object involved.
 *)
  DDGDI_GETHOSTIDENTIFIER         = $00000001;

(*============================================================================
 *
 * DirectDraw Structures
 *
 * Various structures used to invoke DirectDraw.
 *
 *==========================================================================*)

var
  NilGUID : TGUID = '{00000000-0000-0000-0000-000000000000}';


type
  TRefGUID = packed record
    case integer of
      1 : (guid : PGUID);
      2 : (dwFlags : LongWord);
  end;

  IDirectDraw = interface;
  IDirectDraw2 = interface;
  IDirectDraw4 = interface;
  IDirectDraw7 = interface;
  IDirectDrawSurface = interface;
  IDirectDrawSurface2 = interface;
  IDirectDrawSurface3 = interface;
  IDirectDrawSurface4 = interface;
  IDirectDrawSurface7 = interface;

  IDirectDrawPalette = interface;
  IDirectDrawClipper = interface;
  IDirectDrawColorControl = interface;
  IDirectDrawGammaControl = interface;

(*
 * Generic pixel format with 8-bit RGB and alpha components
 *)
  PDDARGB = ^TDDARGB;
  TDDARGB = packed record
    blue  : Byte;
    green : Byte;
    red   : Byte;
    alpha : Byte;
  end;

(*
 * This version of the structure remains for backwards source compatibility.
 * The DDARGB structure is the one that should be used for all DirectDraw APIs.
 *)
  PDDRGBA = ^TDDRGBA;
  TDDRGBA = packed record
    red   : Byte;
    green : Byte;
    blue  : Byte;
    alpha : Byte;
  end;

(*
 * TDDColorKey
 *)
  PDDColorKey = ^TDDColorKey;
  TDDColorKey = packed record
    dwColorSpaceLowValue  : LongWord;  // low boundary of color space that is to
                                       // be treated as Color Key, inclusive
    dwColorSpaceHighValue : LongWord;  // high boundary of color space that is
                                       // to be treated as Color Key, inclusive
  end;

// Delphi 5 can't handle interface in variant records
// so we have to use pointers instead (which can be type-casted into interfaces):

{$IFDEF VER130}
  PDirectDrawSurface = Pointer;              
{$ELSE}
{$IFDEF VER140}                // D6, TP 14
  PDirectDrawSurface = Pointer;
{$ELSE}
{$IFDEF VER150}                // D7
  PDirectDrawSurface = Pointer;
{$ELSE}
  PDirectDrawSurface = IDirectDrawSurface;
{$ENDIF}
{$ENDIF}
{$ENDIF}

(*
 * TDDBltFX
 * Used to pass override information to the DIRECTDRAWSURFACE callback Blt.
 *)
  PDDBltFX = ^TDDBltFX;
  TDDBltFX = packed record
    dwSize                        : LongWord;     // size of structure
    dwDDFX                        : LongWord;     // FX operations
    dwROP                         : LongWord;     // Win32 raster operations
    dwDDROP                       : LongWord;     // Raster operations new for DirectDraw
    dwRotationAngle               : LongWord;     // Rotation angle for blt
    dwZBufferOpCode               : LongWord;     // ZBuffer compares
    dwZBufferLow                  : LongWord;     // Low limit of Z buffer
    dwZBufferHigh                 : LongWord;     // High limit of Z buffer
    dwZBufferBaseDest             : LongWord;     // Destination base value
    dwZDestConstBitDepth          : LongWord;     // Bit depth used to specify Z constant for destination
    case integer of
    0: (
      dwZDestConst                : LongWord      // Constant to use as Z buffer for dest
     );
    1: (
      lpDDSZBufferDest            : PDirectDrawSurface; // Surface to use as Z buffer for dest
      dwZSrcConstBitDepth         : LongWord;     // Bit depth used to specify Z constant for source
      case integer of
      0: (
        dwZSrcConst               : LongWord;     // Constant to use as Z buffer for src
       );
      1: (
        lpDDSZBufferSrc           : PDirectDrawSurface; // Surface to use as Z buffer for src
        dwAlphaEdgeBlendBitDepth  : LongWord;     // Bit depth used to specify constant for alpha edge blend
        dwAlphaEdgeBlend          : LongWord;     // Alpha for edge blending
        dwReserved                : LongWord;
        dwAlphaDestConstBitDepth  : LongWord;     // Bit depth used to specify alpha constant for destination
        case integer of
        0: (
          dwAlphaDestConst        : LongWord;     // Constant to use as Alpha Channel
         );
        1: (
          lpDDSAlphaDest          : PDirectDrawSurface; // Surface to use as Alpha Channel
          dwAlphaSrcConstBitDepth : LongWord;     // Bit depth used to specify alpha constant for source
          case integer of
          0: (
            dwAlphaSrcConst       : LongWord;     // Constant to use as Alpha Channel
          );
          1: (
            lpDDSAlphaSrc         : PDirectDrawSurface; // Surface to use as Alpha Channel
            case integer of
            0: (
              dwFillColor         : LongWord;     // color in RGB or Palettized
            );
            1: (
              dwFillDepth         : LongWord;     // depth value for z-buffer
            );
            2: (
              dwFillPixel         : LongWord;     // pixel value
            );
            3: (
              lpDDSPattern        : PDirectDrawSurface; // Surface to use as pattern
              ddckDestColorkey    : TDDColorKey; // DestColorkey override
              ddckSrcColorkey     : TDDColorKey; // SrcColorkey override
            )
        )
      )
    )
  )
  end;

(*
 * TDDSCaps
 *)
  PDDSCaps = ^TDDSCaps;
  TDDSCaps = packed record
    dwCaps : LongWord;         // capabilities of surface wanted
  end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -