本文整理汇总了C++中LPDIRECTDRAWSURFACE4类的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE4类的具体用法?C++ LPDIRECTDRAWSURFACE4怎么用?C++ LPDIRECTDRAWSURFACE4使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPDIRECTDRAWSURFACE4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PisteDraw_Create_Surface
LPDIRECTDRAWSURFACE4 PisteDraw_Create_Surface(int width, int height, int mem_flags, UCHAR color)
{
LPDIRECTDRAWSURFACE4 lpdds;
DD_INIT_STRUCT(PD_ddsd);
PD_ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
PD_ddsd.dwWidth = width;
PD_ddsd.dwHeight = height;
PD_ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | mem_flags;
if (FAILED(PD_lpdd->CreateSurface(&PD_ddsd, &lpdds, NULL)))
return(NULL);
DDCOLORKEY color_key;
color_key.dwColorSpaceLowValue = color;
color_key.dwColorSpaceHighValue = color;
if(FAILED(lpdds->SetColorKey(DDCKEY_SRCBLT, &color_key)))
return(NULL);
return(lpdds);
}
示例2: Clear_Surface
/***************************************************************************\
Clears the specified surface.
\***************************************************************************/
void IMR_DirectXInterface::Clear_Surface(LPDIRECTDRAWSURFACE4 Surface)
{
HRESULT ddflag;
RECT Area;
DDSURFACEDESC2 DDSurfaceDesc;
char *Mem;
// Make sure the surface exists:
if (!Surface) return;
// Lock the surface:
DDSurfaceDesc.dwSize = sizeof(DDSurfaceDesc);
ddflag = Surface->Lock(&Area, &DDSurfaceDesc, DDLOCK_WAIT, NULL);
if (ddflag == DDERR_SURFACELOST)
{
Restore(Surface);
ddflag = Surface->Lock(NULL, &DDSurfaceDesc, DDLOCK_WAIT, NULL);
}
if (ddflag != DD_OK) return;
Mem = (char *)DDSurfaceDesc.lpSurface;
// Clear the surface:
if (Mem) memset(Mem, 0, DDSurfaceDesc.dwSize);
// And unlock the surface:
Surface->Unlock(NULL);
}
示例3: FillLMapSurface2
//=====================================================================================
// FillLMapSurface
//=====================================================================================
static void FillLMapSurface2(DRV_LInfo *LInfo, int32 LNum)
{
U16 *pTempBits;
int32 w, h, Width, Height, Stride;
U8 *pBitPtr;
RGB_LUT *Lut;
geRDriver_THandle *THandle;
HRESULT Result;
const RECT *pRect;
DDSURFACEDESC2 SurfDesc;
LPDIRECTDRAWSURFACE4 Surface;
int32 Extra;
THandle = LInfo->THandle;
pBitPtr = (U8*)LInfo->RGBLight[LNum];
Width = LInfo->Width;
Height = LInfo->Height;
Lut = &AppInfo.Lut1;
pRect = TPage_BlockGetRect(THandle->Block);
Surface = TPage_BlockGetSurface(THandle->Block);
memset(&SurfDesc, 0, sizeof(DDSURFACEDESC2));
SurfDesc.dwSize = sizeof(DDSURFACEDESC2);
Result = Surface->Lock((RECT*)pRect, &SurfDesc, DDLOCK_WAIT, NULL);
assert(Result == DD_OK);
Stride = SurfDesc.dwWidth;
pTempBits = (U16*)SurfDesc.lpSurface;
Extra = Stride - Width;
for (h=0; h< Height; h++)
{
for (w=0; w< Width; w++)
{
U8 R, G, B;
U16 Color;
R = *pBitPtr++;
G = *pBitPtr++;
B = *pBitPtr++;
Color = (U16)(Lut->R[R] | Lut->G[G] | Lut->B[B]);
*pTempBits++ = Color;
}
pTempBits += Extra;
}
Result = Surface->Unlock((RECT*)pRect);
assert(Result == DD_OK);
}
示例4: LoadLMapFromSystem
//=====================================================================================
// LoadLMapFromSystem
//=====================================================================================
static void LoadLMapFromSystem(DRV_LInfo *LInfo, int32 Log, int32 LNum)
{
U16 *pTempBits;
int32 w, h, Width, Height, Size, Extra;
U8 *pBitPtr;
LPDIRECTDRAWSURFACE4 Surface;
RGB_LUT *Lut;
DDSURFACEDESC2 ddsd;
HRESULT ddrval;
pBitPtr = (U8*)LInfo->RGBLight[LNum];
Width = LInfo->Width;
Height = LInfo->Height;
Size = 1<<Log;
Extra = Size - Width;
Lut = &AppInfo.Lut1;
Surface = SystemToVideo[Log].Surface;
memset(&ddsd, 0, sizeof(DDSURFACEDESC2));
ddsd.dwSize = sizeof(DDSURFACEDESC2);
ddrval = Surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
assert(ddrval == DD_OK);
U8 R, G, B;
U16 Color;
pTempBits = (USHORT*)ddsd.lpSurface;
for (h=0; h< Height; h++)
{
for (w=0; w< Width; w++)
{
R = *pBitPtr++;
G = *pBitPtr++;
B = *pBitPtr++;
Color = (U16)(Lut->R[R] | Lut->G[G] | Lut->B[B]);
*pTempBits++ = Color;
}
pTempBits += Extra;
}
ddrval = Surface->Unlock(NULL);
assert(ddrval == DD_OK);
}
示例5: Restore
/***************************************************************************\
Restores the specified surface.
\***************************************************************************/
void IMR_DirectXInterface::Restore(LPDIRECTDRAWSURFACE4 Surface)
{
int err;
// If the surface hasn't been initialized, return:
if (!Surface) return;
// Restore the surface:
err = Surface->Restore();
if (err == DDERR_WRONGMODE)
{
DirectDraw->SetDisplayMode(Display.Width, Display.Height, Display.BPP, 0, 0);
err = Surface->Restore();
}
}
示例6: SetupTexture
//=====================================================================================
// SetupTexture
//=====================================================================================
geBoolean SetupTexture(int32 Stage, geRDriver_THandle *THandle, int32 MipLevel)
{
#ifdef D3D_MANAGE_TEXTURES
D3DSetTexture(Stage, THandle->MipData[MipLevel].Texture);
return GE_TRUE;
#else
THandle_MipData *MipData;
MipData = &THandle->MipData[MipLevel];
if (!SetupMipData(MipData))
{
MipData->Flags |= THANDLE_UPDATE; // Force an upload
CacheInfo.TexMisses++;
}
if (MipData->Flags & THANDLE_UPDATE)
{
HRESULT Error;
LPDIRECTDRAWSURFACE4 Surface;
Surface = D3DCache_SlotGetSurface(MipData->Slot);
Error = Surface->BltFast(0, 0, MipData->Surface, NULL, DDBLTFAST_WAIT);
if (Error != DD_OK)
{
if(Error==DDERR_SURFACELOST)
{
if (!D3DMain_RestoreAllSurfaces())
return FALSE;
}
else
{
D3DMain_Log("SetupTexture: System to Video cache Blt failed.\n %s", D3DErrorToString(Error));
return GE_FALSE;
}
}
}
MipData->Flags &= ~THANDLE_UPDATE;
D3DCache_SlotSetLRU(MipData->Slot, CurrentLRU);
D3DSetTexture(Stage, D3DCache_SlotGetTexture(MipData->Slot));
return GE_TRUE;
#endif
}
示例7: Blit
/***************************************************************************\
Blits one surface to another.
\**************************************************************************/
int IMR_DirectXInterface::Blit(LPDIRECTDRAWSURFACE4 Source, LPDIRECTDRAWSURFACE4 Target)
{
RECT Dest;
HRESULT ddrval;
DDSURFACEDESC2 SourceDesc, TargetDesc;
int BltX, BltY;
// Make sure DirectDraw is active:
if (!Flags.DirectDrawActive)
{
IMR_SetErrorText("IMR_DirectXInterface::Blit(): Interface not initialized!");
return IMRERR_NOTREADY;
}
// Make sure we have surfaces:
if (!Source || !Target)
{
IMR_SetErrorText("IMR_DirectXInterface::Blit(): NULL surface(s) specified!");
return IMRERR_NODATA;
}
// Get a surface descriptor for the surfaces:
TargetDesc.dwSize = sizeof(TargetDesc);
Target->GetSurfaceDesc(&TargetDesc);
SourceDesc.dwSize = sizeof(SourceDesc);
Source->GetSurfaceDesc(&SourceDesc);
// Now find the blit coords:
BltX = (TargetDesc.dwWidth / 2) - (SourceDesc.dwWidth / 2);
BltY = (TargetDesc.dwHeight / 2) - (SourceDesc.dwHeight / 2);
// Blit the surface:
ddrval = Target->BltFast(BltX, BltY, Source, NULL, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT);
// If we lost the surface, return failure:
if (ddrval == DDERR_SURFACELOST)
{
Restore(Source);
Restore(Target);
IMR_SetErrorText("IMR_DirectXInterface::Blit(): Lost surface!");
return IMRERR_DIRECTX;
}
// Return ok:
return IMR_OK;
}
示例8: Set_Surface_Palette
/***************************************************************************\
Sets the palette for the specified surface.
Palette is a pointer to 256 3-byte (RGB) palette entries.
\***************************************************************************/
int IMR_DirectXInterface::Set_Surface_Palette(LPDIRECTDRAWSURFACE4 Surface, void *Palette)
{
PALETTEENTRY SurfacePal[256];
LPDIRECTDRAWPALETTE DDPalette;
char *Pal = (char *)Palette;
int ColorIndex, err;
// If NULL was specified for Surface, use the primary surface:
if (!Surface) Surface = DDPrimarySurface;
if (!DDPrimarySurface)
{
IMR_SetErrorText("IMR_DirectXInterface::Set_Surface_Palette(): No primary surface!");
return IMRERR_NODATA;
}
// Convert the palette:
for (int color = 0; color < 256; color ++)
{
ColorIndex = color * 3;
SurfacePal[color].peRed = Pal[ColorIndex];
SurfacePal[color].peGreen = Pal[ColorIndex + 1];
SurfacePal[color].peBlue = Pal[ColorIndex + 2];
SurfacePal[color].peFlags = PC_NOCOLLAPSE;
}
// Make sure the DirectDraw object and the surfaces have been initialized:
if (DirectDraw && Surface)
{
// Create the palette. If we can't, return false:
err = DirectDraw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256, SurfacePal, &DDPalette, NULL);
if (err != DD_OK)
{
IMR_SetErrorText("IMR_DirectXInterface::Set_Palette(): DXERR: %s", IMR_MsgFromDXErr(err));
return IMRERR_DIRECTX;
}
// Set the palette for the surface:
Surface->SetPalette(DDPalette);
}
else
{
IMR_SetErrorText("IMR_DirectXInterface::Set_Palette(): No surface specified or not initialized!");
return IMRERR_NODATA;
}
// Return OK:
return IMR_OK;
}
示例9: Prepare_Frame
/***************************************************************************\
Prepares all surfaces for rendering.
\***************************************************************************/
void IMR_DirectXInterface::Prepare_Frame(LPDIRECTDRAWSURFACE4 Target)
{
D3DRECT ClearRect;
DDSURFACEDESC2 TargetDesc;
// Make sure we have a target surface and a viewport interface:
if (!Direct3DViewport || !Target)
return;
// Get target size info:
TargetDesc.dwSize = sizeof(TargetDesc);
Target->GetSurfaceDesc(&TargetDesc);
// Setup the area to clear:
ClearRect.x1 = 0;
ClearRect.y1 = 0;
ClearRect.x2 = TargetDesc.dwWidth;
ClearRect.y2 = TargetDesc.dwHeight;
// Clear the viewport:
Direct3DViewport->Clear2(1, &ClearRect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, (float)1.0, NULL);
}
示例10: SetupLMap
//=====================================================================================
// SetupLMap
//=====================================================================================
geBoolean SetupLMap(int32 Stage, DRV_LInfo *LInfo, int32 LNum, geBoolean Dynamic)
{
#ifdef D3D_MANAGE_TEXTURES
#ifdef USE_TPAGES
{
geRDriver_THandle *THandle;
THandle = LInfo->THandle;
if (Dynamic)
THandle->Flags |= THANDLE_UPDATE;
if (!THandle->Block)
{
THandle->Block = TPage_MgrFindOptimalBlock(TPageMgr, CurrentLRU);
THandle->Flags |= THANDLE_UPDATE;
TPage_BlockSetUserData(THandle->Block, THandle);
assert(THandle->Block);
}
else if (TPage_BlockGetUserData(THandle->Block) != THandle)
{
// Find another block
THandle->Block = TPage_MgrFindOptimalBlock(TPageMgr, CurrentLRU);
assert(THandle->Block);
THandle->Flags |= THANDLE_UPDATE;
TPage_BlockSetUserData(THandle->Block, THandle);
}
if (THandle->Flags & THANDLE_UPDATE)
FillLMapSurface2(LInfo, LNum);
TPage_BlockSetLRU(THandle->Block, CurrentLRU);
D3DSetTexture(Stage, TPage_BlockGetTexture(THandle->Block));
if (Dynamic)
THandle->Flags |= THANDLE_UPDATE;
else
THandle->Flags &= ~THANDLE_UPDATE;
return GE_TRUE;
}
#else
{
geRDriver_THandle *THandle;
THandle = LInfo->THandle;
if (Dynamic)
THandle->MipData[0].Flags |= THANDLE_UPDATE;
if (THandle->MipData[0].Flags & THANDLE_UPDATE)
FillLMapSurface(LInfo, LNum);
D3DSetTexture(Stage, THandle->MipData[0].Texture);
if (Dynamic)
THandle->MipData[0].Flags |= THANDLE_UPDATE;
else
THandle->MipData[0].Flags &= ~THANDLE_UPDATE;
return GE_TRUE;
}
#endif
#else
geRDriver_THandle *THandle;
THandle_MipData *MipData;
THandle = LInfo->THandle;
MipData = &THandle->MipData[0];
if (Dynamic)
MipData->Flags |= THANDLE_UPDATE;
if (!SetupMipData(MipData))
{
MipData->Flags |= THANDLE_UPDATE; // Force an upload
CacheInfo.LMapMisses++;
}
if (MipData->Flags & THANDLE_UPDATE)
{
HRESULT Error;
LPDIRECTDRAWSURFACE4 Surface;
assert(MipData->Slot);
Surface = D3DCache_SlotGetSurface(MipData->Slot);
assert(Surface);
assert(THandle->Log < MAX_LMAP_LOG_SIZE);
assert(SystemToVideo[THandle->Log].Surface);
LoadLMapFromSystem(LInfo, THandle->Log, LNum);
Error = Surface->BltFast(0, 0, SystemToVideo[THandle->Log].Surface, NULL, DDBLTFAST_WAIT);
//.........这里部分代码省略.........
示例11: Unlock_Surface
/***************************************************************************\
Unlocks the specified surface.
\***************************************************************************/
void IMR_DirectXInterface::Unlock_Surface(LPDIRECTDRAWSURFACE4 Surface)
{
if (!Surface) Surface = DDPrimarySurface;
Surface->Unlock(NULL);
}
示例12: sizeof
/***************************************************************************\
Initializes Direct3D.
\***************************************************************************/
int IMR_DirectXInterface::InitDirect3D(LPDIRECTDRAWSURFACE4 Target)
{
int err;
D3DVIEWPORT2 PortInitData;
DDPIXELFORMAT ZBufferPixelFormat;
DDSURFACEDESC2 ZBufferDesc, TargetDesc;
D3DDEVICEDESC HALDesc, HELDesc;
int DeviceFound = FALSE, FormatFound = FALSE;
// Make sure DirectDraw is active:
if (!Flags.DirectDrawActive)
{
IMR_SetErrorText("IMR_DirectXInterface::InitDirect3D(): DirectDraw not initialized!");
return IMRERR_NOTREADY;
}
// Make sure we have a target surface:
if (!Target)
{
IMR_SetErrorText("IMR_DirectXInterface::InitDirect3D(): NULL target specified!");
return IMRERR_NODATA;
}
// Get target size info:
TargetDesc.dwSize = sizeof(TargetDesc);
Target->GetSurfaceDesc(&TargetDesc);
// Release all Direct3D interfaces:
if (Direct3DViewport)
{
Direct3DViewport->Release();
Direct3DViewport = NULL;
}
if (Direct3DDevice)
{
Direct3DDevice->Release();
Direct3DDevice = NULL;
}
if (Direct3D)
{
Direct3D->Release();
Direct3D = NULL;
}
Flags.Direct3DActive = 0;
// Now get a new Direct3D3 interface:
DirectDraw->QueryInterface(IID_IDirect3D3, (void **)&Direct3D);
if (err != DD_OK)
{
IMR_SetErrorText("IMR_DirectXInterface::InitDirect3D(): 1 DXERR: %s", IMR_MsgFromDXErr(err));
return IMRERR_DIRECTX;
}
// Enumerate the devices and find one to use:
err = Direct3D->EnumDevices(DeviceCallback, &DeviceFound);
if (err != D3D_OK)
{
IMR_SetErrorText("IMR_DirectXInterface::InitDirect3D(): 2 DXERR: %s", IMR_MsgFromDXErr(err));
return IMRERR_DIRECTX;
}
if (!DeviceFound)
{
IMR_SetErrorText("IMR_DirectXInterface::InitDirect3D(): No usable rendering devices!");
return IMRERR_DIRECTX;
}
// Find a pixel format for our z-buffer and verify that it worked:
Direct3D->EnumZBufferFormats(Direct3DDeviceInfo.Guid, ZBufferCallback, (void *)&ZBufferPixelFormat);
if (ZBufferPixelFormat.dwSize != sizeof(DDPIXELFORMAT))
{
IMR_SetErrorText("IMR_DirectXInterface::InitDirect3D(): Couldn't find Z-Buffer pixel format!");
return IMRERR_DIRECTX;
}
// Create a Z-Buffer:
ZeroMemory((void *)&ZBufferDesc, sizeof(ZBufferDesc));
ZBufferDesc.dwSize = sizeof(ZBufferDesc);
ZBufferDesc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ZBufferDesc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
ZBufferDesc.dwWidth = TargetDesc.dwWidth;
ZBufferDesc.dwHeight = TargetDesc.dwHeight;
memcpy(&ZBufferDesc.ddpfPixelFormat, &ZBufferPixelFormat, sizeof(DDPIXELFORMAT));
if (IsEqualIID(Direct3DDeviceInfo.Guid, IID_IDirect3DHALDevice))
ZBufferDesc.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
else
ZBufferDesc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
err = DirectDraw->CreateSurface(&ZBufferDesc, &DDZBuffer, NULL);
if (err != DD_OK)
{
IMR_SetErrorText("IMR_DirectXInterface::InitDirect3D(): 3 DXERR: %s", IMR_MsgFromDXErr(err));
return IMRERR_DIRECTX;
}
// Now attach the Z-buffer to the target surface:
err = Target->AddAttachedSurface(DDZBuffer);
if (err != DD_OK)
{
//.........这里部分代码省略.........
示例13: Destroy_Surface
void Destroy_Surface(LPDIRECTDRAWSURFACE4 Surface) const { Surface->Release(); };
示例14: Shutdown
void Shutdown(void)
{
if (Lightmap) Lightmap->Release();
Lightmap = NULL;
if (LightmapSurface) LightmapSurface->Release();
LightmapSurface = NULL;
DirectX = NULL;
};
示例15: Flip
// 페이지 플리핑
int Flip()
{
//동영상 재생
if ( ParkPlaying && (smFlipCount&1)==0 ) {
updateFrameWin_Video();
return TRUE;
}
if ( WindowMode || ( hFocusWnd && (smFlipCount&1)==0) ) {
updateFrameWin();
return TRUE;
}
HRESULT hresult = lpDDSPrimary->Flip( NULL, DDFLIP_WAIT );
if ( hresult == DDERR_SURFACELOST ) {
lpDDSPrimary->Restore();
return FALSE;
}
smFlipCount++; //플리핑 카운터
return TRUE;
}