本文整理汇总了C++中IDirect3DDevice9::CreateVolumeTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DDevice9::CreateVolumeTexture方法的具体用法?C++ IDirect3DDevice9::CreateVolumeTexture怎么用?C++ IDirect3DDevice9::CreateVolumeTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DDevice9
的用法示例。
在下文中一共展示了IDirect3DDevice9::CreateVolumeTexture方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void D3D9Texture::createHardwareResource()
{
IDirect3DDevice9* dev = mFatherManager->getAs<D3D9TextureManager>()
->getD3DResourceFactory()->getMainDevice();
// release created resources.
releaseHardwareResource();
D3DFORMAT texFormat = (mFormat == PF_Unknown) ? D3DFMT_A8R8G8B8 : D3D9Translator::getD3DFormat(mFormat);
uint32 mipmap = mMipMapCount == MIPMAP_MAXCOUNT ? 0 : mMipMapCount + 1;
if (mType == TT_1D || mType == TT_2D)
{
dev->CreateTexture(mWidth, mHeight, mipmap, 0,
texFormat, D3DPOOL_MANAGED, &mTexture.p2DTexture, NULL);
mTexture.pBaseTexture = mTexture.p2DTexture;
}
else if (mType == TT_3D)
{
dev->CreateVolumeTexture(mWidth, mHeight, mDepth, mipmap, 0,
texFormat, D3DPOOL_MANAGED, &mTexture.p3DTexture, NULL);
mTexture.pBaseTexture = mTexture.p3DTexture;
}
else
{
dev-> CreateCubeTexture(mWidth, mipmap, 0,
texFormat, D3DPOOL_MANAGED, &mTexture.pCubeTexture, NULL);
mTexture.pBaseTexture = mTexture.pCubeTexture;
}
createSurfaceList();
mTextureConstant = DGpuTextureConstantPtr(new D3D9GpuTextureConstant(mTexture.pBaseTexture));
}
示例2: Release
bool Texture3D::Create()
{
Release();
if (!graphics_ || !width_ || !height_)
return false;
if (graphics_->IsDeviceLost())
{
URHO3D_LOGWARNING("Texture creation while device is lost");
return true;
}
IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
HRESULT hr = device->CreateVolumeTexture(
(UINT)width_,
(UINT)height_,
(UINT)depth_,
requestedLevels_,
usage_,
(D3DFORMAT)format_,
(D3DPOOL)pool_,
(IDirect3DVolumeTexture9**)&object_,
0);
if (FAILED(hr))
{
URHO3D_SAFE_RELEASE(object_);
URHO3D_LOGD3DERROR("Could not create texture", hr);
return false;
}
levels_ = ((IDirect3DVolumeTexture9*)object_)->GetLevelCount();
return true;
}
示例3: Texture
TextureDX9::TextureDX9(
const PixelFormat texFormat, const TexType texType,
const unsigned int sizeX, const unsigned int sizeY, const unsigned int sizeZ,
const unsigned int mipmapLevelCount, const BufferUsage usage)
: Texture(texFormat, texType, sizeX, sizeY, sizeZ, mipmapLevelCount, usage)
, m_pTexture(nullptr)
, m_pTempBuffer(nullptr)
, m_nRowPitch(0)
, m_nDepthPitch(0)
{
IDirect3DDevice9* device = RendererDX9::GetInstance()->GetDevice();
D3DPOOL pool;
if (GetUsage() == BU_TEXTURE)
pool = D3DPOOL_MANAGED;
else
pool = D3DPOOL_DEFAULT;
HRESULT hr;
DWORD usageFlags;
switch (GetTextureType())
{
case TT_1D:
hr = device->CreateTexture(
GetWidth(), 1u, GetMipmapLevelCount(),
BufferUsageDX9[m_eBufferUsage], TextureFormatDX9[m_eTexFormat],
pool, (IDirect3DTexture9**)&m_pTexture, 0);
break;
case TT_2D:
usageFlags = BufferUsageDX9[m_eBufferUsage];
if (m_eBufferUsage == BU_RENDERTAGET && mipmapLevelCount == 0)
{
// automatic mipmap generation for RTs
usageFlags |= D3DUSAGE_AUTOGENMIPMAP;
m_bAutogenMipmaps = true;
}
hr = device->CreateTexture(
GetWidth(), GetHeight(), m_bAutogenMipmaps ? 0 : GetMipmapLevelCount(),
usageFlags, TextureFormatDX9[m_eTexFormat],
pool, (IDirect3DTexture9**)&m_pTexture, 0);
break;
case TT_3D:
hr = device->CreateVolumeTexture(
GetWidth(), GetHeight(), GetDepth(), GetMipmapLevelCount(),
BufferUsageDX9[m_eBufferUsage], TextureFormatDX9[m_eTexFormat],
pool, (IDirect3DVolumeTexture9**)&m_pTexture, 0);
break;
case TT_CUBE:
hr = device->CreateCubeTexture(
GetWidth(), GetMipmapLevelCount(),
BufferUsageDX9[m_eBufferUsage], TextureFormatDX9[m_eTexFormat],
pool, (IDirect3DCubeTexture9**)&m_pTexture, 0);
}
assert(SUCCEEDED(hr));
}
示例4: assertion
//----------------------------------------------------------------------------
PdrTexture3D::PdrTexture3D (Renderer* renderer, const Texture3D* texture)
{
IDirect3DDevice9* device = renderer->mData->mDevice;
int numLevels = texture->GetNumLevels();
HRESULT hr = device->CreateVolumeTexture((UINT)texture->GetWidth(),
(UINT)texture->GetHeight(), (UINT)texture->GetThickness(),
(UINT)numLevels, gDX9BufferUsage[texture->GetUsage()],
gDX9TextureFormat[texture->GetFormat()], D3DPOOL_MANAGED,
&mTexture, 0);
WM5_UNUSED(hr);
assertion(hr == D3D_OK, "Failed to create 3D texture: %s\n",
DXGetErrorString(hr));
for (int level = 0; level < numLevels; ++level)
{
void* data = Lock(level, Buffer::BL_WRITE_ONLY);
memcpy(data, texture->GetData(level),
texture->GetNumLevelBytes(level));
Unlock(level);
}
}
示例5: Release
bool Texture3D::Create()
{
Release();
if (!graphics_ || !width_ || !height_)
return false;
if (graphics_->IsDeviceLost())
{
URHO3D_LOGWARNING("Texture creation while device is lost");
return true;
}
unsigned pool = usage_ > TEXTURE_STATIC ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
unsigned d3dUsage = usage_ == TEXTURE_DYNAMIC ? D3DUSAGE_DYNAMIC : 0;
IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
HRESULT hr = device->CreateVolumeTexture(
(UINT)width_,
(UINT)height_,
(UINT)depth_,
requestedLevels_,
d3dUsage,
(D3DFORMAT)format_,
(D3DPOOL)pool,
(IDirect3DVolumeTexture9**)&object_,
nullptr);
if (FAILED(hr))
{
URHO3D_LOGD3DERROR("Could not create texture", hr);
URHO3D_SAFE_RELEASE(object_.ptr_);
return false;
}
levels_ = ((IDirect3DVolumeTexture9*)object_.ptr_)->GetLevelCount();
return true;
}
示例6: GetMipmapLevelCount
void TextureDX9::Bind()
{
IDirect3DDevice9* device = RendererDX9::GetInstance()->GetDevice();
D3DPOOL pool;
if (GetUsage() == BU_TEXTURE)
pool = D3DPOOL_MANAGED;
else
pool = D3DPOOL_DEFAULT;
HRESULT hr;
DWORD usageFlags;
switch (GetTextureType())
{
case TT_1D:
hr = device->CreateTexture(
GetWidth(), 1u, GetMipmapLevelCount(),
BufferUsageDX9[m_eBufferUsage], TextureFormatDX9[m_eTexFormat],
pool, (IDirect3DTexture9**)&m_pTexture, 0);
break;
case TT_2D:
usageFlags = BufferUsageDX9[m_eBufferUsage];
if (m_eBufferUsage == BU_RENDERTAGET && m_bAutogenMipmaps == true)
{
// automatic mipmap generation for RTs
usageFlags |= D3DUSAGE_AUTOGENMIPMAP;
}
hr = device->CreateTexture(
GetWidth(), GetHeight(), m_bAutogenMipmaps ? 0 : GetMipmapLevelCount(),
usageFlags, TextureFormatDX9[m_eTexFormat],
pool, (IDirect3DTexture9**)&m_pTexture, 0);
break;
case TT_3D:
hr = device->CreateVolumeTexture(
GetWidth(), GetHeight(), GetDepth(), GetMipmapLevelCount(),
BufferUsageDX9[m_eBufferUsage], TextureFormatDX9[m_eTexFormat],
pool, (IDirect3DVolumeTexture9**)&m_pTexture, 0);
break;
case TT_CUBE:
hr = device->CreateCubeTexture(
GetWidth(), GetMipmapLevelCount(),
BufferUsageDX9[m_eBufferUsage], TextureFormatDX9[m_eTexFormat],
pool, (IDirect3DCubeTexture9**)&m_pTexture, 0);
}
assert(SUCCEEDED(hr));
switch (GetTextureType())
{
case TT_1D:
case TT_2D:
case TT_3D:
for (unsigned int mip = 0; mip < GetMipmapLevelCount(); mip++)
{
if (Lock(mip, BL_WRITE_ONLY))
{
Update();
Unlock();
}
else
if (m_eBufferUsage != BU_RENDERTAGET && m_eBufferUsage != BU_DEPTHSTENCIL)
assert(false);
}
break;
case TT_CUBE:
for (unsigned int face = 0; face < 6; face++)
{
for (unsigned int mip = 0; mip < GetMipmapLevelCount(); mip++)
{
if (Lock(face, mip, BL_WRITE_ONLY))
{
Update();
Unlock();
}
else
assert(false);
}
}
}
}