当前位置: 首页>>代码示例>>C++>>正文


C++ D3DXCreateTextureFromFileEx函数代码示例

本文整理汇总了C++中D3DXCreateTextureFromFileEx函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXCreateTextureFromFileEx函数的具体用法?C++ D3DXCreateTextureFromFileEx怎么用?C++ D3DXCreateTextureFromFileEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了D3DXCreateTextureFromFileEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ASSERT

HRESULT GdsResTexture::vLoadResource( LPDIRECT3DDEVICE9 device )
{
	if ( device == NULL )
	{
		ASSERT( 0 );
		return false;
	}

	if ( m_strPath == L"" )
	{
		ASSERT( 0 );
		return false;
	}

	if ( SUCCEEDED( D3DXCreateTextureFromFileEx( device , m_strPath.c_str() , D3DX_DEFAULT , D3DX_DEFAULT , D3DX_DEFAULT , 0 ,
								D3DFMT_X8R8G8B8 ,
								D3DPOOL_MANAGED , 
								D3DX_DEFAULT , D3DX_DEFAULT , 0 ,
								NULL , NULL , 
								&m_pTexture
								) ) )
	{
		return true;
	}

	return false;
}
开发者ID:rodrigobmg,项目名称:choding,代码行数:27,代码来源:GdsResTexture.cpp

示例2: Device

// 생성자(로드)
CTexture::CTexture(LPDIRECT3DDEVICE9 device, wstring file, CArchiveLoader* archive)
	: Device(device), TextureW(0), TextureH(0), OriginalW(0), OriginalH(0), Texture(NULL)
{
	D3DXIMAGE_INFO info;
	if (archive) {
		ARCHIVE_ENTRY* e = archive->Find(file);
		if (e) {
			D3DXCreateTextureFromFileInMemoryEx(
				Device, e->Data, e->Size,
				D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
				0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
				D3DX_DEFAULT, D3DX_DEFAULT, 0,
				&info, NULL, &Texture);
		}
	}
	else {
		D3DXCreateTextureFromFileEx(
			device, file.c_str(),
			D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT,
			0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
			D3DX_DEFAULT, D3DX_DEFAULT, 0,
			&info, NULL, &Texture);
	}
	if (Texture) {
		D3DSURFACE_DESC desc;
		Texture->GetLevelDesc(0, &desc);
		TextureW = desc.Width;
		TextureH = desc.Height;
		OriginalW = info.Width;
		OriginalH = info.Height;
	}
}
开发者ID:codebachi,项目名称:ProjectDirectX,代码行数:33,代码来源:Texture.cpp

示例3: 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;
}
开发者ID:simonfosh,项目名称:mybilliard01,代码行数:27,代码来源:TextureDX9Imp.cpp

示例4: SAFE_RELEASE

void c3DSprite::Load( 
	const char * spritePath )
{
	SAFE_RELEASE( m_texture );

	HRESULT hr = D3DXCreateTextureFromFileEx(
		g_pD3DDevice,
		spritePath,
		D3DX_DEFAULT_NONPOW2,
		D3DX_DEFAULT_NONPOW2,
		D3DX_DEFAULT,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_FILTER_NONE,
		D3DX_DEFAULT,
		0,
		&m_imgInfo,
		NULL,
		&m_texture
	);

	if ( FAILED( hr ) )
	{
		MessageBox(
			GetFocus( ),
			( std::string( "Failed to load texture. ( " ) + spritePath + std::string( ")" ) ).c_str( ),
			"WARNING!",
			MB_OK | MB_ICONEXCLAMATION
		);
	}

	this->SetupVertices( );
	this->SetupIndices( );
}
开发者ID:deahoum,项目名称:Project-Tera,代码行数:35,代码来源:c3DSprite.cpp

示例5: strcpy_s

	int TextureManager::AddTexture(LPCSTR name)
	{
		for(int i = 0; i<textures.Top(); i++)
		{
			if( textures[i] &&  _stricmp(name,textures[i]->fileName)==0 )
				return i;
		}
			
		spriteTexture *st = new spriteTexture;
		strcpy_s(st->fileName,256,name);
		D3DXCreateTextureFromFileEx(
			DI.GetD3DDevice(),
			name,
			D3DX_DEFAULT_NONPOW2,
			D3DX_DEFAULT_NONPOW2,
			1,
			0,
			D3DFMT_UNKNOWN,
			D3DPOOL_DEFAULT,
			D3DX_DEFAULT,
			D3DX_DEFAULT,
			0,
			NULL,
			NULL,
			&(st->texture));		
		return textures.Add(st);
	}
开发者ID:ShadowDOg100,项目名称:2D-Engine,代码行数:27,代码来源:Sprites.cpp

