本文整理汇总了C++中IDirect3DTexture9::GetLevelCount方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DTexture9::GetLevelCount方法的具体用法?C++ IDirect3DTexture9::GetLevelCount怎么用?C++ IDirect3DTexture9::GetLevelCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DTexture9
的用法示例。
在下文中一共展示了IDirect3DTexture9::GetLevelCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2:
TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchain)
: TextureStorage9(renderer, D3DUSAGE_RENDERTARGET)
{
IDirect3DTexture9 *surfaceTexture = swapchain->getOffscreenTexture();
mTexture = surfaceTexture;
mMipLevels = surfaceTexture->GetLevelCount();
mInternalFormat = swapchain->getRenderTargetInternalFormat();
D3DSURFACE_DESC surfaceDesc;
surfaceTexture->GetLevelDesc(0, &surfaceDesc);
mTextureWidth = surfaceDesc.Width;
mTextureHeight = surfaceDesc.Height;
mTextureFormat = surfaceDesc.Format;
mRenderTargets.resize(mMipLevels, nullptr);
}
示例3: initializeSerials
TextureStorage9_2D::TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchain)
: TextureStorage9(renderer, D3DUSAGE_RENDERTARGET)
{
IDirect3DTexture9 *surfaceTexture = swapchain->getOffscreenTexture();
mTexture = surfaceTexture;
mMipLevels = surfaceTexture->GetLevelCount();
mInternalFormat = swapchain->GetBackBufferInternalFormat();
D3DSURFACE_DESC surfaceDesc;
surfaceTexture->GetLevelDesc(0, &surfaceDesc);
mTextureWidth = surfaceDesc.Width;
mTextureHeight = surfaceDesc.Height;
mTextureFormat = surfaceDesc.Format;
mRenderTarget = NULL;
initializeSerials(1, 1);
}
示例4: switch
//.........这里部分代码省略.........
for(u32 r = 0; r < desc.Height && textureFormat == D3DFMT_DXT1; r++)
{
u32* pixels = (u32*) (((u8*)lockedRect.pBits) + lockedRect.Pitch * r);
for(u32 c = 0; c < desc.Width; c++)
{
u32 masked = pixels[c] & 0xFF000000;
if(masked != 0xFF000000)
{
alpha = true;
}
if(masked != 0xFF000000 && masked != 0x00000000)
{
textureFormat = D3DFMT_DXT5;
break;
}
}
}
tempTexture->UnlockRect(0);
tempTexture->Release();
}
int compressionRatio;
switch ( textureFormat )
{
case D3DFMT_DXT1:
{
if (alpha)
{
compressionRatio = 8;
}
else
{
compressionRatio = 6;
}
break;
}
case D3DFMT_DXT5:
{
compressionRatio = 4;
break;
}
default:
{
compressionRatio = 1;
HELIUM_BREAK();
break;
}
}
if ( D3DXCreateTextureFromFileEx( device,
file.c_str(),
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DX_DEFAULT,
NULL,
textureFormat,
pool,
D3DX_DEFAULT,
D3DX_DEFAULT,
NULL,
&sourceInfo,
NULL,
&texture ) == D3D_OK )
{
texture->SetAutoGenFilterType( D3DTEXF_ANISOTROPIC );
if ( textureSize )
{
*textureSize = 0;
for(u32 i = 0; i < texture->GetLevelCount(); i++)
{
D3DSURFACE_DESC desc;
texture->GetLevelDesc(i, &desc);
*textureSize += desc.Width * desc.Height * 4 / compressionRatio;
}
}
}
else
{
Log::Warning( TXT( "Unable to create texture from file '%s'\n" ), file.c_str() );
}
}
else
{
Log::Warning( TXT( "File '%s' does not exist\n" ), file.c_str() );
}
}
if ( hasAlpha )
{
*hasAlpha = alpha;
}
return texture;
}