本文整理汇总了C++中CComQIPtr::CreateSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::CreateSurface方法的具体用法?C++ CComQIPtr::CreateSurface怎么用?C++ CComQIPtr::CreateSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::CreateSurface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cAutoLock
bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
if (!ppSubPic) {
return false;
}
if (m_maxsize.cx <= 0 || m_maxsize.cy <= 0) {
return false;
}
CAutoLock cAutoLock(this);
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | (fStatic ? DDSCAPS_SYSTEMMEMORY : 0);
ddsd.ddsCaps.dwCaps2 = fStatic ? 0 : (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_HINTSTATIC);
ddsd.dwWidth = m_maxsize.cx;
ddsd.dwHeight = m_maxsize.cy;
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
if (m_fPow2Textures && ddsd.dwWidth < 1024 && ddsd.dwHeight < 1024) {
ddsd.dwWidth = ddsd.dwHeight = 1;
while (ddsd.dwWidth < (DWORD)m_maxsize.cx) {
ddsd.dwWidth <<= 1;
}
while (ddsd.dwHeight < (DWORD)m_maxsize.cy) {
ddsd.dwHeight <<= 1;
}
}
CComPtr<IDirect3D7> pD3D;
CComQIPtr<IDirectDraw7, &IID_IDirectDraw7> pDD;
if (FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
return false;
}
CComPtr<IDirectDrawSurface7> pSurface;
if (FAILED(pDD->CreateSurface(&ddsd, &pSurface, nullptr))) {
return false;
}
try {
*ppSubPic = DEBUG_NEW CDX7SubPic(m_pD3DDev, pSurface);
} catch (std::bad_alloc) {
return false;
}
(*ppSubPic)->AddRef();
return true;
}
示例2: cAutoLock
bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
if (!ppSubPic) {
return false;
}
CAutoLock cAutoLock(this);
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | (fStatic ? DDSCAPS_SYSTEMMEMORY : 0);
ddsd.ddsCaps.dwCaps2 = fStatic ? 0 : (DDSCAPS2_TEXTUREMANAGE|DDSCAPS2_HINTSTATIC);
ddsd.dwWidth = m_maxsize.cx;
ddsd.dwHeight = m_maxsize.cy;
ddsd.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB|DDPF_ALPHAPIXELS;
ddsd.ddpfPixelFormat.dwRGBBitCount = 32;
ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
CComPtr<IDirect3D7> pD3D;
CComQIPtr<IDirectDraw7, &IID_IDirectDraw7> pDD;
if (FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
return false;
}
CComPtr<IDirectDrawSurface7> pSurface;
if (FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL))) {
return false;
}
*ppSubPic = DNew CDX7SubPic(m_pD3DDev, pSurface);
if (!(*ppSubPic)) {
return false;
}
(*ppSubPic)->AddRef();
return true;
}