本文整理汇总了C++中D3DXCreateTexture函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXCreateTexture函数的具体用法?C++ D3DXCreateTexture怎么用?C++ D3DXCreateTexture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D3DXCreateTexture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Texture_Create
HTEXTURE CALL HGE_Impl::Texture_Create(int width, int height)
{
LPDIRECT3DTEXTURE8 pTex;
#ifdef UNDER_CE
int w, h;
for(w = 256; w < width; w <<= 1);
for(h = 2; h < height; h <<= 1);
if( FAILED( D3DXCreateTexture( pD3DDevice, w, h,
1, // Mip levels
D3DMUSAGE_DYNAMIC | D3DMUSAGE_LOCKABLE, // Usage
D3DFMT_A8R8G8B8, // Format
D3DMPOOL_VIDEOMEM, // Memory pool
&pTex ) ) )
#else
if( FAILED( D3DXCreateTexture( pD3DDevice, width, height,
1, // Mip levels
0, // Usage
D3DFMT_A8R8G8B8, // Format
D3DPOOL_MANAGED, // Memory pool
&pTex ) ) )
#endif
{
_PostError("Can't create texture");
return NULL;
}
return (HTEXTURE)pTex;
}
示例2: _MGL_DEBUGLOG
// 生成
void CMglTexture::Create( int x, int y, BOOL bRenderTarget )
{
_MGL_DEBUGLOG( "+ CMglTexture::Create()" );
InitCheck(); // 初期化チェック
// 二回目以降の呼び出しを考慮し一端Release
Release();
if ( x <= 0 ) x = m_myudg->GetDispX();
if ( y <= 0 ) y = m_myudg->GetDispY();
/*m_nBmpSizeX = x;
m_nBmpSizeY = y;*/
// 2008/06/28 m_imgInfoも設定してあ・げ・る。
m_imgInfo.Width = x;
m_imgInfo.Height = y;
/*int i;
ZeroMemory( m_vertices, sizeof(MYU_VERTEX)*4 );*/
// m_myudg->backBufferDesc.Format
if ( bRenderTarget == TRUE ) {
MyuAssert( D3DXCreateTexture( d3d, x, y, D3DX_DEFAULT, D3DUSAGE_RENDERTARGET, m_myudg->GetFormat(), D3DPOOL_DEFAULT, &m_pTexture ), D3D_OK,
"CMglTexture::Create() D3DXCreateTexture(VRAM)に失敗" );
}
else {
MyuAssert( D3DXCreateTexture( d3d, x, y, D3DX_DEFAULT, 0, m_myudg->GetFormat(), D3DPOOL_MANAGED, &m_pTexture ), D3D_OK,
"CMglTexture::Create() D3DXCreateTexture(SYSMEM)に失敗" );
}
// 記憶しておく
m_bRenderTarget = bRenderTarget;
/*
//SetGradation();
// テクスチャのサーフェスを取得する
MyuAssert( m_pTexture->GetSurfaceLevel(0, &m_pSurface), D3D_OK,
"CMglTexture::Create() GetSurfaceLevel()に失敗" );
// スプライト作成
MyuAssert( D3DXCreateSprite( d3d, &this->m_pSprite ), D3D_OK,
"CMglTexture::Init D3DXCreateSprite()に失敗" );
// クリアする
//Clear();
createFlg = TRUE;
*/
// SetRenderとかで必要なのでサーフェス取得しておく
_GetSurface();
// 2008/06/30 なんでクリアしないんだろうかー?
//Clear();
Clear(0); // 0にしないとカラーキー+白に勝手にされてしまう・・・
_MGL_DEBUGLOG( "- CMglTexture::Create()" );
}
示例3: D3DXCreateTexture
void TransitionCircleScan::doAfterSetScene()
{
D3DXCreateTexture(Graphics::getInstance()->getDevice(), SCWIDTH, SCHEIGHT, D3DX_DEFAULT,
D3DUSAGE_RENDERTARGET, D3DFMT_A8B8G8R8, D3DPOOL_DEFAULT, &texture0);
D3DXCreateTexture(Graphics::getInstance()->getDevice(), SCWIDTH, SCHEIGHT, D3DX_DEFAULT,
D3DUSAGE_RENDERTARGET, D3DFMT_A8B8G8R8, D3DPOOL_DEFAULT, &texture1);
Graphics::getInstance()->isAllowPresent = false;
IDirect3DSurface9 *surface, *backsurface;
this->sceneDest->render();
texture1->GetSurfaceLevel(0, &surface);
Graphics::getInstance()->getDevice()->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backsurface);
D3DXLoadSurfaceFromSurface(surface, NULL, NULL, backsurface, NULL, NULL, D3DX_FILTER_NONE, 0);
surface->Release();
surface = nullptr;
this->sceneSource->render();
texture0->GetSurfaceLevel(0, &surface);
D3DXLoadSurfaceFromSurface(surface, NULL, NULL, backsurface, NULL, NULL, D3DX_FILTER_NONE, 0);
surface->Release();
Graphics::getInstance()->isAllowPresent = true;
}
示例4: m_rt1
Bloom::Bloom()
: m_rt1(0), m_rt2(0), m_fx(0)
{
f32 width = gEngine.device->getWidth();
f32 height = gEngine.device->getHeight();
if(FAILED(D3DXCreateTexture(gEngine.device->getDev(), width/2, height/2, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_rt1))
|| FAILED(D3DXCreateTexture(gEngine.device->getDev(), width/2, height/2, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_rt2)))
{
gEngine.kernel->log->prnEx(LT_ERROR, "Bloom", "Creating textures failed");
return;
}
VertexTransformedTextured* data;
gEngine.device->getDev()->CreateVertexBuffer(4 * sizeof(VertexTransformedTextured), D3DUSAGE_WRITEONLY, VertexTransformedTextured_FVF,
D3DPOOL_MANAGED, &m_vbHalf, 0);
m_vbHalf->Lock(0, 0, (void**)&data, 0);
data[0].p = D3DXVECTOR4(-0.5f, height/2-0.5f, 0.0f, 1.0f);
data[0].u = 0.0f;
data[0].v = 1.0f;
data[1].p = D3DXVECTOR4(width/2-0.5f, height/2-0.5f, 0.0f, 1.0f);
data[1].u = 1.0f;
data[1].v = 1.0f;
data[2].p = D3DXVECTOR4(-0.5f, -0.5f, 0.0f, 1.0f);
data[2].u = 0.0f;
data[2].v = 0.0f;
data[3].p = D3DXVECTOR4(width/2-0.5f, -0.5f, 0.0f, 1.0f);
data[3].u = 1.0f;
data[3].v = 0.0f;
m_vbHalf->Unlock();
m_fx = gEngine.shaderMgr->load("Bloom.fx");
}
示例5: MessageBox
HRESULT CShimmer::Init(void)
{
Window* window = Window::Instance();
LPDIRECT3DDEVICE9 Device = window->Device();
//シェーダーを作成
LPD3DXBUFFER pError = NULL;
if (FAILED(D3DXCreateEffectFromFile(Device,"data/shaders/ShimmerShader.fx",NULL,NULL,D3DXSHADER_SKIPVALIDATION,NULL,&Effect,&pError)))
{
MessageBox(nullptr,"陽炎シェーダーの生成に失敗しました","ERROR",MB_OK | MB_ICONERROR);
OutputDebugStringA((LPCSTR)pError->GetBufferPointer());
pError->Release();
pError = nullptr;
return E_FAIL;
}
//陽炎マップ用テクスチャを作成、サーフェイスにセット
D3DXCreateTexture(Device,(UINT)window->WindowSize().x,(UINT)window->WindowSize().y,1,D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&Texture);
Texture->GetSurfaceLevel(0,&Surface);
for (int cnt = 0;cnt < 2;cnt++)
{
D3DXCreateTexture(Device,(UINT)window->WindowSize().x,(UINT)window->WindowSize().y,1,D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&BlurTex[cnt]);
BlurTex[cnt]->GetSurfaceLevel(0,&Blur[cnt]);
}
//結果用テクスチャを作成、サーフェイスにセット
D3DXCreateTexture(Device,(UINT)window->WindowSize().x,(UINT)window->WindowSize().y,1,D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&Result);
Result->GetSurfaceLevel(0,&ResultSurface);
D3DXMATRIX Projection = D3DXMATRIX(
2.0f,0,0,0,
0,-2.0f,0,0,
0,0,1.0f,0,
0,0,0,1.0f);
Effect->SetMatrix("Projection",&Projection);
D3DXVECTOR2 texel = D3DXVECTOR2(1.0f / window->WindowSize().x,1.0f / window->WindowSize().y);
float U[5];
float V[5];
for (int cnt = 0;cnt < 5;cnt++)
{
U[cnt] = texel.x * (cnt + 1);
V[cnt] = texel.y * (cnt + 1);
}
Effect->SetFloatArray("TexelU",U,5);
Effect->SetFloatArray("TexelV",V,5);
for (int cnt = 0;cnt < PARAM_MAX;cnt++)
{
Param[cnt] = Effect->GetParameterByName(NULL,ParamName[cnt]);
}
Effect->SetTechnique("Shimmer");
return S_OK;
}
示例6: D3DXCreateTextureFromFileEx
bool TextureDX9Imp::acquireResource()
{
if( NULL != textureDX9_ ) return true;
LPDIRECT3DTEXTURE9 newTexDX9;
if( isFromFile() )
{
const HRESULT hr = D3DXCreateTextureFromFileEx( getD3D9Device(), filename_.c_str(),
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0,
D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
0, NULL, NULL, & newTexDX9 );
RETURN_FALSE_IF_FAILED( hr, L"TextureDX9Imp::acquireResource" );
}
else
{
const HRESULT hr = D3DXCreateTexture( getD3D9Device(),
requiredWidth_, requiredHeight_, requiredMipLevels_, requiredUsage_,
requiredFormat_, requiredPool_, & newTexDX9 );
RETURN_FALSE_IF_FAILED( hr, L"TextureDX9Imp::acquireResource" );
}
textureDX9_ = IDirect3DTexture9Ptr( newTexDX9, ComReleaser< IDirect3DTexture9 >() );
MY_FOR_EACH( Surfaces, iter, surfaces_ )
acquireSurface( iter->level );
return true;
}
示例7: MFTexture_CreatePlatformSpecific
// interface functions
void MFTexture_CreatePlatformSpecific(MFTexture *pTexture, bool generateMipChain)
{
MFCALLSTACK;
HRESULT hr;
MFTextureTemplateData *pTemplate = pTexture->pTemplateData;
// create texture
D3DFORMAT platformFormat = (D3DFORMAT)MFTexture_GetPlatformFormatID(pTemplate->imageFormat, MFDD_D3D9);
hr = D3DXCreateTexture(pd3dDevice, pTemplate->pSurfaces[0].width, pTemplate->pSurfaces[0].height, generateMipChain ? 0 : 1, 0, platformFormat, D3DPOOL_MANAGED, (IDirect3DTexture9**)&pTexture->pInternalData);
MFDebug_Assert(hr != D3DERR_NOTAVAILABLE, MFStr("LoadTexture failed: D3DERR_NOTAVAILABLE, 0x%08X", hr));
MFDebug_Assert(hr != D3DERR_OUTOFVIDEOMEMORY, MFStr("LoadTexture failed: D3DERR_OUTOFVIDEOMEMORY, 0x%08X", hr));
MFDebug_Assert(hr != D3DERR_INVALIDCALL, MFStr("LoadTexture failed: D3DERR_INVALIDCALL, 0x%08X", hr));
MFDebug_Assert(hr != D3DXERR_INVALIDDATA, MFStr("LoadTexture failed: D3DXERR_INVALIDDATA, 0x%08X", hr));
MFDebug_Assert(hr == D3D_OK, MFStr("Failed to create texture '%s'.", pTexture->name));
IDirect3DTexture9 *pTex = (IDirect3DTexture9*)pTexture->pInternalData;
// copy image data
D3DLOCKED_RECT rect;
pTex->LockRect(0, &rect, NULL, 0);
MFCopyMemory(rect.pBits, pTemplate->pSurfaces[0].pImageData, pTemplate->pSurfaces[0].bufferLength);
pTex->UnlockRect(0);
// filter mip levels
if(generateMipChain)
D3DXFilterTexture(pTex, NULL, 0, D3DX_DEFAULT);
}
示例8: 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);
}
示例9: NIASSERT
ENGINE_NAMESPACE_BEGIN_ENGINE
//-------------------------------------------------------------------------------------------------
sdMemoryTexture::sdMemoryTexture(uint uiWidth, uint uiHeight, uint uiLevel, D3DFORMAT eFormat)
{
// 获取渲染设备
NiDX9Renderer* spRenderer = NiDX9Renderer::GetRenderer();
NIASSERT(spRenderer);
LPDIRECT3DDEVICE9 spD3DDevice = spRenderer->GetD3DDevice();
NIASSERT(spD3DDevice);
//
m_uiWidth = uiWidth;
m_uiHeight = uiHeight;
m_uiLevel = uiLevel;
m_eFormat = eFormat;
// 创建D3D纹理
HRESULT hr = D3DXCreateTexture(spD3DDevice,
m_uiWidth, m_uiHeight, uiLevel,
0,
eFormat,
D3DPOOL_SYSTEMMEM,
&m_spD3DTexture);
if (FAILED(hr))
{
NIASSERT(0);
return;
}
m_spD3DTexture->AddRef();
// 创建GB纹理对象
m_spTexture = spRenderer->CreateNiTextureFromD3DTexture(m_spD3DTexture);
NIASSERT(m_spTexture);
}
示例10: D3DXCreateTexture
void SPTexture::CreateRenderTarget( int setWidth, int setHeight, D3DXCOLOR setColor )
{
SPGameManager::GetSingleton()->GetGame()->LockDrawing();
// Create texture from memory.
HRESULT hr = D3DXCreateTexture(
SPDevice::GetSingleton()->GetD3DDevice(),
setWidth, setHeight,
1, D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT,
&texture);
if (FAILED(hr))
{
texture = NULL;
return;
}
height = setHeight;
width = setWidth;
format = D3DFMT_A8R8G8B8;
isRenderTarget = true;
backgroundColor = setColor;
//Fill(0x00000000);
SPGameManager::GetSingleton()->GetGame()->UnlockDrawing();
}
示例11: D3DXCreateTexture
void cTexBuf::Create( int nWidthSize, int nHeightSize )
{
m_nWidth = nWidthSize;
m_nHeight = nHeightSize;
D3DXCreateTexture( DXUTGetD3D9Device()
, m_nWidth
, m_nHeight
, 1
, D3DUSAGE_RENDERTARGET
, D3DFMT_A8R8G8B8
, D3DPOOL_DEFAULT
, &m_pTexture );
m_pTexture->GetSurfaceLevel( 0, &m_pRenderTarget );
DXUTGetD3D9Device()->GetRenderTarget( 0, &m_pOriRenderTarget );
DXUTGetD3D9Device()->GetDepthStencilSurface( &m_pOriDepthSurface );
D3DSURFACE_DESC dsc;
m_pOriDepthSurface->GetDesc( &dsc );
DXUTGetD3D9Device()->CreateDepthStencilSurface(
m_nWidth
, m_nHeight
, dsc.Format
, D3DMULTISAMPLE_NONE
, 0
, true
, &m_pDepthSurface
, NULL );
}
示例12: dx9vid_init
BOOL dx9vid_init()
{
d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
D3DCAPS9 d3dCaps;
d3d->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps );
d3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &d3ddev );
// Create the screen texture
D3DXCreateTexture( d3ddev, 256, 256, D3DX_FILTER_NONE, D3DUSAGE_DYNAMIC, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &g_screenTex);
// Create the screen sprite (ignores 3d perspective)
D3DXCreateSprite( d3ddev, &g_screenSprite );
// Scale our matrix to match the screen
D3DXMatrixIdentity( &pTransform );
spritePos = D3DXVECTOR2( 0.f, 0.f );
rotCenter = D3DXVECTOR2( 0.f, 0.f);
D3DXVECTOR2 vscale = D3DXVECTOR2( float(3.0f), float(3.0f));
D3DXMatrixTransformation2D( &pTransform, NULL, 0.0f, &vscale, &rotCenter, 0.f, &spritePos );
g_screenSprite->SetTransform(&pTransform);
return TRUE;
}
示例13: Progress
void TERRAIN::CalculateAlphaMaps()
{
Progress("Creating Alpha Map", 0.0f);
//Clear old alpha maps
if(m_pAlphaMap != NULL)
m_pAlphaMap->Release();
//Create new alpha map
D3DXCreateTexture(m_pDevice, 128, 128, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pAlphaMap);
//Lock the texture
D3DLOCKED_RECT sRect;
m_pAlphaMap->LockRect(0, &sRect, NULL, NULL);
BYTE *bytes = (BYTE*)sRect.pBits;
memset(bytes, 0, 128*sRect.Pitch); //Clear texture to black
for(int i=0;i<(int)m_diffuseMaps.size();i++)
for(int y=0;y<sRect.Pitch / 4;y++)
for(int x=0;x<sRect.Pitch / 4;x++)
{
int terrain_x = (int)(m_size.x * (x / (float)(sRect.Pitch / 4.0f)));
int terrain_y = (int)(m_size.y * (y / (float)(sRect.Pitch / 4.0f)));
MAPTILE *tile = GetTile(terrain_x, terrain_y);
if(tile != NULL && tile->m_type == i)
bytes[y * sRect.Pitch + x * 4 + i] = 255;
}
//Unlock the texture
m_pAlphaMap->UnlockRect(0);
//D3DXSaveTextureToFile("alpha.bmp", D3DXIFF_BMP, m_pAlphaMap, NULL);
}
示例14: assert
////////////////////////////////////////////////////////////////
//
// CWebBrowserItem::CreateUnderlyingData
//
//
//
////////////////////////////////////////////////////////////////
void CWebBrowserItem::CreateUnderlyingData()
{
assert(!m_pD3DRenderTargetSurface);
assert(!m_pD3DTexture);
D3DXCreateTexture(m_pDevice, m_uiSizeX, m_uiSizeY, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, (IDirect3DTexture9**)&m_pD3DTexture);
// Check texture created
if (!m_pD3DTexture)
return;
// D3DXCreateTexture sets width and height to 1 if the argument value was 0
// See: https://docs.microsoft.com/en-us/windows/desktop/direct3d9/d3dxcreatetexture
if (m_uiSizeX == 0)
m_uiSizeX = 1;
if (m_uiSizeY == 0)
m_uiSizeY = 1;
// Get the render target surface here for convenience
((IDirect3DTexture9*)m_pD3DTexture)->GetSurfaceLevel(0, &m_pD3DRenderTargetSurface);
// Update surface size, although it probably will be unchanged | Todo: Remove this
D3DSURFACE_DESC desc;
m_pD3DRenderTargetSurface->GetDesc(&desc);
m_uiSurfaceSizeX = desc.Width;
m_uiSurfaceSizeY = desc.Height;
m_iMemoryKBUsed = CRenderItemManager::CalcD3DResourceMemoryKBUsage(m_pD3DRenderTargetSurface);
}
示例15: Texture2D
RenderTargetTexture2D::RenderTargetTexture2D(GraphicsDevice* graphicsDevice, int width, int height)
: Texture2D(graphicsDevice, width, height, width, height, A8R8G8B8Pixels),
d3dSurface(nullptr)
{
BBAssert(GetGraphicsDevice()->GetD3DDevice() != nullptr);
IDirect3DTexture9* newD3DTexture = nullptr;
HRESULT result = D3DXCreateTexture(GetGraphicsDevice()->GetD3DDevice(), width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &newD3DTexture);
if (result == D3D_OK)
{
D3DSURFACE_DESC surfaceDesc;
if (newD3DTexture->GetLevelDesc(0, &surfaceDesc) == D3D_OK)
Setup(newD3DTexture, width, height, static_cast<int>(surfaceDesc.Width), static_cast<int>(surfaceDesc.Height), A8R8G8B8Pixels);
else
Setup(newD3DTexture, width, height, width, height, A8R8G8B8Pixels);
newD3DTexture->GetSurfaceLevel(0, &d3dSurface);
IncreaseRevision();
SetStatus(CompletedStatus);
}
else
{
IncreaseRevision();
SetStatus(FaultStatus);
}
}