📄 dxdraws.pas
字号:
function GetCanDraw: Boolean;
function GetCanPaletteAnimation: Boolean;
function GetSurfaceHeight: Integer;
function GetSurfaceWidth: Integer;
procedure NotifyEventList(NotifyType: TDXDrawNotifyType);
procedure SetAutoSize(Value: Boolean);
procedure SetColorTable(const ColorTable: TRGBQuads);
procedure SetCooperativeLevel;
procedure SetDisplay(Value: TDXDrawDisplay);
procedure SetDriver(Value: PGUID);
procedure SetOptions(Value: TDXDrawOptions);
procedure SetSurfaceHeight(Value: Integer);
procedure SetSurfaceWidth(Value: Integer);
function TryRestore: Boolean;
procedure WMCreate(var Message: TMessage); message WM_CREATE;
protected
procedure DoFinalize; virtual;
procedure DoFinalizeSurface; virtual;
procedure DoInitialize; virtual;
procedure DoInitializeSurface; virtual;
procedure DoInitializing; virtual;
procedure DoRestoreSurface; virtual;
procedure Loaded; override;
procedure Paint; override;
function PaletteChanged(Foreground: Boolean): Boolean; override;
procedure SetParent(AParent: TWinControl); override;
public
ColorTable: TRGBQuads;
DefColorTable: TRGBQuads;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
class function Drivers: TDirectXDrivers;
procedure Finalize;
procedure Flip;
procedure Initialize;
procedure Render;
procedure Restore;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
procedure SetSize(ASurfaceWidth, ASurfaceHeight: Integer);
procedure UpdatePalette;
procedure RegisterNotifyEvent(NotifyEvent: TDXDrawNotifyEvent);
procedure UnRegisterNotifyEvent(NotifyEvent: TDXDrawNotifyEvent);
property AutoInitialize: Boolean read FAutoInitialize write FAutoInitialize;
property AutoSize: Boolean read FAutoSize write SetAutoSize;
property Camera: IDirect3DRMFrame read FCamera;
property CanDraw: Boolean read GetCanDraw;
property CanPaletteAnimation: Boolean read GetCanPaletteAnimation;
property Clipper: TDirectDrawClipper read FClipper;
property Color;
property D3D: IDirect3D read FD3D;
property D3D2: IDirect3D2 read FD3D2;
property D3D3: IDirect3D3 read FD3D3;
property D3D7: IDirect3D7 read FD3D7;
property D3DDevice: IDirect3DDevice read FD3DDevice;
property D3DDevice2: IDirect3DDevice2 read FD3DDevice2;
property D3DDevice3: IDirect3DDevice3 read FD3DDevice3;
property D3DDevice7: IDirect3DDevice7 read FD3DDevice7;
property D3DRM: IDirect3DRM read FD3DRM;
property D3DRM2: IDirect3DRM2 read FD3DRM2;
property D3DRM3: IDirect3DRM3 read FD3DRM3;
property D3DRMDevice: IDirect3DRMDevice read FD3DRMDevice;
property D3DRMDevice2: IDirect3DRMDevice2 read FD3DRMDevice2;
property D3DRMDevice3: IDirect3DRMDevice3 read FD3DRMDevice3;
property DDraw: TDirectDraw read FDDraw;
property Display: TDXDrawDisplay read FDisplay write SetDisplay;
property Driver: PGUID read FDriver write SetDriver;
property Initialized: Boolean read FInitialized;
property NowOptions: TDXDrawOptions read FNowOptions;
property OnFinalize: TNotifyEvent read FOnFinalize write FOnFinalize;
property OnFinalizeSurface: TNotifyEvent read FOnFinalizeSurface write FOnFinalizeSurface;
property OnInitialize: TNotifyEvent read FOnInitialize write FOnInitialize;
property OnInitializeSurface: TNotifyEvent read FOnInitializeSurface write FOnInitializeSurface;
property OnInitializing: TNotifyEvent read FOnInitializing write FOnInitializing;
property OnRestoreSurface: TNotifyEvent read FOnRestoreSurface write FOnRestoreSurface;
property Options: TDXDrawOptions read FOptions write SetOptions;
property Palette: TDirectDrawPalette read FPalette;
property Primary: TDirectDrawSurface read FPrimary;
property Scene: IDirect3DRMFrame read FScene;
property Surface: TDirectDrawSurface read FSurface;
property SurfaceHeight: Integer read GetSurfaceHeight write SetSurfaceHeight default 480;
property SurfaceWidth: Integer read GetSurfaceWidth write SetSurfaceWidth default 640;
property Viewport: IDirect3DRMViewport read FViewport;
property ZBuffer: TDirectDrawSurface read FZBuffer;
end;
{ TDXDraw }
TDXDraw = class(TCustomDXDraw)
published
property AutoInitialize;
property AutoSize;
property Color;
property Display;
property Options;
property SurfaceHeight;
property SurfaceWidth;
property OnFinalize;
property OnFinalizeSurface;
property OnInitialize;
property OnInitializeSurface;
property OnInitializing;
property OnRestoreSurface;
property Align;
{$IFDEF DelphiX_Spt4}property Anchors;{$ENDIF}
{$IFDEF DelphiX_Spt4}property Constraints;{$ENDIF}
property DragCursor;
property DragMode;
property Enabled;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
{$IFDEF DelphiX_Spt4}property OnResize;{$ENDIF}
property OnStartDrag;
end;
{ EDX3DError }
EDX3DError = class(Exception);
{ TCustomDX3D }
TDX3DOption = (toRetainedMode, toSystemMemory, toHardware, toSelectDriver, toZBuffer);
TDX3DOptions = set of TDX3DOption;
TCustomDX3D = class(TComponent)
private
FAutoSize: Boolean;
FCamera: IDirect3DRMFrame;
FD3D: IDirect3D;
FD3D2: IDirect3D2;
FD3D3: IDirect3D3;
FD3D7: IDirect3D7;
FD3DDevice: IDirect3DDevice;
FD3DDevice2: IDirect3DDevice2;
FD3DDevice3: IDirect3DDevice3;
FD3DDevice7: IDirect3DDevice7;
FD3DRM: IDirect3DRM;
FD3DRM2: IDirect3DRM2;
FD3DRM3: IDirect3DRM3;
FD3DRMDevice: IDirect3DRMDevice;
FD3DRMDevice2: IDirect3DRMDevice2;
FD3DRMDevice3: IDirect3DRMDevice3;
FDXDraw: TCustomDXDraw;
FInitFlag: Boolean;
FInitialized: Boolean;
FNowOptions: TDX3DOptions;
FOnFinalize: TNotifyEvent;
FOnInitialize: TNotifyEvent;
FOptions: TDX3DOptions;
FScene: IDirect3DRMFrame;
FSurface: TDirectDrawSurface;
FSurfaceHeight: Integer;
FSurfaceWidth: Integer;
FViewport: IDirect3DRMViewport;
FZBuffer: TDirectDrawSurface;
procedure Finalize;
procedure Initialize;
procedure DXDrawNotifyEvent(Sender: TCustomDXDraw; NotifyType: TDXDrawNotifyType);
function GetCanDraw: Boolean;
function GetSurfaceHeight: Integer;
function GetSurfaceWidth: Integer;
procedure SetAutoSize(Value: Boolean);
procedure SetDXDraw(Value: TCustomDXDraw);
procedure SetOptions(Value: TDX3DOptions);
procedure SetSurfaceHeight(Value: Integer);
procedure SetSurfaceWidth(Value: Integer);
protected
procedure DoFinalize; virtual;
procedure DoInitialize; virtual;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Render;
procedure SetSize(ASurfaceWidth, ASurfaceHeight: Integer);
property AutoSize: Boolean read FAutoSize write SetAutoSize;
property Camera: IDirect3DRMFrame read FCamera;
property CanDraw: Boolean read GetCanDraw;
property D3D: IDirect3D read FD3D;
property D3D2: IDirect3D2 read FD3D2;
property D3D3: IDirect3D3 read FD3D3;
property D3D7: IDirect3D7 read FD3D7;
property D3DDevice: IDirect3DDevice read FD3DDevice;
property D3DDevice2: IDirect3DDevice2 read FD3DDevice2;
property D3DDevice3: IDirect3DDevice3 read FD3DDevice3;
property D3DDevice7: IDirect3DDevice7 read FD3DDevice7;
property D3DRM: IDirect3DRM read FD3DRM;
property D3DRM2: IDirect3DRM2 read FD3DRM2;
property D3DRM3: IDirect3DRM3 read FD3DRM3;
property D3DRMDevice: IDirect3DRMDevice read FD3DRMDevice;
property D3DRMDevice2: IDirect3DRMDevice2 read FD3DRMDevice2;
property D3DRMDevice3: IDirect3DRMDevice3 read FD3DRMDevice3;
property DXDraw: TCustomDXDraw read FDXDraw write SetDXDraw;
property Initialized: Boolean read FInitialized;
property NowOptions: TDX3DOptions read FNowOptions;
property OnFinalize: TNotifyEvent read FOnFinalize write FOnFinalize;
property OnInitialize: TNotifyEvent read FOnInitialize write FOnInitialize;
property Options: TDX3DOptions read FOptions write SetOptions;
property Scene: IDirect3DRMFrame read FScene;
property Surface: TDirectDrawSurface read FSurface;
property SurfaceHeight: Integer read GetSurfaceHeight write SetSurfaceHeight default 480;
property SurfaceWidth: Integer read GetSurfaceWidth write SetSurfaceWidth default 640;
property Viewport: IDirect3DRMViewport read FViewport;
property ZBuffer: TDirectDrawSurface read FZBuffer;
end;
{ TDX3D }
TDX3D = class(TCustomDX3D)
published
property AutoSize;
property DXDraw;
property Options;
property SurfaceHeight;
property SurfaceWidth;
property OnFinalize;
property OnInitialize;
end;
{ EDirect3DTextureError }
EDirect3DTextureError = class(Exception);
{ TDirect3DTexture }
TDirect3DTexture = class
private
FBitCount: DWORD;
FDXDraw: TComponent;
FEnumFormatFlag: Boolean;
FFormat: TDDSurfaceDesc;
FGraphic: TGraphic;
FHandle: TD3DTextureHandle;
FPaletteEntries: TPaletteEntries;
FSurface: TDirectDrawSurface;
FTexture: IDirect3DTexture;
FTransparentColor: TColor;
procedure Clear;
procedure DXDrawNotifyEvent(Sender: TCustomDXDraw; NotifyType: TDXDrawNotifyType);
function GetHandle: TD3DTextureHandle;
function GetSurface: TDirectDrawSurface;
function GetTexture: IDirect3DTexture;
procedure SetTransparentColor(Value: TColor);
public
constructor Create(Graphic: TGraphic; DXDraw: TComponent);
destructor Destroy; override;
procedure Restore;
property Handle: TD3DTextureHandle read GetHandle;
property Surface: TDirectDrawSurface read GetSurface;
property TransparentColor: TColor read FTransparentColor write SetTransparentColor;
property Texture: IDirect3DTexture read GetTexture;
end;
{ TDirect3DTexture2 }
TDirect3DTexture2 = class
private
FDXDraw: TCustomDXDraw;
FSrcImage: TObject;
FImage: TDXTextureImage;
FImage2: TDXTextureImage;
FAutoFreeGraphic: Boolean;
FSurface: TDirectDrawSurface;
FTextureFormat: TDDSurfaceDesc2;
FMipmap: Boolean;
FTransparent: Boolean;
FTransparentColor: TColorRef;
FUseMipmap: Boolean;
FUseColorKey: Boolean;
FOnRestoreSurface: TNotifyEvent;
FNeedLoadTexture: Boolean;
FEnumTextureFormatFlag: Boolean;
FD3DDevDesc: TD3DDeviceDesc;
procedure DXDrawNotifyEvent(Sender: TCustomDXDraw; NotifyType: TDXDrawNotifyType);
procedure SetDXDraw(ADXDraw: TCustomDXDraw);
procedure LoadSubTexture(Dest: IDirectDrawSurface4; SrcImage: TDXTextureImage);
procedure SetColorKey;
procedure SetDIB(DIB: TDIB);
function GetIsMipmap: Boolean;
function GetSurface: TDirectDrawSurface;
function GetTransparent: Boolean;
procedure SetTransparent(Value: Boolean);
procedure SetTransparentColor(Value: TColorRef);
protected
procedure DoRestoreSurface; virtual;
public
constructor Create(ADXDraw: TCustomDXDraw; Graphic: TObject; AutoFreeGraphic: Boolean);
constructor CreateFromFile(ADXDraw: TCustomDXDraw; const FileName: string);
constructor CreateVideoTexture(ADXDraw: TCustomDXDraw);
destructor Destroy; override;
procedure Finalize;
procedure Load;
procedure Initialize;
property IsMipmap: Boolean read GetIsMipmap;
property Surface: TDirectDrawSurface read GetSurface;
property TextureFormat: TDDSurfaceDesc2 read FTextureFormat write FTextureFormat;
property Transparent: Boolean read GetTransparent write SetTransparent;
property TransparentColor: TColorRef read FTransparentColor write SetTransparentColor;
property OnRestoreSurface: TNotifyEvent read FOnRestoreSurface write FOnRestoreSurface;
end;
{ EDirect3DRMUserVisualError }
EDirect3DRMUserVisualError = class(Exception);
{ TDirect3DRMUserVisual }
TDirect3DRMUserVisual = class
private
FUserVisual: IDirect3DRMUserVisual;
protected
function DoRender(Reason: TD3DRMUserVisualReason;
D3DRMDev: IDirect3DRMDevice; D3DRMView: IDirect3DRMViewport): HRESULT; virtual;
public
constructor Create(D3DRM: IDirect3DRM);
destructor Destroy; override;
property UserVisual: IDirect3DRMUserVisual read FUserVisual;
end;
{ EPictureCollectionError }
EPictureCollectionError = class(Exception);
{ TPictureCollectionItem }
TPictureCollection = class;
TPictureCollectionItem = class(THashCollectionItem)
private
FPicture: TPicture;
FInitialized: Boolean;
FPatternHeight: Integer;
FPatternWidth: Integer;
FPatterns: TCollection;
FSkipHeight: Integer;
FSkipWidth: Integer;
FSurfaceList: TList;
FSystemMemory: Boolean;
FTransparent: Boolean;
FTransparentColor: TColor;
procedure ClearSurface;
procedure Finalize;
procedure Initialize;
function GetHeight: Integer;
function GetPictureCollection: TPictureCollection;
function GetPatternRect(Index: Integer): TRect;
function GetPatternSurface(Index: Integer): TDirectDrawSurface;
function GetPatternCount: Integer;
function GetWidth: Integer;
procedure SetPicture(Value: TPicture);
procedure SetTransparentColor(Value: TColor);
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure Draw(Dest: TDirectDrawSurface; X, Y: Integer; PatternIndex: Integer);
procedure StretchDraw(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer);
procedure DrawAdd(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawAlpha(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Alpha: Integer);
procedure DrawSub(Dest: TDirectDrawSurface; const DestRect: TRect; PatternIndex: Integer;
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawRotate(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: Integer);
procedure DrawRotateAdd(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: Integer;
Alpha: Integer{$IFDEF DelphiX_Spt4}=255{$ENDIF});
procedure DrawRotateAlpha(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: Integer;
Alpha: Integer);
procedure DrawRotateSub(Dest: TDirectDrawSurface; X, Y, Width, Height: Integer; PatternIndex: Integer;
CenterX, CenterY: Double; Angle: Integer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -