本文整理汇总了C++中IDirect3DSurface9::GetDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DSurface9::GetDesc方法的具体用法?C++ IDirect3DSurface9::GetDesc怎么用?C++ IDirect3DSurface9::GetDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DSurface9
的用法示例。
在下文中一共展示了IDirect3DSurface9::GetDesc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
RageSurface* RageDisplay_D3D::CreateScreenshot()
{
#if defined(XBOX)
return NULL;
#else
RageSurface * result = NULL;
// Get the back buffer.
IDirect3DSurface9* pSurface;
if( SUCCEEDED( g_pd3dDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pSurface ) ) )
{
// Get the back buffer description.
D3DSURFACE_DESC desc;
pSurface->GetDesc( &desc );
// Copy the back buffer into a surface of a type we support.
IDirect3DSurface9* pCopy;
if( SUCCEEDED( g_pd3dDevice->CreateOffscreenPlainSurface( desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pCopy, NULL ) ) )
{
if( SUCCEEDED( D3DXLoadSurfaceFromSurface( pCopy, NULL, NULL, pSurface, NULL, NULL, D3DX_FILTER_NONE, 0) ) )
{
// Update desc from the copy.
pCopy->GetDesc( &desc );
D3DLOCKED_RECT lr;
{
RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = desc.Width;
rect.bottom = desc.Height;
pCopy->LockRect( &lr, &rect, D3DLOCK_READONLY );
}
RageSurface *surface = CreateSurfaceFromPixfmt( FMT_RGBA8, lr.pBits, desc.Width, desc.Height, lr.Pitch);
ASSERT( surface != NULL );
// We need to make a copy, since lr.pBits will go away when we call UnlockRect().
result =
CreateSurface( surface->w, surface->h,
surface->format->BitsPerPixel,
surface->format->Rmask, surface->format->Gmask,
surface->format->Bmask, surface->format->Amask );
RageSurfaceUtils::CopySurface( surface, result );
delete surface;
pCopy->UnlockRect();
}
pCopy->Release();
}
pSurface->Release();
}
return result;
#endif
}
示例2:
CDX9TextureManager::CDX9TextureManager( )
: m_pDefaultRT( NULL )
, m_pDefaultDT( NULL )
, m_pNULLTexture( NULL )
{
// Create the default render target
IDirect3DSurface9* pDefaultRT = NULL;
CDX9Renderer::GetDevice( )->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pDefaultRT );
D3DSURFACE_DESC RTDesc;
pDefaultRT->GetDesc( &RTDesc );
m_pDefaultRT = new CDX9Texture( pDefaultRT, CDX9Renderer::GetDevice( ) );
// Create the default depth target
IDirect3DSurface9* pDefaultDT = NULL;
CDX9Renderer::GetDevice( )->GetDepthStencilSurface( &pDefaultDT );
D3DSURFACE_DESC Desc;
pDefaultDT->GetDesc( &Desc );
m_pDefaultDT = new CDX9Texture( pDefaultDT, CDX9Renderer::GetDevice( ), true );
// Create the null texture
IDirect3DTexture9* p = NULL;
m_pNULLTexture = new CDX9Texture( p, CDX9Renderer::GetDevice( ) );
}
示例3: FillDefaultBltInfo
HRESULT CD3DUtils::ProgressiveBlt(IDirect3DSurface9 *pSurfIn, IDirect3DSurface9 *pSurfOut)
{
if (!m_pVPDevice || !pSurfIn || !pSurfOut) return E_FAIL;
DXVA2_VideoProcessBltParams blt = {0};
DXVA2_VideoSample samples[2] = {0};
RECT SrcRect = {0};
RECT DstRect = {0};
D3DSURFACE_DESC SrcDesc, DstDesc;
IDirect3DSurface9 *pSrc = pSurfIn;
IDirect3DSurface9 *pDst = pSurfOut;
REFERENCE_TIME rtStart = 0;
REFERENCE_TIME rtStop = 1;
pSrc->GetDesc(&SrcDesc);
pDst->GetDesc(&DstDesc);
SrcRect.right = SrcDesc.Width;
SrcRect.bottom = SrcDesc.Height;
DstRect.right = DstDesc.Width;
DstRect.bottom = DstDesc.Height;
FillDefaultBltInfo(blt);
blt.TargetFrame = rtStart;
blt.TargetRect = DstRect;
// DXVA2_VideoProcess_Constriction
blt.ConstrictionSize.cx = blt.TargetRect.right - blt.TargetRect.left;
blt.ConstrictionSize.cy = blt.TargetRect.bottom - blt.TargetRect.top;
//
// Initialize main stream video sample.
//
samples[0].Start = rtStart;
samples[0].End = rtStop;
FillDefaultDXVAFormat(samples[0].SampleFormat, DXVA2_SampleProgressiveFrame);
samples[0].SrcSurface = pSrc;
samples[0].SrcRect = SrcRect;
samples[0].DstRect = DstRect;
samples[0].PlanarAlpha = DXVA2_Fixed32OpaqueAlpha();
HRESULT hr = m_pVPDevice->VideoProcessBlt(pDst, &blt, samples, 1, NULL);
return hr;
}
示例4: ImagePtr
ImagePtr D3D9VideoBufferManager::CreateImage(int iWidth, int iHeight, FORMAT Format)
{
IDirect3DTexture9 * texture;
HRESULT hr = D3DXCreateTexture(mD3D9Device,
iWidth,
iHeight,
1,
0,
D3D9Mapping::GetD3DFormat(Format),
D3DPOOL_SYSTEMMEM,
&texture);
D3DErrorExceptionFunction(D3DXCreateTexture, hr);
IDirect3DSurface9 * surface;
texture->GetSurfaceLevel(0, &surface);
D3DSURFACE_DESC desc;
surface->GetDesc(&desc);
D3D9Image * image = new D3D9Image();
image->mWidth = desc.Width;
image->mHeight = desc.Height;
image->mSrcWidth = iWidth;
image->mSrcHeight = iHeight;
image->mFormat = D3D9Mapping::GetFormat(desc.Format);
image->mMipmapLevel = texture->GetLevelCount();
image->mD3D9Texture = texture;
surface->Release();
return ImagePtr(image);
}
示例5: if
HRESULT DS2Plugin::redirectSetRenderTarget(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
// At this point, we can grab the z (RT1) and normal (RT0) RTs
if(RenderTargetIndex == 1 && pRenderTarget == NULL && zBufferSurf == NULL) {
SAFERELEASE(zBufferSurf);
SAFERELEASE(normalSurf);
d3ddev->GetRenderTarget(1, &zBufferSurf);
d3ddev->GetRenderTarget(0, &normalSurf);
}
// If previous RT was D3DFMT_A16B16G16R16F, store RT
else if(((doAO && ssao) || (doBloom && bloom)) && !aoDone && !hdrRT && RenderTargetIndex == 0 && zBufferSurf != NULL && defaultState != NULL) {
IDirect3DSurface9* prevRT = NULL;
d3ddev->GetRenderTarget(0, &prevRT);
if(prevRT) {
D3DSURFACE_DESC desc;
prevRT->GetDesc(&desc);
if(desc.Format == D3DFMT_A16B16G16R16F && (desc.Width == manager.getRenderWidth() || desc.Height == manager.getRenderHeight()) && !aoDone) {
// store RT for later use
hdrRT = prevRT;
}
else {
SAFERELEASE(prevRT);
}
}
}
return GamePlugin::redirectSetRenderTarget(RenderTargetIndex, pRenderTarget);
}
示例6: dxReadPixels
HRESULT dxReadPixels(IDirect3DDevice9* Device, void* Buffer, bool& Minimised, int& Width, int& Height, D3DFORMAT Format)
{
IDirect3DSurface9* RenderTarget = nullptr;
IDirect3DSurface9* DestTarget = nullptr;
HRESULT result = Device->GetRenderTarget(0, &RenderTarget);
if (result == S_OK)
{
if (Width == 0 || Height == 0 || Format == D3DFMT_UNKNOWN)
{
D3DSURFACE_DESC descriptor = {};
RenderTarget->GetDesc(&descriptor);
Width = descriptor.Width;
Height = descriptor.Height;
Format = descriptor.Format;
}
HDC DC = nullptr;
RenderTarget->GetDC(&DC);
Minimised = IsIconic(WindowFromDC(DC));
RenderTarget->ReleaseDC(DC);
result = Device->CreateOffscreenPlainSurface(Width, Height, Format, D3DPOOL_SYSTEMMEM, &DestTarget, nullptr);
result = Device->GetRenderTargetData(RenderTarget, DestTarget);
D3DLOCKED_RECT rect;
DestTarget->LockRect(&rect, 0, D3DLOCK_READONLY);
memcpy(Buffer, rect.pBits, Width * Height * 4);
DestTarget->UnlockRect();
}
SafeRelease(RenderTarget);
SafeRelease(DestTarget);
return result;
}
示例7:
D3D9ProxySwapChain::D3D9ProxySwapChain(IDirect3DSwapChain9* pActualSwapChain, D3DProxyDevice* pWrappedOwningDevice, bool isAdditionalChain) :
BaseDirect3DSwapChain9(pActualSwapChain, pWrappedOwningDevice, isAdditionalChain),
m_backBuffers()
{
// Get creation parameters for backbuffers.
D3DPRESENT_PARAMETERS params;
pActualSwapChain->GetPresentParameters(¶ms);
UINT bbCount = params.BackBufferCount;
if (bbCount == 0)
bbCount = 1;
m_backBuffers.reserve(bbCount);
IDirect3DSurface9* pTempActualBackBuffer;
pActualSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pTempActualBackBuffer);
D3DSURFACE_DESC backDesc;
pTempActualBackBuffer->GetDesc(&backDesc);
pTempActualBackBuffer->Release();
pTempActualBackBuffer = NULL;
// Create stereo backbuffers to use in place of actual backbuffers
for (UINT i = 0; i < bbCount; i++) {
IDirect3DSurface9* pTemp;
pWrappedOwningDevice->CreateRenderTarget(backDesc.Width, backDesc.Height, backDesc.Format, backDesc.MultiSampleType, backDesc.MultiSampleQuality, false, &pTemp, NULL, true);
m_backBuffers.push_back(static_cast<D3D9ProxySurface*>(pTemp));
}
}
示例8: DoLimbo
void RSManager::DoLimbo()
{
if (!(mainRT && zSurf && doLimbo && limbo)) return;
IDirect3DSurface9 *oldRenderTarget;
d3ddev->GetRenderTarget(0, &oldRenderTarget);
if (oldRenderTarget == mainRT) {
// final renderbuffer has to be from texture, just making sure here
if (IDirect3DTexture9* tex = getSurfTexture(oldRenderTarget)) {
// check size just to make even more sure
D3DSURFACE_DESC desc;
oldRenderTarget->GetDesc(&desc);
if (desc.Width == Settings::get().getRenderWidth() && desc.Height == Settings::get().getRenderHeight()) {
IDirect3DTexture9 *zTex = getSurfTexture(zSurf);
storeRenderState();
d3ddev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
d3ddev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE);
/// Draw zbuffer
limbo->go(zTex, oldRenderTarget, limboZNear, limboZFar);
SDLOG(0, "ZNear: %g, ZFar: %g\n", limboZNear, limboZFar);
//d3ddev->StretchRect(zSurf, NULL, oldRenderTarget, NULL, D3DTEXF_NONE);
restoreRenderState();
zTex->Release();
}
tex->Release();
}
}
oldRenderTarget->Release();
}
示例9: CreateDepthBuffers
void RenderController::CreateDepthBuffers()
{
IDirect3DSurface9 *pOldDS = NULL;
D3DSURFACE_DESC desc;
Renderer::theDevicePtr->GetDepthStencilSurface( &pOldDS );
pOldDS->GetDesc(&desc);
pOldDS->Release();
Renderer::theDevicePtr->CreateDepthStencilSurface( thePointShadowSize,
thePointShadowSize, desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE,
&m_pPointDSShadow, NULL );
Renderer::theDevicePtr->CreateDepthStencilSurface( theDirectionalShadowSize,
theDirectionalShadowSize, desc.Format,D3DMULTISAMPLE_NONE, 0, TRUE,
&m_pDirectionalDSShadow, NULL );
m_SpotDepths.Create(theSpotShadowSize, theSpotShadowSize);
Renderer::theDevicePtr->CreateDepthStencilSurface( theSpotShadowSize,
theSpotShadowSize, desc.Format,D3DMULTISAMPLE_NONE, 0, TRUE,
&m_pSpotDSShadow, NULL );
Renderer::theDevicePtr->CreateDepthStencilSurface(desc.Width,
desc.Height, desc.Format,
D3DMULTISAMPLE_NONE, 0, TRUE, &m_pDSGBuffers, NULL );
}
示例10: MAKEFOURCC
bool CDVDCodecUtils::CopyDXVA2Picture(YV12Image* pImage, DVDVideoPicture *pSrc)
{
#ifdef HAS_DX
// TODO: Optimize this later using shaders/swscale/etc.
switch (pSrc->extended_format)
{
case MAKEFOURCC('N','V','1','2'):
{
IDirect3DSurface9* surface = (IDirect3DSurface9*)pSrc->data[3];
D3DLOCKED_RECT rectangle;
if (FAILED(surface->LockRect(&rectangle, NULL, 0)))
return false;
// Copy Y
uint8_t* bits = (uint8_t*)(rectangle.pBits);
uint8_t* d = pImage->plane[0];
for (unsigned y = 0; y < pSrc->iHeight; y++)
{
memcpy(d, bits, pSrc->iWidth);
bits += rectangle.Pitch;
d += pImage->stride[0];
}
D3DSURFACE_DESC desc;
if (FAILED(surface->GetDesc(&desc)))
return false;
// Copy packed UV
uint8_t *s_uv = ((uint8_t*)(rectangle.pBits)) + desc.Height * rectangle.Pitch;
uint8_t *d_uv = pImage->plane[1];
for (unsigned y = 0; y < pSrc->iHeight >> 1; y++)
{
memcpy(d_uv, s_uv, pSrc->iWidth);
s_uv += rectangle.Pitch;
d_uv += pImage->stride[1];
}
if (FAILED(surface->UnlockRect()))
return false;
}
return true;
// Future...
/*case MAKEFOURCC('Y','V','1','2'):
return true;*/
/*case MAKEFOURCC('Y','V','V','Y'):
return true;*/
default:
CLog::Log(LOGWARNING, "CDVDCodecUtils::CopyDXVA2Picture colorspace not supported");
return false;
}
#endif
return false;
}
示例11: if
//! Regenerates the mip map levels of the texture. Useful after locking and
//! modifying the texture
void CD3D9Texture::regenerateMipMapLevels(void* mipmapData)
{
if (mipmapData)
{
core::dimension2du size = TextureSize;
u32 level=0;
do
{
if (size.Width>1)
size.Width /=2;
if (size.Height>1)
size.Height /=2;
++level;
IDirect3DSurface9* mipSurface = 0;
HRESULT hr = Texture->GetSurfaceLevel(level, &mipSurface);
if (FAILED(hr) || !mipSurface)
{
os::Printer::log("Could not get mipmap level", ELL_WARNING);
return;
}
D3DSURFACE_DESC mipDesc;
mipSurface->GetDesc(&mipDesc);
D3DLOCKED_RECT miplr;
// lock mipmap surface
if (FAILED(mipSurface->LockRect(&miplr, NULL, 0)))
{
mipSurface->Release();
os::Printer::log("Could not lock texture", ELL_WARNING);
return;
}
memcpy(miplr.pBits, mipmapData, size.getArea()*getPitch()/TextureSize.Width);
mipmapData = (u8*)mipmapData+size.getArea()*getPitch()/TextureSize.Width;
// unlock
mipSurface->UnlockRect();
// release
mipSurface->Release();
} while (size.Width != 1 || size.Height != 1);
}
else if (HasMipMaps)
{
// create mip maps.
#ifdef _IRR_USE_D3DXFilterTexture_
// The D3DXFilterTexture function seems to get linked wrong when
// compiling with both D3D8 and 9, causing it not to work in the D3D9 device.
// So mipmapgeneration is replaced with my own bad generation
HRESULT hr = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT, D3DX_DEFAULT);
if (FAILED(hr))
#endif
createMipMaps();
}
}
示例12: AssertFatal
void GFXPCD3D9TextureTarget::attachTexture( RenderSlot slot, GFXCubemap *tex, U32 face, U32 mipLevel/*=0*/ )
{
GFXDEBUGEVENT_SCOPE( GFXPCD3D9TextureTarget_attachTexture_Cubemap, ColorI::RED );
AssertFatal(slot < MaxRenderSlotId, "GFXPCD3D9TextureTarget::attachTexture - out of range slot.");
// Mark state as dirty so device can know to update.
invalidateState();
// Release what we had, it's definitely going to change.
mDevice->destroyD3DResource( mTargets[slot] ); // SAFE_RELEASE
mTargets[slot] = NULL;
mResolveTargets[slot] = NULL;
// Cast the texture object to D3D...
AssertFatal(!tex || dynamic_cast<GFXD3D9Cubemap*>(tex),
"GFXD3DTextureTarget::attachTexture - invalid cubemap object.");
GFXD3D9Cubemap *cube = static_cast<GFXD3D9Cubemap*>(tex);
if(slot == Color0)
{
mTargetSize = Point2I::Zero;
mTargetFormat = GFXFormatR8G8B8A8;
}
// Are we clearing?
if(!tex)
{
// Yup - just exit, it'll stay NULL.
return;
}
D3D9Assert(cube->mCubeTex->GetCubeMapSurface( (D3DCUBEMAP_FACES)face, mipLevel, &mTargets[slot] ),
"GFXD3DTextureTarget::attachTexture - could not get surface level for the passed texture!");
// Update surface size
if(slot == Color0)
{
IDirect3DSurface9 *surface = mTargets[Color0];
if ( surface )
{
D3DSURFACE_DESC sd;
surface->GetDesc(&sd);
mTargetSize = Point2I(sd.Width, sd.Height);
S32 format = sd.Format;
GFXREVERSE_LOOKUP( GFXD3D9TextureFormat, GFXFormat, format );
mTargetFormat = (GFXFormat)format;
}
}
}
示例13: copy
void copy(IDirect3DDevice9 *device) {
HRESULT hr;
// A dummy copy over here.
IDirect3DSurface9 *colorSurface = NULL;
V(colorTex->GetSurfaceLevel(0, &colorSurface));
D3DSURFACE_DESC desc;
colorSurface->GetDesc(&desc);
const D3DSURFACE_DESC *backbufferDesc = DXUTGetD3D9BackBufferSurfaceDesc();
RECT rect = {0, 0, min(desc.Width, backbufferDesc->Width), min(desc.Height, backbufferDesc->Height)};
V(device->StretchRect(colorSurface, &rect, backbufferSurface, &rect, D3DTEXF_POINT));
SAFE_RELEASE(colorSurface);
}
示例14: OnDistorting
virtual void OnDistorting()
{
IDirect3DSurface9* targetSurface = nullptr;
IDirect3DSurface9* texSurface = nullptr;
HRESULT hr = S_OK;
// レンダーターゲットを取得
hr = g_D3d9Device->GetRenderTarget( 0, &targetSurface );
if( FAILED( hr ) ){
return;
}
// レンダーターゲットの情報を取得
D3DSURFACE_DESC targetSurfaceDesc;
targetSurface->GetDesc( &targetSurfaceDesc );
// シザリング範囲を取得
RECT scissorRect;
g_D3d9Device->GetScissorRect( &scissorRect );
// 描画範囲を計算
uint32_t width = scissorRect.right - scissorRect.left;
uint32_t height = scissorRect.bottom - scissorRect.top;
// 保持テクスチャとフォーマットが異なればテクスチャを作り直す
if( backGroundTexture == nullptr ||
backGroundTextureWidth != width ||
backGroundTextureHeight != height ||
backGroundTextureFormat != targetSurfaceDesc.Format )
{
PrepareTexture( width, height, targetSurfaceDesc.Format );
}
// コピーするためのサーフェスを取得
hr = backGroundTexture->GetSurfaceLevel( 0, &texSurface );
if( FAILED( hr ) ){
return;
}
// サーフェス間コピー
hr = g_D3d9Device->StretchRect( targetSurface, &scissorRect, texSurface, NULL, D3DTEXF_NONE);
if( FAILED( hr ) ){
return;
}
// 取得したサーフェスの参照カウンタを下げる
ES_SAFE_RELEASE( texSurface );
ES_SAFE_RELEASE( targetSurface );
renderer->SetBackground( backGroundTexture );
}
示例15: LoadImageFromFile
//! creates a surface from the file
Image* ImageLoaderX::LoadImageFromFile(FileReader* file)
{
IDirect3DSurface9* pSurf = NULL;
D3DXIMAGE_INFO info;
D3DXGetImageInfoFromFileA(file->GetFileName(), &info);
m_pID3DDevice->CreateOffscreenPlainSurface(info.Width, info.Height, info.Format, D3DPOOL_SCRATCH, &pSurf, NULL);
D3DXLoadSurfaceFromFileA(pSurf, NULL, NULL, file->GetFileName(), NULL, D3DX_FILTER_NONE, 0, &info);
Image* image = 0;
if (pSurf)
{
// create surface
D3DLOCKED_RECT lockRect;
D3DSURFACE_DESC desc;
switch (info.Format)
{
case D3DFMT_A8R8G8B8:
case D3DFMT_X8R8G8B8:
pSurf->LockRect(&lockRect, NULL, D3DLOCK_READONLY);
image = new Image(ECF_A8R8G8B8, dimension2d<s32>(info.Width, info.Height), lockRect.pBits, FALSE);
break;
case D3DFMT_R8G8B8:
pSurf->LockRect(&lockRect, NULL, D3DLOCK_READONLY);
pSurf->GetDesc(&desc);
image = new Image(ECF_R8G8B8, dimension2d<s32>(info.Width, info.Height), lockRect.pBits, FALSE);
break;
case D3DFMT_A1R5G5B5:
case D3DFMT_X1R5G5B5:
pSurf->LockRect(&lockRect, NULL, D3DLOCK_READONLY);
image = new Image(ECF_A1R5G5B5, dimension2d<s32>(info.Width, info.Height), lockRect.pBits, FALSE);
break;
case D3DFMT_R5G6B5:
pSurf->LockRect(&lockRect, NULL, D3DLOCK_READONLY);
image = new Image(ECF_R5G6B5, dimension2d<s32>(info.Width, info.Height), lockRect.pBits, FALSE);
break;
default:
Printer::Log("No matched image format", ELL_ERROR);
break;
}
}
else
{
Printer::Log("D3DXLoadSuface failed", ELL_ERROR);
return NULL;
}
pSurf->Release();
return image;
}