示例6: D3DXGetImageInfoFromFile

bool Texture::init(std::string fileName, D3DCOLOR color)
{
	HRESULT result; // take a value return
	
	result = D3DXGetImageInfoFromFile(fileName.c_str(), &_infoImage);
	if (result != D3D_OK)
	{
		_texture = NULL;
		return false;
	}
	// create a new Texture by loading bitmap image file
	result = D3DXCreateTextureFromFileEx(
		_d3ddv, // directx Device
		fileName.c_str(), // bitmap file
		_infoImage.Width, //bitmap image width
		_infoImage.Height, //bitmap image Height
		1,
		D3DPOOL_DEFAULT, // type of the surface
		D3DFMT_UNKNOWN, //surface format
		D3DPOOL_DEFAULT, // memory class for the texture
		D3DX_DEFAULT, //image filter
		D3DX_DEFAULT, //mip filter
		color, // color key for transparency
		&_infoImage,//bitmap file information
		NULL, //color palette
		&_texture //destination Texture
		);
	if (result != D3D_OK)
	{
		_texture = NULL;
		return false;
	}
	return  true;
}
开发者ID:d3ru,项目名称:hsjdgal-sdw,代码行数:34,代码来源:Texture.cpp

示例7: ZeroMemory

//-------------------------------------------------------------------------------------
//빌보드 스프라이트 객체 생성
HRESULT BillBoard::InitSprite(){
	if(FAILED(D3DXCreateSprite(BillRender->g_pd3dDevice, &m_pd3dSprite)))
	{
		return E_FAIL;
	}
	D3DXIMAGE_INFO ImageInfo;
	ZeroMemory(&ImageInfo,sizeof(D3DXIMAGE_INFO));
	
	// 너비와 높이를 디폴트 값을 사용하면 왜곡이 일어나므로 이 부분을 주의하시길..
	D3DXCreateTextureFromFileEx
		(
			BillRender->g_pd3dDevice,"..\\..\\Data\\Books.xml",D3DX_DEFAULT,  //임시 books.xml 은 비트맵파일
			D3DX_DEFAULT,
			1,  // 밉맵을 생성하지 않습니다.
			D3DPOOL_DEFAULT,
			D3DFMT_UNKNOWN,
            D3DPOOL_MANAGED,
			D3DX_DEFAULT,
			D3DX_DEFAULT,
			D3DCOLOR_ARGB(0xFF, 255, 0, 255), // 컬러키
            &ImageInfo,
            NULL,
            &m_pTex
		);

	
return S_OK;
}
开发者ID:kaoraswoo,项目名称:HappyEngine,代码行数:30,代码来源:BillBoard.cpp

示例8: D3DXCreateTextureFromFileEx

LPDIRECT3DTEXTURE9 CDXMetadataLoader::CreateTextureFromFile(const std::wstring &srcFile, FLOAT *pWidth, FLOAT *pHeight)
{
    D3DXIMAGE_INFO srcImageInfo;
    LPDIRECT3DTEXTURE9 pTexture = NULL;
    CSGMSystem *pSystem = CSGMSystem::Instance();
    CDXGUIInterface *pDXGUI = dynamic_cast<CDXGUIInterface*>(pSystem->GUIInterface());
    D3DXCreateTextureFromFileEx(
        pDXGUI->D3DDevice(),
        srcFile.data(),
        D3DX_DEFAULT,D3DX_DEFAULT,D3DX_DEFAULT,
        0,
        D3DFMT_UNKNOWN,
        D3DPOOL_MANAGED,
        D3DX_DEFAULT,
        D3DX_DEFAULT,
        0,
        &srcImageInfo,
        NULL,
        &pTexture);

    if(pWidth)
    {
        *pWidth  = static_cast<FLOAT>(srcImageInfo.Width);
    }

    if(pHeight)
    {
        *pHeight = static_cast<FLOAT>(srcImageInfo.Height);
    }
    return pTexture;
}
开发者ID:httpmail,项目名称:sgm_engine,代码行数:31,代码来源:dxmetadataloader.cpp

示例9: FrkTexture

