📄 directdraw.pas
字号:
{******************************************************************************}
{* *}
{* Copyright (C) Microsoft Corporation. All Rights Reserved. *}
{* *}
{* Files: ddraw.h dvp.h *}
{* Content: DirectDraw and DirectDrawVideoPort include files *}
{* *}
{* DirectX 9.0 Delphi adaptation by Alexey Barkovoy *}
{* E-Mail: clootie@reactor.ru *}
{* *}
{* Modified: 20-Dec-2002 *}
{* *}
{* 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.narod.ru/delphi/ *}
{* *}
{******************************************************************************}
{ }
{ 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:
// DIRECTDRAW_VERSION_7 : DIRECTDRAW_VERSION = 0x0700,
// DIRECTDRAW_VERSION_6 : DIRECTDRAW_VERSION = 0x0600,
// DIRECTDRAW_VERSION_5 : DIRECTDRAW_VERSION = 0x0500,
// DIRECTDRAW_VERSION_3 : DIRECTDRAW_VERSION = 0x0300,
// DIRECTDRAW_VERSION_LESS_3 : DIRECTDRAW_VERSION < 0x0300,
//
// By default DIRECTDRAW_VERSION_7 (DIRECTDRAW_VERSION = 0x0700) is assumed
//
// Also you can use generic DIRECTXx defines, so:
// DIRECTX7 equal to DIRECTDRAW_VERSION_7;
// DIRECTX6 equal to DIRECTDRAW_VERSION_6;
// DIRECTX5 equal to DIRECTDRAW_VERSION_5;
// DIRECTX3 equal to DIRECTDRAW_VERSION_3
///////////////////////////////////////////////////////////////////////////////
unit DirectDraw;
interface
{$I DirectX.inc}
////////////////////////////////////////////////////////////////////////
// Global level dynamic loading support
{$IFDEF DYNAMIC_LINK_ALL}
{$DEFINE DIRECTDRAW_DYNAMIC_LINK}
{$ENDIF}
{$IFDEF DYNAMIC_LINK_EXPLICIT_ALL}
{$DEFINE DIRECTDRAW_DYNAMIC_LINK_EXPLICIT}
{$ENDIF}
// Remove "dots" below to force some kind of dynamic linking
{.$DEFINE DIRECTDRAW_DYNAMIC_LINK}
{.$DEFINE DIRECTDRAW_DYNAMIC_LINK_EXPLICIT}
////////////////////////////////////////////////////////////////////////
// Assume for what DirectDraw version we will compile headers
{$IFDEF DIRECTX7}
{$DEFINE DIRECTDRAW_VERSION_7}
{$ENDIF}
{$IFDEF DIRECTX6}
{$DEFINE DIRECTDRAW_VERSION_6}
{$ENDIF}
{$IFDEF DIRECTX5}
{$DEFINE DIRECTDRAW_VERSION_5}
{$ENDIF}
{$IFDEF DIRECTX3}
{$DEFINE DIRECTDRAW_VERSION_3}
{$ENDIF}
{$IFNDEF DIRECTDRAW_VERSION_7}
{$IFNDEF DIRECTDRAW_VERSION_6}
{$IFNDEF DIRECTDRAW_VERSION_5}
{$IFNDEF DIRECTDRAW_VERSION_3}
{$IFNDEF DIRECTDRAW_VERSION_LESS_3}
{$DEFINE DIRECTDRAW_VERSION_7} // Compiling for DirectDraw7 by default
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
{$ENDIF}
////////////////////////////////////////////////////////////////////////
// Emit conditionals to C++Builder compiler
{$IFDEF DIRECTDRAW_VERSION_LESS_3}
{$HPPEMIT '#define DIRECTDRAW_VERSION 0x0100'}
{$ENDIF}
{$IFDEF DIRECTDRAW_VERSION_3}
{$HPPEMIT '#define DIRECTDRAW_VERSION 0x0300'}
{$ENDIF}
{$IFDEF DIRECTDRAW_VERSION_5}
{$HPPEMIT '#define DIRECTDRAW_VERSION 0x0500'}
{$ENDIF}
{$IFDEF DIRECTDRAW_VERSION_6}
{$HPPEMIT '#define DIRECTDRAW_VERSION 0x0600'}
{$ENDIF}
{$IFDEF DIRECTDRAW_VERSION_7}
{$HPPEMIT '#define DIRECTDRAW_VERSION 0x0700'}
{$ENDIF}
////////////////////////////////////////////////////////////////////////
// Define symbols for '<=' comparision
{$IFDEF DIRECTDRAW_VERSION_7}
{$DEFINE DIRECTDRAW_VERSION_6}
{$ENDIF}
{$IFDEF DIRECTDRAW_VERSION_6}
{$DEFINE DIRECTDRAW_VERSION_5}
{$ENDIF}
{$IFDEF DIRECTDRAW_VERSION_5}
{$DEFINE DIRECTDRAW_VERSION_3}
{$ENDIF}
{$IFDEF DIRECTDRAW_VERSION_3}
{$DEFINE DIRECTDRAW_VERSION_LESS_3}
{$ENDIF}
(*$HPPEMIT '#include "ddraw.h"' *)
(*$HPPEMIT '#include "dvp.h"' *)
uses
Windows;
(*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: ddraw.h
* Content: DirectDraw include file
*
***************************************************************************)
function MAKEFOURCC(ch0, ch1, ch2, ch3: Char): DWORD;
{$EXTERNALSYM MAKEFOURCC}
(*
* FOURCC codes for DX compressed-texture pixel formats
*)
const
//#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1'))
FOURCC_DXT1 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('1') shl 24));
{$EXTERNALSYM FOURCC_DXT1}
//#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2'))
FOURCC_DXT2 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('2') shl 24));
{$EXTERNALSYM FOURCC_DXT2}
//#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3'))
FOURCC_DXT3 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('3') shl 24));
{$EXTERNALSYM FOURCC_DXT3}
//#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4'))
FOURCC_DXT4 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('4') shl 24));
{$EXTERNALSYM FOURCC_DXT4}
//#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5'))
FOURCC_DXT5 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('5') shl 24));
{$EXTERNALSYM FOURCC_DXT5}
(*
* GUIDS used by DirectDraw objects
*)
const
CLSID_DirectDraw: TGUID = '{D7B70EE0-4340-11CF-B063-0020AFC2CD35}';
{$EXTERNALSYM CLSID_DirectDraw}
CLSID_DirectDraw7: TGUID = '{3c305196-50db-11d3-9cfe-00c04fd930c5}';
{$EXTERNALSYM CLSID_DirectDraw7}
CLSID_DirectDrawClipper: TGUID = '{593817A0-7DB3-11CF-A2DE-00AA00b93356}';
{$EXTERNALSYM CLSID_DirectDrawClipper}
(* These GUID's defined later by typedefing to Delphi interfaces
DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 );
DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b );
DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 );
DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB );
DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B );
DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b );
DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
DEFINE_GUID( IID_IDirectDrawColorControl, 0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 );
DEFINE_GUID( IID_IDirectDrawGammaControl, 0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E );
*)
const
DD_ROP_SPACE = (256 div 32); // space required to store ROP array
{$EXTERNALSYM DD_ROP_SPACE}
MAX_DDDEVICEID_STRING = 512;
{$EXTERNALSYM MAX_DDDEVICEID_STRING}
(*============================================================================
*
* DirectDraw Structures
*
* Various structures used to invoke DirectDraw.
*
*==========================================================================*)
var
NilGUID : TGUID = '{00000000-0000-0000-0000-000000000000}';
type
//Clootie: This was originally in Erik Unger headers - don't know why, so leave it alone
TRefGUID = packed record
case Integer of
1: (guid : PGUID);
2: (dwFlags : DWORD);
end;
REFGUID = PGUID;
{$EXTERNALSYM REFGUID}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDraw> _di_IDirectDraw;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDraw2> _di_IDirectDraw2;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDraw4> _di_IDirectDraw4;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDraw7> _di_IDirectDraw7;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawSurface> _di_IDirectDrawSurface;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawSurface2> _di_IDirectDrawSurface2;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawSurface3> _di_IDirectDrawSurface3;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawSurface4> _di_IDirectDrawSurface4;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawSurface7> _di_IDirectDrawSurface7;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawPalette> _di_IDirectDrawPalette;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawClipper> _di_IDirectDrawClipper;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawColorControl> _di_IDirectDrawColorControl;'}
{$HPPEMIT 'typedef System::DelphiInterface<IDirectDrawGammaControl> _di_IDirectDrawGammaControl;'}
IDirectDraw = interface;
{$EXTERNALSYM IDirectDraw}
IDirectDraw2 = interface;
{$EXTERNALSYM IDirectDraw2}
IDirectDraw4 = interface;
{$EXTERNALSYM IDirectDraw4}
IDirectDraw7 = interface;
{$EXTERNALSYM IDirectDraw7}
IDirectDrawSurface = interface;
{$EXTERNALSYM IDirectDrawSurface}
IDirectDrawSurface2 = interface;
{$EXTERNALSYM IDirectDrawSurface2}
IDirectDrawSurface3 = interface;
{$EXTERNALSYM IDirectDrawSurface3}
IDirectDrawSurface4 = interface;
{$EXTERNALSYM IDirectDrawSurface4}
IDirectDrawSurface7 = interface;
{$EXTERNALSYM IDirectDrawSurface7}
IDirectDrawPalette = interface;
{$EXTERNALSYM IDirectDrawPalette}
IDirectDrawClipper = interface;
{$EXTERNALSYM IDirectDrawClipper}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -