当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTDRAWSURFACE4::GetSurfaceDesc方法代码示例

本文整理汇总了C++中LPDIRECTDRAWSURFACE4::GetSurfaceDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE4::GetSurfaceDesc方法的具体用法?C++ LPDIRECTDRAWSURFACE4::GetSurfaceDesc怎么用?C++ LPDIRECTDRAWSURFACE4::GetSurfaceDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTDRAWSURFACE4的用法示例。


在下文中一共展示了LPDIRECTDRAWSURFACE4::GetSurfaceDesc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
 }
开发者ID:dhawt,项目名称:Immerse,代码行数:49,代码来源:imr_directx.cpp

示例2: 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);
 }
开发者ID:dhawt,项目名称:Immerse,代码行数:25,代码来源:imr_directx.cpp

示例3: 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)
    {
//.........这里部分代码省略.........
开发者ID:dhawt,项目名称:Immerse,代码行数:101,代码来源:imr_directx.cpp


注:本文中的LPDIRECTDRAWSURFACE4::GetSurfaceDesc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。