FrkTexture* FrkContent::LoadTexture(string path)
{
	this->m_hMytexture = new FrkTexture();
	LPDIRECT3DTEXTURE9 texture = NULL;
	D3DXIMAGE_INFO info;
	HRESULT hr;
	ZeroMemory(&info, sizeof(info));
	//l?y thông tin v? hình ?nh
	hr = D3DXGetImageInfoFromFile(path.c_str(), &info);
	if (hr != D3D_OK)
		return NULL;
	//t?o texture
	hr = D3DXCreateTextureFromFileEx(this->m_hGame->GetDevice(),
		path.c_str(),
		info.Width,
		info.Height,
		1,
		D3DUSAGE_DYNAMIC,
		D3DFMT_UNKNOWN,// t? ??ng ch?n format phù h?p
		D3DPOOL_DEFAULT, //Ch?n b? nh? ?? l?u t? ??ng
		D3DX_DEFAULT,//Ch?n tham s? m?c ??nh
		D3DX_DEFAULT,//Ch?n tham s? m?c ??nh
		D3DCOLOR_XRGB(255, 255, 255),
		&info,//thông tin hình ?nh
		NULL,
		&texture);

	if (hr != D3D_OK)
		return 0;
	this->m_hMytexture->SetImage(texture);
	this->m_hMytexture->SetHeight(info.Height);
	this->m_hMytexture->SetWidth(info.Width);
	return m_hMytexture;
}
开发者ID:hotkutepro,项目名称:Game-DirectX9,代码行数:34,代码来源:FrkContent.cpp

示例10: LoadTexture

	bool LoadTexture(std::string filename, Texture *te, D3DCOLOR transcolor) {
		LPDIRECT3DTEXTURE9 texture = NULL;

		D3DXIMAGE_INFO info;
		HRESULT result = D3DXGetImageInfoFromFile(filename.c_str(), &info);
		if(result != D3D_OK) {
			return false;
		}

		result = D3DXCreateTextureFromFileEx(device, filename.c_str(), info.Width,
																				 info.Height, 1, D3DPOOL_DEFAULT, D3DFMT_UNKNOWN, 
																				 D3DPOOL_DEFAULT, D3DX_DEFAULT,
																				 D3DX_DEFAULT, transcolor, &info, NULL, &texture);

		if(result != D3D_OK) {
			return false;
		}

		textureList.push_back(texture);

		te->height = info.Height;
		te->width = info.Width;
		te->textureIndex = textureList.size() - 1;
		te->imageLoaded = true;
		te->color = 0xffffffff;

		return true;
	}
开发者ID:gejben,项目名称:Pathfinding,代码行数:28,代码来源:Graphics.cpp

示例11: CPanel

CSkillWnd::CSkillWnd()
{
   m_pPanel=new CPanel();
   m_pPanel->UpdateVertices(768,64);
   
   m_xLock.bLock=false;

   m_Rect.left=128;
   m_Rect.top=670;
   m_Rect.right=128+768;
   m_Rect.bottom=670+64;

   m_pItemBtn[0]=new CItemBtn(128+48+48,670+16);
   m_pItemBtn[0]->LoadSkill(1);
   m_pItemBtn[1]=new CItemBtn(128+48+48+48,686);
   m_pItemBtn[1]->LoadSkill(2);

   for(int i=2;i<12;i++)
   {
	   m_pItemBtn[i]=new CItemBtn(128+48*i+48+48,670+16);
	   m_pItemBtn[i]->LoadItem(0);	   
   }
 //  D3DXCreateTextureFromFileEx(g_pGame->GetDevice(),"UI\\skillbar_bg.bmp", 0, 0, 1, 0,D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_NONE,D3DX_DEFAULT, D3DCOLOR_XRGB(0,0,0), NULL, NULL, &m_pTexture);
   D3DXCreateTextureFromFileEx(g_pGame->GetDevice(), "UI\\skillbar_bg.bmp", 
	   D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, 	D3DFMT_UNKNOWN,
	   D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT,D3DCOLOR_XRGB(0,0,0), NULL, NULL, &m_pTexture);

   //14 14 14 1 1 1
}
开发者ID:wang35666,项目名称:3dgame,代码行数:29,代码来源:SkillWnd.cpp

示例12: Initialize

bool Sprite::Initialize(LPDIRECT3DDEVICE9 device, std::string file, UINT width, UINT height){

	this->width = width;
	this->height = height;

	if(!SUCCEEDED(D3DXCreateTextureFromFileEx(
		device,
		file.c_str(),
		width,
		height,
		D3DX_DEFAULT, 
		0, 
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED, 
		D3DX_DEFAULT, 
		D3DX_DEFAULT, 
		0, 
		NULL, 
		NULL, 
		&tex))){

			std::string s = "There was an issue creating the texture. Make sure the requested image is available. Requested image: " + file;
			MessageBox(NULL, s.c_str(), NULL, NULL);
			return(false);
	}

	if(!SUCCEEDED(D3DXCreateSprite(device, &sprite))){

		MessageBox(NULL, "There was an issue creating the sprite.", NULL, MB_OK);
	}

	initialized = true;

	return true;
}
开发者ID:jmlong94,项目名称:ContraClone,代码行数:35,代码来源:Sprite.cpp

