本文整理汇总了C++中IDirect3DSurface9类的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DSurface9类的具体用法?C++ IDirect3DSurface9怎么用?C++ IDirect3DSurface9使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDirect3DSurface9类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ERR
bool Blit::copy(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level)
{
RenderTarget9 *renderTarget = NULL;
IDirect3DSurface9 *source = NULL;
gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0);
if (colorbuffer)
{
renderTarget = RenderTarget9::makeRenderTarget9(colorbuffer->getRenderTarget());
}
if (renderTarget)
{
source = renderTarget->getSurface();
}
if (!source)
{
ERR("Failed to retrieve the render target.");
return gl::error(GL_OUT_OF_MEMORY, false);
}
TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage->getStorageInstance());
IDirect3DSurface9 *destSurface = storage9->getCubeMapSurface(target, level, true);
bool result = false;
if (destSurface)
{
result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface);
destSurface->Release();
}
source->Release();
return result;
}
示例2: D3DXCreateTexture
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);
}
示例3: QByteArray
QByteArray MFTransform::dataFromBuffer(IMFMediaBuffer *buffer, int height, int *bytesPerLine)
{
QByteArray array;
BYTE *bytes;
DWORD length;
HRESULT hr = buffer->Lock(&bytes, NULL, &length);
if (SUCCEEDED(hr)) {
array = QByteArray((const char *)bytes, (int)length);
buffer->Unlock();
} else {
// try to lock as Direct3DSurface
IDirect3DSurface9 *surface = 0;
do {
if (FAILED(MFGetService(buffer, MR_BUFFER_SERVICE, IID_IDirect3DSurface9, (void**)&surface)))
break;
D3DLOCKED_RECT rect;
if (FAILED(surface->LockRect(&rect, NULL, D3DLOCK_READONLY)))
break;
if (bytesPerLine)
*bytesPerLine = (int)rect.Pitch;
array = QByteArray((const char *)rect.pBits, rect.Pitch * height);
surface->UnlockRect();
} while (false);
if (surface) {
surface->Release();
surface = 0;
}
}
return array;
}
示例4: D3D9Assert
GBitmap *AtlasTexChunk::loadDDSIntoGBitmap(const U8 *ddsBuffer, U32 ddsBufferSize)
{
D3DXIMAGE_INFO info;
D3D9Assert(GFXD3DX.D3DXGetImageInfoFromFileInMemory(ddsBuffer, ddsBufferSize, &info),
"AtlasTexChunk::loadDDSIntoGBitmap - failed to get image info.");
IDirect3DSurface9 *surf = NULL;
D3D9Assert(((GFXD3D9Device*)GFX)->getDevice()->CreateOffscreenPlainSurface(
info.Width, info.Height, info.Format, D3DPOOL_SCRATCH, &surf, NULL),
"AtlasTexChunk::loadDDSIntoGBitmap - failed to allocate scratch surface.");
// We want JPEGs, let's convert it in a klunky way...
D3D9Assert(GFXD3DX.D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL,
ddsBuffer, ddsBufferSize, NULL,
D3DX_DEFAULT, 0, NULL),
"AtlasTexChunk::loadDDSIntoGBitmap - D3DX failed to load from buffer.");
ID3DXBuffer *buff = NULL;
D3D9Assert(GFXD3DX.D3DXSaveSurfaceToFileInMemory(&buff, D3DXIFF_PNG, surf, NULL, NULL),
"AtlasTexChunk::loadDDSIntoGBitmap - D3DX failed to save back to buffer.");
MemStream ms(buff->GetBufferSize(), buff->GetBufferPointer(), true, false);
GBitmap *bitmap = new GBitmap[1];
bitmap->readBitmap( "png", ms );
// Cleanup!
buff->Release();
surf->Release();
return bitmap;
}
示例5: DrawToTexture
void COverlayRenderer::DrawToTexture(OSDTexture* pOsdTexture, IDirect3DTexture9* pTexture, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
{
if (!pOsdTexture || !pTexture || !m_pD3DDevice)
return;
RECT sourceRect;
sourceRect.left = 0;
sourceRect.top = 0;
sourceRect.right = w;
sourceRect.bottom = h;
RECT dstRect;
dstRect.left = x;
dstRect.top = y;
dstRect.right = x + w;
dstRect.bottom = y + h;
IDirect3DSurface9* sourceSurface = NULL;
IDirect3DSurface9* dstSurface = NULL;
pTexture->GetSurfaceLevel(0, &sourceSurface);
pOsdTexture->texture->GetSurfaceLevel(0, &dstSurface);
m_pD3DDevice->StretchRect(sourceSurface, &sourceRect, dstSurface, &dstRect, D3DTEXF_NONE);
sourceSurface->Release();
dstSurface->Release();
pTexture->Release();
}
示例6: InstallOnDevice
LTRESULT CRenderTarget::InstallOnDevice()
{
if(m_pRenderTarget == NULL || m_pDepthStencilBuffer == NULL)
{
return LT_ERROR;
}
IDirect3DSurface9* pRTSurface;
if(FAILED(m_pRenderTarget->GetSurfaceLevel(0, &pRTSurface)))
{
return LT_ERROR;
}
if(FAILED(PD3DDEVICE->SetRenderTarget(pRTSurface, m_pDepthStencilBuffer)))
{
dsi_ConsolePrint("Failed to set the new render target!");
pRTSurface->Release();
return LT_ERROR;
}
// We need to clear to make it a valid render target.
if(FAILED(PD3DDEVICE->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DRGBA_255(0, 0, 0, 0), 1.0f, 0)))
{
PD3DDEVICE->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DRGBA_255(0, 0, 0, 0), 1.0f, 0);
}
pRTSurface->Release();
return LT_OK;
}
示例7: OutputDebugString
HRESULT WINAPI D3D9ProxySwapChain::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags)
{
#ifdef _DEBUG
OutputDebugString(__FUNCTION__);
OutputDebugString("\n");
#endif;
// Test only, StereoView needs to be properly integrated as part of SwapChain.
// This test allowed deus ex menus and videos to work correctly. Lots of model rendering issues in game though
D3DProxyDevice* pD3DProxyDev = static_cast<D3DProxyDevice*>(m_pOwningDevice);
IDirect3DSurface9* pWrappedBackBuffer;
try {
GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pWrappedBackBuffer);
if (pD3DProxyDev->stereoView->initialized)
pD3DProxyDev->stereoView->Draw(static_cast<D3D9ProxySurface*>(pWrappedBackBuffer));
pWrappedBackBuffer->Release();
}
catch (std::out_of_range) {
OutputDebugString("Present: No primary swap chain found. (Present probably called before device has been reset)");
}
return m_pActualSwapChain->Present(pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
}
示例8: catch
void D3D9Sprite::RecoverFromBackup()
{
if (!m_pBackupTexture)
return;
m_texture = m_video.lock()->CreateRenderTargetTexture(static_cast<unsigned int>(m_size.x), static_cast<unsigned int>(m_size.y), m_targetFormat);
IDirect3DTexture9* pBackup = m_pBackupTexture;
IDirect3DTexture9* pActualTexture;
try
{
pActualTexture = boost::any_cast<IDirect3DTexture9*>(m_texture->GetTextureObject());
}
catch (const boost::bad_any_cast &)
{
std::wstringstream ss;
ss << L"D3D9Sprite::RecoverFromBackup Invalid texture pointer" << std::endl;
ShowMessage(ss, GSMT_ERROR);
return;
}
IDirect3DSurface9* pActualSurface = NULL;
IDirect3DSurface9* pBackupSurf = NULL;
pActualTexture->GetSurfaceLevel(0, &pActualSurface);
pBackup->GetSurfaceLevel(0, &pBackupSurf);
m_pDevice->UpdateSurface(pBackupSurf, NULL, pActualSurface, NULL);
pBackupSurf->Release();
pActualSurface->Release();
GetInternalData();
}
示例9: SRT
void DS_Basic_MRT::buildGBuffers()
{
HRESULT hr;
//-- G-Buffsers
SetRenderTarget SRT(m_pD3DDevice, m_posRT);
IDirect3DSurface9 *pSurfaceZ = NULL;
hr = m_posRT_Z->GetSurfaceLevel(0, &pSurfaceZ );
IDirect3DSurface9 *pSurfaceNormal = NULL;
hr = m_normalRT->GetSurfaceLevel(0, &pSurfaceNormal );
IDirect3DSurface9 *pSurfaceDiffuse= NULL;
hr = m_diffuseRT->GetSurfaceLevel(0, &pSurfaceDiffuse );
hr = m_pD3DDevice->SetRenderTarget(1, pSurfaceZ);
hr = m_pD3DDevice->SetRenderTarget(2, pSurfaceNormal);
hr = m_pD3DDevice->SetRenderTarget(3, pSurfaceDiffuse);
pSurfaceZ->Release();
pSurfaceDiffuse->Release();
pSurfaceNormal->Release();
hr = m_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1, 0);
hr = m_pEffect->SetTechnique("init_mrt");
renderScene();
hr = m_pD3DDevice->SetRenderTarget(1, NULL);
hr = m_pD3DDevice->SetRenderTarget(2, NULL);
hr = m_pD3DDevice->SetRenderTarget(3, NULL);
//hr = D3DXSaveTextureToFile("D:\\test.dds", D3DXIFF_DDS, m_posRT, NULL);
}
示例10: AssertFatal
//-----------------------------------------------------------------------------
// unLock
//-----------------------------------------------------------------------------
void GFXD3D9TextureObject::unlock(U32 mipLevel)
{
AssertFatal( mLocked, "GFXD3D9TextureObject::unlock - Attempting to unlock a surface that has not been locked" );
#ifndef TORQUE_OS_XENON
if( mProfile->isRenderTarget() )
{
IDirect3DSurface9 *dest;
GFXD3D9TextureObject *to = (GFXD3D9TextureObject *) &(*mLockTex);
D3D9Assert( to->get2DTex()->GetSurfaceLevel( 0, &dest ), NULL );
dest->UnlockRect();
dest->Release();
mLocked = false;
}
else
#endif
{
D3D9Assert( get2DTex()->UnlockRect(mipLevel),
"GFXD3D9TextureObject::unlock - could not unlock non-RT texture." );
mLocked = false;
}
}
示例11: PresentToTexture
HRESULT VMRSurfaceAllocator::PresentToTexture( VMR9PresentationInfo *lpPresInfo )
{
HRESULT hr;
IDirect3DTexture9 *lpTexture;
IDirect3DSurface9 *lpSurface;
if ( m_alpDirect3DTexture[ 0 ] != NULL )
{
clock->Lock();
lpTexture = m_alpDirect3DTexture[ m_nFilpTexNum ];
hr = lpTexture->GetSurfaceLevel( 0, &lpSurface );
if ( hr != S_OK )
{
return hr;
}
hr = D3DDev->StretchRect( lpPresInfo->lpSurf, NULL, lpSurface, NULL, D3DTEXF_NONE );
if ( hr != S_OK )
{
lpSurface->Release();
return hr;
}
lpSurface->Release();
texnum = m_nFilpTexNum;
m_nFilpTexNum = m_nFilpTexNum ^ 0x01;
clock->Unlock();
} else
{
m_nFilpTexNum = -1;
}
return S_OK;
}
示例12: 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();
}
示例13: 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 );
}
示例14:
void CCoherentViewListener::DrawFrameDX9SharedTexture( Coherent::UI::CoherentHandle handle, int width, int height )
{
if ( gCoherentUISystem == NULL )
{
return;
}
void* pNativeTexture = gCoherentUISystem->GetNativeTextureFromSharedHandle( handle );
if ( pNativeTexture == NULL )
{
return;
}
IDirect3DTexture9* pD3DSrcTex = static_cast<IDirect3DTexture9*>( pNativeTexture );
IDirect3DSurface9* pSurfaceSource;
pD3DSrcTex->GetSurfaceLevel( 0, &pSurfaceSource );
IDirect3DSurface9* pSurfaceDest;
IDirect3DTexture9* pD3DDestTex = static_cast<IDirect3DTexture9*>( m_pTexture );
pD3DDestTex->GetSurfaceLevel( 0, &pSurfaceDest );
static_cast<IDirect3DDevice9*>( gD3DDevice )->StretchRect( pSurfaceSource, nullptr, pSurfaceDest, nullptr, D3DTEXF_NONE );
pSurfaceSource->Release();
pSurfaceDest->Release();
}
示例15: ASSERT
HRESULT CSurfaceQueueDeviceD3D9::LockSurface(IUnknown* pSurface, DWORD flags)
{
ASSERT(pSurface);
HRESULT hr = S_OK;
IDirect3DSurface9* pSurf = NULL;
DWORD d3d9flags = D3DLOCK_READONLY;
D3DLOCKED_RECT region;
if (flags & SURFACE_QUEUE_FLAG_DO_NOT_WAIT)
{
d3d9flags |= D3DLOCK_DONOTWAIT;
}
if (FAILED(hr = pSurface->QueryInterface(__uuidof(IDirect3DSurface9), (void**)&pSurf)))
{
goto end;
}
hr = pSurf->LockRect(®ion, NULL, d3d9flags);
end:
if (pSurf)
{
pSurf->Release();
}
if (hr == D3DERR_WASSTILLDRAWING)
{
hr = DXGI_ERROR_WAS_STILL_DRAWING;
}
return hr;
}