本文整理汇总了C++中IDirect3DTexture9类的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DTexture9类的具体用法?C++ IDirect3DTexture9怎么用?C++ IDirect3DTexture9使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDirect3DTexture9类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/**
*
* @author Jade Abbott
*
*/
bool
CRadialMenu::CreateFinalTexture()
{
assert(m_pRenderer);
IDirect3DTexture9* pTexture = 0;
if (FAILED(m_pRenderer->GetSurfaceManager().CreateTexture(m_uiDiameter,
m_uiDiameter,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
&pTexture)))
{
return false;
}
CTextureManager& rTextureManager = m_pRenderer->GetTextureManager();
if (m_iFinalTextureID != Utility::INVALID_ID)
{
rTextureManager.RemoveTexture(m_iFinalTextureID);
}
m_iFinalTextureID = rTextureManager.LoadTextureMemory(pTexture);
if (m_iFinalTextureID == Utility::INVALID_ID)
{
pTexture->Release();
return false;
}
return true;
}
示例2: 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);
}
示例3: createTexture
virtual IDirect3DTexture9* createTexture() {
IDirect3DTexture9* tex = CFixedTextureCreator::createTexture();
// create the offscreen surface
HRESULT hr;
CD3DDevice& dx = CD3DDevice::getInstance();
IDirect3DSurface9* srcSurf = 0;
hr = dx.getDevice().CreateOffscreenPlainSurface( mGameMap->getCellsX(), mGameMap->getCellsY(), D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &srcSurf, NULL );
assert( SUCCEEDED(hr) );
D3DLOCKED_RECT lr;
srcSurf->LockRect( &lr, NULL, D3DLOCK_DISCARD );
const char* linePtr = (const char*)lr.pBits;
for( int y = 0; y < mGameMap->getCellsY(); ++y ) {
D3DCOLOR* p = (D3DCOLOR*)linePtr;
for( int x = 0; x < mGameMap->getCellsX(); ++x ) {
const CGameMap::SCell& cell = mGameMap->getCell(x,y);
*p = gColors.minimap[cell.color][cell.type];
++p;
}
linePtr += lr.Pitch;
}
srcSurf->UnlockRect();
// now, filter this into the texture
IDirect3DSurface9* dstSurf = 0;
hr = tex->GetSurfaceLevel( 0, &dstSurf );
assert( SUCCEEDED(hr) );
hr = D3DXLoadSurfaceFromSurface( dstSurf, NULL, NULL, srcSurf, NULL, NULL, D3DX_FILTER_BOX, 0 );
dstSurf->Release();
srcSurf->Release();
D3DXFilterTexture( tex, NULL, 0, D3DX_FILTER_BOX );
return tex;
}
示例4:
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();
}
示例5: sizeof
HRESULT CDXSurfaceDevice9::OpenShareSurface(HANDLE hShare, IUnknown **ppSurface, UINT w, UINT h, D3DFORMAT format)
{
DXGI_FORMAT DxgiFormat;
// If the format is not cross api shareable the utility function will return
// D3DFMT_UNKNOWN
if ((DxgiFormat = D3D9FormatToCrossAPIDXGI(format)) == D3DFMT_UNKNOWN)
{
return E_INVALIDARG;
}
HRESULT hr = S_OK;
IDirect3DTexture9 *pTexture = NULL;
hr = m_pDevice->CreateTexture(w, h, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &pTexture, &hShare);
if (S_OK == hr && pTexture)
{
// Store the shared handle
hr = pTexture->SetPrivateData(SharedHandleGuid, &hShare, sizeof(HANDLE), 0);
if (S_OK != hr)
hr = GetSurfaceFromTexture(pTexture, (IDirect3DSurface9 **)ppSurface);
SAFE_RELEASE(pTexture)
}
示例6: GenerateTexture
// Called by Rocket when a texture is required to be built from an internally-generated sequence of pixels.
bool GuiRenderer::GenerateTexture(Rocket::Core::TextureHandle& textureHandle, const unsigned char* source, const Rocket::Core::Vector2i& sourceDimensions)
{
// Create a Direct3DTexture9, which will be set as the texture handle. Note that we only create one surface for
// this texture; because we're rendering in a 2D context, mip-maps are not required.
IDirect3DTexture9* texture;
guiManager->getGraphicsDevice().resource->CreateTexture(sourceDimensions.x, sourceDimensions.y, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL);
// Lock the top surface and write the pixel data onto it.
D3DLOCKED_RECT lockedRect;
texture->LockRect(0, &lockedRect, 0, 0);
for (int y = 0; y < sourceDimensions.y; ++y)
{
for (int x = 0; x < sourceDimensions.x; ++x)
{
const unsigned char* sourcePixel = source + (sourceDimensions.x * 4 * y) + (x * 4);
unsigned char* destinationPixel = ((unsigned char*) lockedRect.pBits) + lockedRect.Pitch * y + x * 4;
destinationPixel[0] = sourcePixel[2];
destinationPixel[1] = sourcePixel[1];
destinationPixel[2] = sourcePixel[0];
destinationPixel[3] = sourcePixel[3];
}
}
texture->UnlockRect(0);
// Set the handle on the Rocket texture structure.
textureHandle = (Rocket::Core::TextureHandle)texture;
return true;
}
示例7: 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;
}
示例8:
void CD3D9RenderTarget::generateSurfaces()
{
for (u32 i = 0; i < Surface.size(); ++i)
{
if (!Surface[i] && Texture[i])
{
IDirect3DTexture9* currentTexture = static_cast<CD3D9Texture*>(Texture[i])->getDX9Texture();
IDirect3DSurface9* currentSurface = 0;
currentTexture->GetSurfaceLevel(0, ¤tSurface);
Surface[i] = currentSurface;
}
}
if (!DepthStencilSurface && DepthStencil)
{
IDirect3DTexture9* currentTexture = static_cast<CD3D9Texture*>(DepthStencil)->getDX9Texture();
IDirect3DSurface9* currentSurface = 0;
currentTexture->GetSurfaceLevel(0, ¤tSurface);
DepthStencilSurface = currentSurface;
}
}
示例9: findOrCreateStagingTexture
void mpRendererD3D9::updateDataTexture(void *texptr, int width, int height, const void *data, size_t data_size)
{
int psize = 16;
HRESULT hr;
IDirect3DTexture9 *tex = (IDirect3DTexture9*)texptr;
// D3D11 と違い、D3D9 では書き込みも staging texture を経由する必要がある。
IDirect3DSurface9 *surf_src = findOrCreateStagingTexture(mpDataTextureWidth, height);
if (surf_src == nullptr) { return; }
IDirect3DSurface9* surf_dst = nullptr;
hr = tex->GetSurfaceLevel(0, &surf_dst);
if (FAILED(hr)) { return; }
bool ret = false;
D3DLOCKED_RECT locked;
hr = surf_src->LockRect(&locked, nullptr, D3DLOCK_DISCARD);
if (SUCCEEDED(hr))
{
const char *rpixels = (const char*)data;
int rpitch = psize * width;
char *wpixels = (char*)locked.pBits;
int wpitch = locked.Pitch;
memcpy(wpixels, rpixels, data_size);
surf_src->UnlockRect();
hr = m_device->UpdateSurface(surf_src, nullptr, surf_dst, nullptr);
if (SUCCEEDED(hr)) {
ret = true;
}
}
surf_dst->Release();
}
示例10: getSurfTexture
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();
}
示例11: copySurfaceToTexture
bool Blit::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
{
IDirect3DTexture9 *texture = copySurfaceToTexture(source, getSurfaceRect(source));
if (!texture)
{
return false;
}
IDirect3DDevice9 *device = getDevice();
saveState();
device->SetTexture(0, texture);
device->SetRenderTarget(0, dest);
setVertexShader(SHADER_VS_STANDARD);
setPixelShader(SHADER_PS_PASSTHROUGH);
setCommonBlitState();
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
setViewport(getSurfaceRect(dest), 0, 0);
render();
texture->Release();
restoreState();
return true;
}
示例12: MFTexture_DestroyPlatformSpecific
void MFTexture_DestroyPlatformSpecific(MFTexture *pTexture)
{
MFCALLSTACK;
IDirect3DTexture9 *pTex = (IDirect3DTexture9*)pTexture->pInternalData;
pTex->Release();
}
示例13: ASSERT
// Increments refcount on surface.
// caller must Release() the returned surface
gl::Error TextureStorage9_2D::getSurfaceLevel(GLenum target,
int level,
bool dirty,
IDirect3DSurface9 **outSurface)
{
ASSERT(target == GL_TEXTURE_2D);
UNUSED_ASSERTION_VARIABLE(target);
IDirect3DBaseTexture9 *baseTexture = NULL;
gl::Error error = getBaseTexture(&baseTexture);
if (error.isError())
{
return error;
}
IDirect3DTexture9 *texture = static_cast<IDirect3DTexture9*>(baseTexture);
HRESULT result = texture->GetSurfaceLevel(level + mTopLevel, outSurface);
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{
return gl::Error(GL_OUT_OF_MEMORY, "Failed to get the surface from a texture, result: 0x%X.", result);
}
// With managed textures the driver needs to be informed of updates to the lower mipmap levels
if (level + mTopLevel != 0 && isManaged() && dirty)
{
texture->AddDirtyRect(NULL);
}
return gl::Error(GL_NO_ERROR);
}
示例14: D3D9Blit
void D3D9Blit(const IntRect& dstRect, unsigned char* src, unsigned srcStride, bool discard = false)
{
RECT d3dRect;
d3dRect.left = dstRect.left_;
d3dRect.top = dstRect.top_;
d3dRect.right = dstRect.right_;
d3dRect.bottom = dstRect.bottom_;
int level = 0;
DWORD flags = discard ? D3DLOCK_DISCARD : 0;
D3DLOCKED_RECT d3dLockedRect;
IDirect3DTexture9* object = (IDirect3DTexture9*) webTexture2D_->GetTexture2D()->GetGPUObject();
if (FAILED(object->LockRect(level, &d3dLockedRect, (flags & D3DLOCK_DISCARD) ? 0 : &d3dRect, flags)))
{
LOGERROR("WebTexture2D - Could not lock texture");
return;
}
int width = dstRect.Width();
int height = dstRect.Height();
for (int j = 0; j < height; ++j)
{
unsigned char* dst = (unsigned char*) d3dLockedRect.pBits + j * d3dLockedRect.Pitch;
memcpy(dst, src, width * 4);
src += srcStride;
}
object->UnlockRect(level);
}
示例15: LoadTexture
MGuiRendTexture* CRenderer::LoadTexture( const char_t* path, uint32* width, uint32* height )
{
CTexture* texture = NULL;
D3DSURFACE_DESC desc;
IDirect3DTexture9* data;
HRESULT hr;
// I was hoping I wouldn't have to use D3DX for this :(
hr = D3DXCreateTextureFromFileEx( d3dDevice, path, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN,
D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &data );
if ( SUCCEEDED( hr ) )
{
data->GetLevelDesc( 0, &desc );
texture = new CTexture();
texture->texture = data;
texture->width = desc.Width;
texture->height = desc.Height;
if ( width ) *width = desc.Width;
if ( height ) *height = desc.Height;
}
return (MGuiRendTexture*)texture;
}