📄 mmddraw.pas
字号:
{========================================================================}
{= (c) 1995-98 SwiftSoft Ronald Dittrich =}
{========================================================================}
{= All Rights Reserved =}
{========================================================================}
{= D 01099 Dresden = Tel.: +0351-8012255 =}
{= Loewenstr.7a = info@swiftsoft.de =}
{========================================================================}
{= Actual versions on http://www.swiftsoft.de/mmtools.html =}
{========================================================================}
{= This code is for reference purposes only and may not be copied or =}
{= distributed in any format electronic or otherwise except one copy =}
{= for backup purposes. =}
{= =}
{= No Delphi Component Kit or Component individually or in a collection=}
{= subclassed or otherwise from the code in this unit, or associated =}
{= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
{= without express permission from SwiftSoft. =}
{= =}
{= For more licence informations please refer to the associated =}
{= HelpFile. =}
{========================================================================}
{= $Date: 20.01.1998 - 18:00:00 $ =}
{========================================================================}
{= Aufgabe: DirectDraw Unit =}
{========================================================================}
{= This code is for reference purposes only and may not be copied or =}
{= distributed in any format electronic or otherwise except one copy =}
{= for backup purposes. =}
{= =}
{= No Delphi Component Kit or Component individually or in a collection=}
{= subclassed or otherwise from the code in this unit, or associated =}
{= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
{= without express permission from SwiftSoft. =}
{= =}
{= For more licence informations please refer to the associated =}
{= HelpFile. =}
{========================================================================}
unit MMDDraw;
{$I COMPILER.INC}
interface
uses
Windows,
MMOle2;
type
PVOID = Pointer;
LONG = LongInt;
PLONG = ^LONG;
PUnknown = ^IUnknown;
PHWND = ^HWND;
PHDC = ^HDC;
{== GUIDs used by DirectDraw objects =========================================}
const
CLSID_DirectDraw : TGUID =
(D1:$D7B70EE0;D2:$4340;D3:$11CF;D4:($B0,$63,$00,$20,$AF,$C2,$CD,$35));
CLSID_DirectDrawClipper : TGUID =
(D1:$593817A0;D2:$7DB3;D3:$11CF;D4:($A2,$DE,$00,$AA,$00,$B9,$33,$56));
IID_IDirectDraw : TGUID =
(D1:$6C14DB80;D2:$A733;D3:$11CE;D4:($A5,$21,$00,$20,$AF,$0B,$E5,$60));
IID_IDirectDraw2 : TGUID =
(D1:$B3A6F3E0;D2:$2B43;D3:$11CF;D4:($A2,$DE,$00,$AA,$00,$B9,$33,$56));
IID_IDirectDrawSurface : TGUID =
(D1:$6C14DB81;D2:$A733;D3:$11CE;D4:($A5,$21,$00,$20,$AF,$0B,$E5,$60));
IID_IDirectDrawSurface2 : TGUID =
(D1:$57805885;D2:$6EEC;D3:$11CF;D4:($94,$41,$A8,$23,$03,$C1,$0E,$27));
IID_IDirectDrawPalette : TGUID =
(D1:$6C14DB84;D2:$A733;D3:$11CE;D4:($A5,$21,$00,$20,$AF,$0B,$E5,$60));
IID_IDirectDrawClipper : TGUID =
(D1:$6C14DB85;D2:$A733;D3:$11CE;D4:($A5,$21,$00,$20,$AF,$0B,$E5,$60));
{== Various structures used to invoke DirectDraw =============================}
const
REGSTR_KEY_DDHW_DESCRIPTION = 'Description';
REGSTR_KEY_DDHW_DRIVERNAME = 'DriverName';
REGSTR_PATH_DDHW = 'Hardware\DirectDrawDrivers';
DDCREATE_HARDWAREONLY = $00000001;
DDCREATE_EMULATIONONLY = $00000002;
{== Interfaces follow ========================================================}
const
DD_ROP_SPACE = (256 div 32); // space required to store ROP array
type
PDirectDrawSurface = ^IDirectDrawSurface;
IDirectDrawSurface = class;
PDirectDrawClipper = ^IDirectDrawClipper;
IDirectDrawClipper = class;
PDirectDrawPalette = ^IDirectDrawPalette;
IDirectDrawPalette = class;
{-- TDDCOLORKEY --------------------------------------------------------------}
PDDCOLORKEY = ^TDDCOLORKEY;
TDDCOLORKEY = record
dwColorSpaceLowValue : DWORD; // low boundary of color space that is to
// be treated as Color Key, inclusive
dwColorSpaceHighValue : DWORD; // high boundary of color space that is
// to be treated as Color Key, inclusive
end;
{-- TDDBLTFX - used to pass override information to the surface callback Blt -}
TDWDDSurface = record
case Byte of
0: (dw: DWORD); // Constant to use as Z buffer
1: (lpDDS: PDIRECTDRAWSURFACE); // Surface to use as Z buffer
end;
TDDFillStyle = record
case Byte of
0: (dwFillColor: DWORD); // color in RGB or Palettized
1: (dwFillDepth: DWORD); // depth value for z-buffer
2: (lpDDSPattern: PDIRECTDRAWSURFACE); // Surface to use as pattern
end;
PDDBLTFX = ^TDDBLTFX;
TDDBLTFX = record
dwSize : DWORD; // size of structure
dwDDFX : DWORD; // FX operations
dwROP : DWORD; // Win32 raster operations
dwDDROP : DWORD; // Raster operations new for DirectDraw
dwRotationAngle : DWORD; // Rotation angle for blt
dwZBufferOpCode : DWORD; // ZBuffer compares
dwZBufferLow : DWORD; // Low limit of Z buffer
dwZBufferHigh : DWORD; // High limit of Z buffer
dwZBufferBaseDest : DWORD; // Destination base value
dwZDestConstBitDepth : DWORD; // Bit depth used to specify Z constant for destination
ZDest : TDWDDSurface;
dwZSrcConstBitDepth : DWORD; // Bit depth used to specify Z constant for source
ZSrc : TDWDDSurface;
dwAlphaEdgeBlendBitDepth : DWORD; // Bit depth used to specify constant for alpha edge blend
dwAlphaEdgeBlend : DWORD; // Alpha for edge blending
dwReserved : DWORD;
dwAlphaDestConstBitDepth : DWORD; // Bit depth used to specify alpha constant for destination
AlphaDest : TDWDDSurface;
dwAlphaSrcConstBitDepth : DWORD; // Bit depth used to specify alpha constant for source
AlphaSrc : TDWDDSurface;
Fill : TDDFillStyle;
ddckDestColorkey : TDDCOLORKEY; // DestColorkey override
ddckSrcColorkey : TDDCOLORKEY; // SrcColorkey override
end;
{-- TDDSCAPS -----------------------------------------------------------------}
PDDSCAPS = ^TDDSCAPS;
TDDSCAPS = record
dwCaps : DWORD; // capabilities of surface wanted
end;
{-- TDDCAPS ------------------------------------------------------------------}
PDDCAPS = ^TDDCAPS;
TDDCAPS = record
dwSize : DWORD; // size of the DDDRIVERCAPS structure
dwCaps : DWORD; // driver specific capabilities
dwCaps2 : DWORD; // more driver specific capabilites
dwCKeyCaps : DWORD; // color key capabilities of the surface
dwFXCaps : DWORD; // driver specific stretching and effects capabilites
dwFXAlphaCaps : DWORD; // alpha driver specific capabilities
dwPalCaps : DWORD; // palette capabilities
dwSVCaps : DWORD; // stereo vision capabilities
dwAlphaBltConstBitDepths : DWORD; // DDBD_2,4,8
dwAlphaBltPixelBitDepths : DWORD; // DDBD_1,2,4,8
dwAlphaBltSurfaceBitDepths : DWORD; // DDBD_1,2,4,8
dwAlphaOverlayConstBitDepths : DWORD; // DDBD_2,4,8
dwAlphaOverlayPixelBitDepths : DWORD; // DDBD_1,2,4,8
dwAlphaOverlaySurfaceBitDepths : DWORD; // DDBD_1,2,4,8
dwZBufferBitDepths : DWORD; // DDBD_8,16,24,32
dwVidMemTotal : DWORD; // total amount of video memory
dwVidMemFree : DWORD; // amount of free video memory
dwMaxVisibleOverlays : DWORD; // maximum number of visible overlays
dwCurrVisibleOverlays : DWORD; // current number of visible overlays
dwNumFourCCCodes : DWORD; // number of four cc codes
dwAlignBoundarySrc : DWORD; // source rectangle alignment
dwAlignSizeSrc : DWORD; // source rectangle byte size
dwAlignBoundaryDest : DWORD; // dest rectangle alignment
dwAlignSizeDest : DWORD; // dest rectangle byte size
dwAlignStrideAlign : DWORD; // stride alignment
dwRops : array[0..DD_ROP_SPACE-1] of DWORD;
// ROPS supported
ddsCaps : TDDSCAPS; // DDSCAPS structure has all the general capabilities
dwMinOverlayStretch : DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxOverlayStretch : DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMinLiveVideoStretch : DWORD; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxLiveVideoStretch : DWORD; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMinHwCodecStretch : DWORD; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwMaxHwCodecStretch : DWORD; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3
dwReserved1 : DWORD; // reserved
dwReserved2 : DWORD; // reserved
dwReserved3 : DWORD; // reserved
dwSVBCaps : DWORD; // driver specific capabilities for System->Vmem blts
dwSVBCKeyCaps : DWORD; // driver color key capabilities for System->Vmem blts
dwSVBFXCaps : DWORD; // driver FX capabilities for System->Vmem blts
dwSVBRops : array[0..DD_ROP_SPACE-1] of DWORD;
// ROPS supported for System->Vmem blts
dwVSBCaps : DWORD; // driver specific capabilities for Vmem->System blts
dwVSBCKeyCaps : DWORD; // driver color key capabilities for Vmem->System blts
dwVSBFXCaps : DWORD; // driver FX capabilities for Vmem->System blts
dwVSBRops : array[0..DD_ROP_SPACE-1] of DWORD;
// ROPS supported for Vmem->System blts
dwSSBCaps : DWORD; // driver specific capabilities for System->System blts
dwSSBCKeyCaps : DWORD; // driver color key capabilities for System->System blts
dwSSBFXCaps : DWORD; // driver FX capabilities for System->System blts
dwSSBRops : array[0..DD_ROP_SPACE-1] of DWORD;
// ROPS supported for System->System blts
dwReserved4 : DWORD; // reserved
dwReserved5 : DWORD; // reserved
dwReserved6 : DWORD; // reserved
end;
{-- TDDPIXELFORMAT -----------------------------------------------------------}
PDDPIXELFORMAT = ^TDDPIXELFORMAT;
TDDPIXELFORMAT = record
dwSize : DWORD; // size of structure
dwFlags : DWORD; // pixel format flags
dwFourCC : DWORD; // (FOURCC code)
case Byte of
0:(dwRGBBitCount: DWORD; dwRBitMask: DWORD; dwGBitMask: DWORD; dwBBitMask: DWORD; dwRGBAlphaBitMask: DWORD);
1:(dwYUVBitCount: DWORD; dwYBitMask: DWORD; dwUBitMask: DWORD; dwVBitMask: DWORD; dwYUVAlphaBitMask: DWORD);
// how many bits for z buffers
2:(dwZBufferBitDepth: DWORD);
// how many bits for alpha channels
3:(dwAlphaBitDepth: DWORD);
end;
{-- TDDOVERLAYFX -------------------------------------------------------------}
PDDOVERLAYFX = ^TDDOVERLAYFX;
TDDOVERLAYFX = record
dwSize : DWORD; // size of structure
dwAlphaEdgeBlendBitDepth : DWORD; // Bit depth used to specify constant for alpha edge blend
dwAlphaEdgeBlend : DWORD; // Constant to use as alpha for edge blend
dwReserved : DWORD;
dwAlphaDestConstBitDepth : DWORD; // Bit depth used to specify alpha constant for destination
AlphaDest : TDWDDSurface;
dwAlphaSrcConstBitDepth : DWORD; // Bit depth used to specify alpha constant for source
AlphaSrc : TDWDDSurface;
dckDestColorkey : TDDCOLORKEY; // DestColorkey override
dckSrcColorkey : TDDCOLORKEY;
dwDDFX : DWORD; // Overlay FX
dwFlags : DWORD; // flags
end;
{-- TDDBLTBATCH --------------------------------------------------------------}
PDDBLTBATCH = ^TDDBLTBATCH;
TDDBLTBATCH = record
lprDest : PRECT;
lpDDSSrc : PDIRECTDRAWSURFACE;
lprSrc : PRECT;
dwFlags : DWORD;
lpDDBltFx : PDDBLTFX;
end;
{-- Callbacks ----------------------------------------------------------------}
PCLIPPERCALLBACK = function(lpDDClipper: PDIRECTDRAWCLIPPER; hWnd: HWND; code: DWORD; lpContext: PVOID): DWORD; pascal;
// #ifdef STREAMING
// typedef DWORD (FAR PASCAL *LPSURFACESTREAMINGCALLBACK)(DWORD);
// #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -