本文整理汇总了C++中D3DXCreateTextureFromFile函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXCreateTextureFromFile函数的具体用法?C++ D3DXCreateTextureFromFile怎么用?C++ D3DXCreateTextureFromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D3DXCreateTextureFromFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitFade
//===============================================================
// ポリゴン初期化
//===============================================================
void InitFade(){
LPDIRECT3DDEVICE9 pDevice = GetDevice();
//頂点情報の作成
MakeVertexFade(pDevice);
//PlaySound(SOUND_LABEL_BGM001);
g_nPatternAnime = 0; ////0から数えて
g_bFadeChange = false;
g_eFade = FADE_NONE;
g_tFade.nFadeAlpha = 0;
//テクスチャの読み込み
D3DXCreateTextureFromFile(pDevice, FADE_TEX_NAME, &g_pTextureFade);
g_tFade.fTexPosX = FADE_TEX_POS_X;
g_tFade.fTexPosY = FADE_TEX_POS_Y;
g_tFade.nTexSizeX = FADE_TEX_SIZE_X;
g_tFade.nTexSizeY = FADE_TEX_SIZE_Y;
g_tFade.nFadeAlpha = 0;
g_tFade.nFadeVol = FADE_VOLUME;
}
示例2: D3DXCreateTextureFromFile
void Particles::intBuffers(LPDIRECT3DDEVICE9 d3ddev){
D3DXCreateTextureFromFile(d3ddev,"white.png",&texture);
struct CUSTOMVERTEX1 t_vert[] =
{
{-.05f, .05f, 0.0f, D3DCOLOR_XRGB(255, 255, 255), 1, 0,},
{-0.05f, -.05f, 0.0f, D3DCOLOR_XRGB(255, 255, 255), 0, 0,},
{.05f, .05f, 0.0f, D3DCOLOR_XRGB(255, 255, 255), 1, 1,},
{.05f, -.05f, 0.0f, D3DCOLOR_XRGB(255, 255, 255), 0, 1,},
};
// create a vertex buffer interface called t_buffer
d3ddev->CreateVertexBuffer(4*sizeof(CUSTOMVERTEX1),
0,
CUSTOMFVF,
D3DPOOL_MANAGED,
&t_buffer,
NULL);
VOID* pVoid; // a void pointer
// lock t_buffer and load the vertices into it
t_buffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, t_vert, sizeof(t_vert));
t_buffer->Unlock();
}
示例3: Init
bool SnowParticle::Init()
{
//创建顶点数据
if (FAILED(m_device->CreateVertexBuffer(m_numSnow * sizeof(POINTVERTEX),
D3DUSAGE_POINTS | D3DUSAGE_WRITEONLY,
D3DFVF_POINTVERTEX, D3DPOOL_MANAGED,
&m_vb, 0)))
return false;
//加载纹理
std::string resoursePath = Resourse::GetResoursePath();
IDirect3DTexture9 *tex = 0;
for (std::vector<std::string>::iterator it = m_textureNames.begin();
it != m_textureNames.end();
it++)
{
if (FAILED(D3DXCreateTextureFromFile(m_device, Convert::str2Wstr(resoursePath + *it).c_str(),
&tex)))
return false;
m_snowTextures.push_back(tex);
}
for (int i = 0; i < m_numSnow; i++)
{
AddParticle();
}
return true;
}
示例4: D3DXCreateTextureFromFile
CTexture::CTexture(CDisplayDevice *pDevice, char *szFileName) {
bool bResult;
#if (RENDER == DX9)
bResult = D3DXCreateTextureFromFile(pDevice->m_pDevice, szFileName, &m_poTexture) == D3D_OK;
#endif
}
示例5: XMLParseFile
HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice )
{
HRESULT hr;
// Keep a local copy of the device
m_pd3dDevice = pd3dDevice;
// Large fonts need larger textures
//m_dwTexWidth = m_dwTexHeight = 256;
xmlNode *node = XMLParseFile("textures/font.xml");
assert(node);
int count = node->attribute("count").Asint();
m_dwSpacing = node->attribute("spacing").Asint() ;
m_dwTexWidth = node->attribute("width").Asint();
m_dwTexHeight= node->attribute("height").Asint();
String imagefile = "textures/font.png";
StringIter p(node->body);
for( int i=0;i<count;i++)
{
int c;
p >> c;
p >> m_fTexCoords[c-32][0] >> m_fTexCoords[c-32][1] >> m_fTexCoords[c-32][2] >> m_fTexCoords[c-32][3];
}
hr=D3DXCreateTextureFromFile(m_pd3dDevice,(const char*)imagefile,&m_pTexture);
LPD3DXBUFFER error;
extern String effectpath;
D3DXCreateEffectFromFile(m_pd3dDevice,effectpath + "/font.fx",NULL,NULL,0,NULL,&effect,&error) && VERIFY_RESULT;
assert(effect);
diffusemap = effect->GetParameterByName(NULL,"diffusemap");
assert(diffusemap);
effect->SetTexture(diffusemap,m_pTexture) && VERIFY_RESULT;
return S_OK;
}
示例6:
void TextureImpl_DirectX9::Load(const char *filename)
{
char *convertedFilename = ResourceManager::GetConvertedPath(filename);
LPDIRECT3DDEVICE9 device = NULL;
if (device = DrawManager::GetDeviceHandle())
{
if(D3DXCreateTextureFromFile(device, convertedFilename, &_texture) != S_OK) {
Debug::Error("[Texture] Fail to load %s...", filename);
}
}
if (!_texture)
{
MemoryAllocator::Free(convertedFilename);
return;
}
D3DSURFACE_DESC desc;
_texture->GetLevelDesc(0, &desc);
_size.width = desc.Width;
_size.height = desc.Height;
_format = desc.Format;
MemoryAllocator::Free(convertedFilename);
}
示例7: sizeof
void PointSprite::Load( const std::string _fileName )
{
HRESULT hr ;
hr = GlobalD3DDevice::m_pd3dDevice->CreateVertexBuffer( sizeof(POINTSPRITE),
D3DUSAGE_NPATCHES | D3DUSAGE_POINTS | D3DUSAGE_DYNAMIC,
D3DFVF_XYZ | D3DFVF_PSIZE | D3DFVF_DIFFUSE,
D3DPOOL_DEFAULT, &m_VB, NULL ) ;
if( !FAILED( hr ) )
{
POINTSPRITE *pV ;
hr = m_VB->Lock( sizeof( POINTSPRITE ), sizeof(POINTSPRITE),(void**)&pV,D3DLOCK_DISCARD ) ;
if( !FAILED( hr ) )
{
pV->vPos = D3DXVECTOR3(2.0f,2.0f,1.0f) ;
pV->fSize = 1.0f ;
pV->dwColor = 0xffffffff ;
}
m_VB->Unlock() ;
}
WCHAR wcBuff[ 255 ] = { 0 } ;
DXconvAnsiToWide::Change( wcBuff, _fileName.c_str(), 255 ) ;
D3DXCreateTextureFromFile( GlobalD3DDevice::m_pd3dDevice, wcBuff, &m_Texture ) ;
}
示例8: init
//初始化函数
bool PSystem:: init (IDirect3DDevice9 * device,wchar_t *texFileName)
{
_device = device;
HRESULT hr=0;
//创建顶点缓存
hr=device->CreateVertexBuffer (
_vbSize* sizeof(Particle),
D3DUSAGE_DYNAMIC|D3DUSAGE_POINTS|D3DUSAGE_WRITEONLY,
D3DFVF_XYZ|D3DFVF_DIFFUSE,
D3DPOOL_DEFAULT,
&_vb,
0
);
if(FAILED(hr))
{
::MessageBox(0, L"CreateVertexBuffer() - FAILED", L"PSystem", 0);
return false;
}
//创建纹理
hr=D3DXCreateTextureFromFile(
device,
texFileName,
&_tex);
if(FAILED(hr))
{
::MessageBox(0, L"CreateTextureFromFile - FAILED", L"PSystem", 0);
return false;
}
}
示例9: device
managed_texture2d::managed_texture2d(const boost::shared_ptr<device_services> & device,
const platform::tstring & src_file)
: device(device)
{
HRESULT r = D3DXCreateTextureFromFile(device->get(), src_file.c_str(), &texture);
check_failure(r, platform::narrow(LOCI_TSTR("Failed to load texture from file: ") + src_file).c_str(), "D3DXCreateTextureFromFile");
}
示例10: DX9Texture
Texture *DX9Render::loadTextureFromFile(const wchar_t *file)
{
DX9Texture *result = new DX9Texture();
HRESULT hr = D3DXCreateTextureFromFile(device, file, &result->texture);
if (FAILED(hr))
{
switch (hr)
{
case D3DXERR_INVALIDDATA:
{
//log() << "Texture file \"" << file << "\" does not exists" << std::endl;
break;
}
default:
{
//log() << "Failed to load texture \"" << file << "\" does not exists" << std::endl;
break;
}
}
delete result;
return NULL;
}
return result;
}
示例11: InitGeometry
/**-----------------------------------------------------------------------------
* 기하정보 초기화
*------------------------------------------------------------------------------
*/
HRESULT InitGeometry()
{
InitMatrix();
// 빌보드로 사용할 텍스처 이미지
D3DXCreateTextureFromFile( g_pd3dDevice, "tree01S.dds", &g_pTexBillboard[0] );
D3DXCreateTextureFromFile( g_pd3dDevice, "tree02S.dds", &g_pTexBillboard[1] );
D3DXCreateTextureFromFile( g_pd3dDevice, "tree35S.dds", &g_pTexBillboard[2] );
D3DXCreateTextureFromFile( g_pd3dDevice, "tex.jpg", &g_pTexBillboard[3] );
// 최초의 마우스 위치 보관
POINT pt;
GetCursorPos( &pt );
g_dwMouseX = pt.x;
g_dwMouseY = pt.y;
return S_OK;
}
示例12: InitExplosion
//=============================================================================
// 初期化処理
//=============================================================================
HRESULT InitExplosion(LPDIRECT3DDEVICE9 pDevice)
{
// 頂点情報の作成
MakeVertexExplosion(pDevice);
// テクスチャの読み込み
D3DXCreateTextureFromFile(pDevice, // デバイスへのポインタ
TEXTURE_EXPLOSION, // ファイルの名前
&g_pD3DTextureExplosion); // 読み込むメモリー
for(int nCntExplosion = 0; nCntExplosion < MAX_EXPLOSION; nCntExplosion++)
{
g_aExplosion[nCntExplosion].pos = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
g_aExplosion[nCntExplosion].rot = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
g_aExplosion[nCntExplosion].scale = D3DXVECTOR3(1.0f, 1.0f, 1.0f);
g_aExplosion[nCntExplosion].fSizeX = BULLET_SIZE_X;
g_aExplosion[nCntExplosion].fSizeY = BULLET_SIZE_Y;
g_aExplosion[nCntExplosion].nCounter = 0;
g_aExplosion[nCntExplosion].nPattern = 0;
g_aExplosion[nCntExplosion].fAlpha = 1.0f;
g_aExplosion[nCntExplosion].bUse = false;
}
return S_OK;
}
示例13: ZeroMemory
void cMainGame::Setup()
{
//폰트 생성
D3DXFONT_DESC fd;
ZeroMemory(&fd,sizeof(D3DXFONT_DESC));
fd.Height = 45;
fd.Width = 28;
fd.Weight = FW_MEDIUM;
fd.Italic = false;
fd.CharSet = DEFAULT_CHARSET;
fd.OutputPrecision = OUT_DEFAULT_PRECIS;
fd.PitchAndFamily = FF_DONTCARE;
//strcpy_s(fd.FaceName, "궁서체"); //글꼴 스타일
AddFontResource("umberto.ttf");
strcpy(fd.FaceName, "umberto");
D3DXCreateFontIndirect(g_pD3DDevice, &fd, &m_pFont);
m_pCamera = new cCamera;
m_pCamera->Setup(NULL);
m_pGrid = new cGrid;
m_pGrid->Setup(15, 1.0f);
LPDIRECT3DTEXTURE9 pTexture = NULL;
D3DXCreateTextureFromFile(g_pD3DDevice, "Batman.png", &pTexture);
cBody* pBody = new cBody;
pBody->Setup();
pBody->SetTexture(pTexture);
m_pRoot = pBody;
cHead* pHead = new cHead;
pHead->Setup();
pHead->SetTexture(pTexture);
m_pRoot->AddChild(pHead);
cLeftArm* pLeftArm = new cLeftArm;
pLeftArm->Setup();
pLeftArm->SetTexture(pTexture);
m_pRoot->AddChild(pLeftArm);
cRightArm* pRightArm = new cRightArm;
pRightArm->Setup();
pRightArm->SetTexture(pTexture);
m_pRoot->AddChild(pRightArm);
cLeftLeg* pLeftLeg = new cLeftLeg;
pLeftLeg->Setup();
pLeftLeg->SetTexture(pTexture);
m_pRoot->AddChild(pLeftLeg);
cRightLeg* pRightLeg = new cRightLeg;
pRightLeg->Setup();
pRightLeg->SetTexture(pTexture);
m_pRoot->AddChild(pRightLeg);
SAFE_RELEASE(pTexture);
SetLight();
}
示例14: Log
void CException::Init( IDirect3DDevice9* D3DDevice )
{
if ( D3DDevice )
m_D3DDevice = D3DDevice;
else
{
Log( "error: No init Explosion" );
return;
}
// создаЄм буфер вершин
if ( FAILED( m_D3DDevice->CreateVertexBuffer( m_Size * 4 * sizeof( CVertexFVF ), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &m_VertexBuffer, 0 ) ) )
Log( "error create vertex buffer Explosion" );
// создаЄм буфер индексов
if ( FAILED( m_D3DDevice->CreateIndexBuffer( m_Size * 6 * sizeof( short ), 0, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &m_IndexBuffer, 0 ) ) )
Log( "error create index buffer Explosion" );
for ( int i = 0; i < m_Size; ++i )
{
//------задаЄм случайное направление-----------------
m_Particles[i].m_Direct = D3DXVECTOR3( rand()/float(RAND_MAX)*2-1, 0, rand()/float(RAND_MAX)*2-1 );
D3DXVec3Normalize( &m_Particles[i].m_Direct, &m_Particles[i].m_Direct );
}
std::string FileName = "model\\Explosion.tga";
//------загружаем текстуру-----
if ( FAILED( D3DXCreateTextureFromFile( m_D3DDevice, FileName.c_str(), &m_TextureExp )))
Log( "error load texture Exception" );
Log( "Init Explosion" );
}
示例15: fileData
bool Terrian::LoadTerrainFromFile(const char* rawFileName,const char* textureName)
{
//读文件
std::ifstream inFile;
inFile.open(rawFileName,std::ios::binary);
//得到文件大小
inFile.seekg(0,std::ios::end);
std::vector<BYTE> fileData(inFile.tellg());
inFile.seekg(0,std::ios::beg);
inFile.read((char*)&fileData[0],fileData.size());
inFile.close();
//保存高度信息
m_HeightInfo.resize(fileData.size());
for (size_t i=0;i<fileData.size();i++)
m_HeightInfo[i]=fileData[i];
//加载纹理
HRESULT hr=D3DXCreateTextureFromFile(m_pDevice,textureName,&m_pTexture);
if (FAILED(hr))
{
PopupError("Create texture in Terrain!");
return false;
}
return true;
}