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

📄 direct3d.pas

📁 3D GameStudio 的Delphi开发包
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{******************************************************************************}
{*                                                                            *}
{*  Copyright (C) Microsoft Corporation.  All Rights Reserved.                *}
{*                                                                            *}
{*  Files:      d3dtypes.h d3dcaps.h d3d.h                                    *}
{*  Content:    Direct3D8 include files                                       *}
{*                                                                            *}
{*  DirectX 9.0 Delphi / FreePascal adaptation by Alexey Barkovoy             *}
{*  E-Mail: directx@clootie.ru                                                *}
{*                                                                            *}
{*  Modified: 19-Jan-2004                                                     *}
{*                                                                            *}
{*  Partly based upon :                                                       *}
{*    DirectX 7.0 Object Pascal adaptation by                                 *}
{*      Erik Unger, e-Mail: DelphiDirectX@next-reality.com                    *}
{*                                                                            *}
{*  Latest version can be downloaded from:                                    *}
{*    http://clootie.ru                                                       *}
{*    http://sourceforge.net/projects/delphi-dx9sdk                           *}
{*                                                                            *}
{******************************************************************************}
{                                                                              }
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
{                                                                              }
{ The contents of this file are used with permission, subject to the Mozilla   }
{ Public License Version 1.1 (the "License"); you may not use this file except }
{ in compliance with the License. You may obtain a copy of the License at      }
{ http://www.mozilla.org/MPL/MPL-1.1.html                                      }
{                                                                              }
{ Software distributed under the License is distributed on an "AS IS" basis,   }
{ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
{ the specific language governing rights and limitations under the License.    }
{                                                                              }
{ Alternatively, the contents of this file may be used under the terms of the  }
{ GNU Lesser General Public License (the  "LGPL License"), in which case the   }
{ provisions of the LGPL License are applicable instead of those above.        }
{ If you wish to allow use of your version of this file only under the terms   }
{ of the LGPL License and not to allow others to use your version of this file }
{ under the MPL, indicate your decision by deleting  the provisions above and  }
{ replace  them with the notice and other provisions required by the LGPL      }
{ License.  If you do not delete the provisions above, a recipient may use     }
{ your version of this file under either the MPL or the LGPL License.          }
{                                                                              }
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
{                                                                              }
{******************************************************************************}

///////////////////////////////////////////////////////////////////////////////
// Notes:
//----------------------------------------------------------------------------
// Possible input defines for this file, mapped to original C values:
//   DIRECT3D_VERSION_8 : DIRECT3D_VERSION = 0x0800,
//   DIRECT3D_VERSION_7 : DIRECT3D_VERSION = 0x0700,
//   DIRECT3D_VERSION_6 : DIRECT3D_VERSION = 0x0600,
//   DIRECT3D_VERSION_5 : DIRECT3D_VERSION = 0x0500,
//   DIRECT3D_VERSION_LESS_5 : DIRECT3D_VERSION < 0x0500,
//
// By default DIRECT3D_VERSION_7 (DIRECT3D_VERSION = 0x0700) is assumed
///////////////////////////////////////////////////////////////////////////////

unit Direct3D;

{$I DirectX.inc}

// Remove "dots" below to exclude DXFile interfaces - these interfaces
// are included for compatibility with original Erik Unger translation
{$DEFINE EXCLUDE_DXFILE_FROM_DIRECT3D}

// Assume for what Direct3D version we will compile headers
{$IFNDEF DIRECT3D_VERSION_8}
  {$IFNDEF DIRECT3D_VERSION_7}
    {$IFNDEF DIRECT3D_VERSION_6}
      {$IFNDEF DIRECT3D_VERSION_5}
        {$IFNDEF DIRECT3D_VERSION_LESS_5}
          {$DEFINE DIRECT3D_VERSION_7} // Compiling for Direct3D7 by default
        {$ENDIF}
      {$ENDIF}
    {$ENDIF}
  {$ENDIF}
{$ENDIF}

// Emit conditionals to C++Builder compiler
{$IFDEF DIRECT3D_VERSION_8}
  {$HPPEMIT '#define DIRECT3D_VERSION         0x0800'}
{$ENDIF}
{$IFDEF DIRECT3D_VERSION_7}
  {$HPPEMIT '#define DIRECT3D_VERSION         0x0700'}
{$ENDIF}
{$IFDEF DIRECT3D_VERSION_6}
  {$HPPEMIT '#define DIRECT3D_VERSION         0x0600'}
{$ENDIF}
{$IFDEF DIRECT3D_VERSION_5}
  {$HPPEMIT '#define DIRECT3D_VERSION         0x0500'}
{$ENDIF}
{$IFDEF DIRECT3D_VERSION_LESS_5}
  {$HPPEMIT '#define DIRECT3D_VERSION         0x0300'}
{$ENDIF}

// Define symbols for '>=' comparision
{$IFDEF DIRECT3D_VERSION_8}
  {$DEFINE DIRECT3D_VERSION_7}
{$ENDIF}
{$IFDEF DIRECT3D_VERSION_7}
  {$DEFINE DIRECT3D_VERSION_6}
{$ENDIF}
{$IFDEF DIRECT3D_VERSION_6}
  {$DEFINE DIRECT3D_VERSION_5}
{$ENDIF}

// Define symbols for '<' comparision
{$IFNDEF DIRECT3D_VERSION_8}
  {$DEFINE DIRECT3D_VERSION_LESS_8}
{$ENDIF}
{$IFNDEF DIRECT3D_VERSION_7}
  {$DEFINE DIRECT3D_VERSION_LESS_7}
{$ENDIF}
{$IFNDEF DIRECT3D_VERSION_6}
  {$DEFINE DIRECT3D_VERSION_LESS_6}
{$ENDIF}
{$IFNDEF DIRECT3D_VERSION_5}
  {$DEFINE DIRECT3D_VERSION_LESS_5}
{$ENDIF}

interface

uses
  Windows, DXTypes, DirectDraw{$IFDEF DIRECT3D_VERSION_8}, Direct3D8{$ENDIF};

{$NOINCLUDE Windows}
{$NOINCLUDE DirectDraw}
{$IFDEF DIRECT3D_VERSION_8}
  {$NOINCLUDE Direct3D8}
{$ENDIF}

{$HPPEMIT '#include "d3d.h"'}
{$HPPEMIT '#include "d3dtypes.h"'}
{$HPPEMIT '#include "d3dcaps.h"'}

(* TD3DValue is the fundamental Direct3D fractional data type *)

type
  TRefClsID = TGUID;

type
  D3DVALUE = DXTypes.D3DVALUE;
  {$EXTERNALSYM D3DVALUE}
  TD3DValue = DXTypes.TD3DValue;
  PD3DValue = DXTypes.PD3DValue;

  D3DFIXED = Longint;
  {$EXTERNALSYM D3DFIXED}
  TD3DFixed = D3DFIXED;

  float = TD3DValue;
  {$EXTERNALSYM float}

  D3DCOLOR = DXTypes.D3DCOLOR;
  {$EXTERNALSYM D3DCOLOR}
  TD3DColor = DXTypes.TD3DColor;
  PD3DColor = DXTypes.PD3DColor;

function D3DVal(val: Variant): Single;
{$EXTERNALSYM D3DVal}
function D3DDivide(a, b: Double): Single;
{$EXTERNALSYM D3DDivide}
function D3DMultiply(a, b: Double): Single;
{$EXTERNALSYM D3DMultiply}

(*
 * Format of CI colors is
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *  |    alpha      |         color index           |   fraction    |
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *)

// #define CI_GETALPHA(ci)    ((ci) >> 24)
function CI_GETALPHA(ci: DWORD): DWORD;
{$EXTERNALSYM CI_GETALPHA}

// #define CI_GETINDEX(ci)    (((ci) >> 8) & 0xffff)
function CI_GETINDEX(ci: DWORD): DWORD;
{$EXTERNALSYM CI_GETINDEX}

// #define CI_GETFRACTION(ci) ((ci) & 0xff)
function CI_GETFRACTION(ci: DWORD): DWORD;
{$EXTERNALSYM CI_GETFRACTION}

// #define CI_ROUNDINDEX(ci)  CI_GETINDEX((ci) + 0x80)
function CI_ROUNDINDEX(ci: DWORD): DWORD;
{$EXTERNALSYM CI_ROUNDINDEX}

// #define CI_MASKALPHA(ci)   ((ci) & 0xffffff)
function CI_MASKALPHA(ci: DWORD): DWORD;
{$EXTERNALSYM CI_MASKALPHA}

// #define CI_MAKE(a, i, f)    (((a) << 24) | ((i) << 8) | (f))
function CI_MAKE(a,i,f: DWORD): DWORD;
{$EXTERNALSYM CI_MAKE}

(*
 * Format of RGBA colors is
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *  |    alpha      |      red      |     green     |     blue      |
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *)

// #define RGBA_GETALPHA(rgb)      ((rgb) >> 24)
function RGBA_GETALPHA(rgb: TD3DColor): DWORD;
{$EXTERNALSYM RGBA_GETALPHA}

// #define RGBA_GETRED(rgb)        (((rgb) >> 16) & 0xff)
function RGBA_GETRED(rgb: TD3DColor): DWORD;
{$EXTERNALSYM RGBA_GETRED}

// #define RGBA_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
function RGBA_GETGREEN(rgb: TD3DColor): DWORD;
{$EXTERNALSYM RGBA_GETGREEN}

// #define RGBA_GETBLUE(rgb)       ((rgb) & 0xff)
function RGBA_GETBLUE(rgb: TD3DColor): DWORD;
{$EXTERNALSYM RGBA_GETBLUE}

// #define RGBA_MAKE(r, g, b, a)   ((TD3DColor) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
function RGBA_MAKE(r, g, b, a: DWORD): TD3DColor;
{$EXTERNALSYM RGBA_MAKE}

(* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
 * The float values must be in the range 0..1
 *)

// #define D3DRGB(r, g, b) \
//     (0xff000000L | (((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
function D3DRGB(r, g, b: Single): TD3DColor;
{$EXTERNALSYM D3DRGB}

// #define D3DRGBA(r, g, b, a) \
//     (  (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
//     |   (((long)((g) * 255)) << 8) | (long)((b) * 255) \
//    )
function D3DRGBA(r, g, b, a: Single): TD3DColor;
{$EXTERNALSYM D3DRGBA}

(*
 * Format of RGB colors is
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *  |    ignored    |      red      |     green     |     blue      |
 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *)

// #define RGB_GETRED(rgb)         (((rgb) >> 16) & 0xff)
function RGB_GETRED(rgb: TD3DColor): DWORD;
{$EXTERNALSYM RGB_GETRED}

// #define RGB_GETGREEN(rgb)       (((rgb) >> 8) & 0xff)
function RGB_GETGREEN(rgb: TD3DColor): DWORD;
{$EXTERNALSYM RGB_GETGREEN}

// #define RGB_GETBLUE(rgb)        ((rgb) & 0xff)
function RGB_GETBLUE(rgb: TD3DColor): DWORD;
{$EXTERNALSYM RGB_GETBLUE}

// #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
function RGBA_SETALPHA(rgba: TD3DColor; x: DWORD): TD3DColor;
{$EXTERNALSYM RGBA_SETALPHA}

// #define RGB_MAKE(r, g, b)       ((TD3DColor) (((r) << 16) | ((g) << 8) | (b)))
function RGB_MAKE(r, g, b: DWORD): TD3DColor;
{$EXTERNALSYM RGB_MAKE}

// #define RGBA_TORGB(rgba)       ((TD3DColor) ((rgba) & 0xffffff))
function RGBA_TORGB(rgba: TD3DColor): TD3DColor;
{$EXTERNALSYM RGBA_TORGB}

// #define RGB_TORGBA(rgb)        ((TD3DColor) ((rgb) | 0xff000000))
function RGB_TORGBA(rgb: TD3DColor): TD3DColor;
{$EXTERNALSYM RGB_TORGBA}

(*
 * Flags for Enumerate functions
 *)
const

(*
 * Stop the enumeration
 *)

  D3DENUMRET_CANCEL                        = DDENUMRET_CANCEL;
  {$EXTERNALSYM D3DENUMRET_CANCEL}

(*
 * Continue the enumeration
 *)

  D3DENUMRET_OK                            = DDENUMRET_OK;
  {$EXTERNALSYM D3DENUMRET_OK}

type
  TD3DValidateCallback = function (lpUserArg: Pointer;
      dwOffset: DWORD): HResult; stdcall;
  {$NODEFINE TD3DValidateCallback}
  {$HPPEMIT 'typedef LPD3DVALIDATECALLBACK TD3DValidateCallback;'}

  TD3DEnumTextureFormatsCallback = function (var lpDdsd: TDDSurfaceDesc;
      lpContext: Pointer): HResult; stdcall;
  {$NODEFINE TD3DEnumTextureFormatsCallback}
  {$HPPEMIT 'typedef LPD3DENUMTEXTUREFORMATSCALLBACK TD3DEnumTextureFormatsCallback;'}

  TD3DEnumPixelFormatsCallback = function (var lpDDPixFmt: TDDPixelFormat;
      lpContext: Pointer): HResult; stdcall;
  {$NODEFINE TD3DEnumPixelFormatsCallback}
  {$HPPEMIT 'typedef LPD3DENUMPIXELFORMATSCALLBACK TD3DEnumPixelFormatsCallback;'}

  PD3DMaterialHandle = ^TD3DMaterialHandle;
  TD3DMaterialHandle = DWORD;

  PD3DTextureHandle = ^TD3DTextureHandle;
  TD3DTextureHandle = DWORD;

  PD3DMatrixHandle = ^TD3DMatrixHandle;
  TD3DMatrixHandle = DWORD;


  PD3DColorValue = ^TD3DColorValue;
  _D3DCOLORVALUE = packed record
    case Integer of
    0: (
      r: TD3DValue;
      g: TD3DValue;
      b: TD3DValue;
      a: TD3DValue;
     );
    1: (
      dvR: TD3DValue;
      dvG: TD3DValue;
      dvB: TD3DValue;
      dvA: TD3DValue;
     );
  end {_D3DCOLORVALUE};
  {$EXTERNALSYM _D3DCOLORVALUE}
  D3DCOLORVALUE = _D3DCOLORVALUE;
  {$EXTERNALSYM D3DCOLORVALUE}
  TD3DColorValue = _D3DCOLORVALUE;


  PD3DRect = ^TD3DRect;
  _D3DRECT = packed record
    case Integer of
    0: (
      x1: LongInt;
      y1: LongInt;
      x2: LongInt;
      y2: LongInt;
     );
    1: (
      lX1: LongInt;
      lY1: LongInt;
      lX2: LongInt;
      lY2: LongInt;
     );
     2: (
       a: array[0..3] of LongInt;
     );
  end {_D3DRECT};
  {$EXTERNALSYM _D3DRECT}
  D3DRECT = _D3DRECT;
  {$EXTERNALSYM D3DRECT}
  TD3DRect = _D3DRECT;


  PD3DVector = ^TD3DVector;
  _D3DVECTOR = packed record
    case Integer of

⌨️ 快捷键说明

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