示例13: LoadSprite

	bool LoadSprite(std::string filename, Texture &texture, D3DCOLOR transcolor) {
		LPDIRECT3DTEXTURE9 d9texture = NULL;

		D3DXIMAGE_INFO info;
		HRESULT result = D3DXGetImageInfoFromFile(filename.c_str(), &info);
		if(result != D3D_OK) {
			return false;
		}

		result = D3DXCreateTextureFromFileEx(device, filename.c_str(), info.Width,
																				 info.Height, 1, D3DPOOL_DEFAULT, 
																				 D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, 
																				 D3DX_DEFAULT,D3DX_DEFAULT,
																				 transcolor, &info, NULL, &d9texture);

		if(result != D3D_OK) {
			return false;
		}

		textureList.push_back(d9texture);

		//ts up parameters in sprite for successfull load and for being a 
		//single-frame sprite that will not be animated
		texture.height = info.Height;
		texture.width = info.Width;
		texture.textureIndex = textureList.size() - 1;
		texture.imageLoaded = true;

		return true;
	}
开发者ID:gejben,项目名称:Pathfinding,代码行数:30,代码来源:Graphics.cpp

示例14: traceIn

D3DTexture::D3DTexture(D3DSystem *curSystem, CTSTR lpFile, D3DXIMAGE_INFO &imageInfo, BOOL bBuildMipMaps)
{
    traceIn(D3DTexture::D3DTexture(2));

    DWORD dwMipLevels; 
    
    if(bBuildMipMaps)
    {
        switch(imageInfo.ImageFileFormat)
        {
            case D3DXIFF_DDS:
                dwMipLevels = D3DX_FROM_FILE;
                break;

            default:
                dwMipLevels = D3DX_DEFAULT;
        }
    }
    else
        dwMipLevels = 1;

    d3d = curSystem;

    bHasMipMaps = bBuildMipMaps;
    bNeedsBlending = 0;
    mipLevel = 0;
    dwFormat = -1;
    switch(imageInfo.Format)
    {
        case D3DFMT_DXT1:       dwFormat = GS_DXT1; break;
        case D3DFMT_DXT3:       dwFormat = GS_DXT3; break;
        case D3DFMT_DXT5:       dwFormat = GS_DXT5; break;
        case D3DFMT_R8G8B8:     dwFormat = GS_RGB;  break;
        case D3DFMT_A8R8G8B8:   dwFormat = GS_RGBA;
    }

    bDynamic = FALSE;
    dwTexType = D3DTEXTURE_STANDARD_BUFFER;

    DWORD dwDefaultSize = bBuildMipMaps ? D3DX_DEFAULT : D3DX_DEFAULT_NONPOW2;

    //D3DXCreateTextureFromFile(d3d->d3dDevice, lpFile, &d3dTex);

    if(!SUCCEEDED(D3DXCreateTextureFromFileEx(d3d->d3dDevice,
                                   lpFile,
                                   dwDefaultSize, dwDefaultSize,
                                   dwMipLevels,
                                   0, D3DFMT_FROM_FILE, D3DPOOL_MANAGED,
                                   D3DX_FILTER_NONE, D3DX_DEFAULT, 
                                   0, NULL, NULL, &GetTex())))
        ErrOut(TEXT("Could not load file %s"), lpFile);

    D3DSURFACE_DESC sDesc;
    GetTex()->GetLevelDesc(0, &sDesc);

    texWidth = sDesc.Width;
    texHeight = sDesc.Height;

    traceOut;
}
开发者ID:alanzw,项目名称:JimEngine,代码行数:60,代码来源:D3DTexture.cpp

示例15: D3DXGetImageInfoFromFile

// Get texture
LPDIRECT3DTEXTURE9 CTexture::GetTexture(string _filename)
{
	HRESULT result;
	
	// Get image from file
	result = D3DXGetImageInfoFromFile(_filename.c_str(), &m_info);
	if (FAILED(result))
	{
		return NULL;
	}
	
	// Create texture from file >>Ex
	result = D3DXCreateTextureFromFileEx(
		m_pd3ddevice, //device
		_filename.c_str(), //file name
		m_info.Width,  //width of image
		m_info.Height, //height of image
		1, // 
		D3DPOOL_DEFAULT, //
		D3DFMT_UNKNOWN,	 //format
		D3DPOOL_DEFAULT, //
		D3DX_DEFAULT, 
		D3DX_DEFAULT,
		D3DCOLOR_XRGB(250,100,100), // color key
		&m_info, //info image
		NULL,
		&m_texture); //texture

	if (FAILED(result))
	{
		return NULL; // FAILED is declared in WinError.h
	}
	//
	return m_texture;
}
开发者ID:doanhtdpl,项目名称:mario-uit,代码行数:36,代码来源:Texture.cpp


注:本文中的D3DXCreateTextureFromFileEx函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。