コード例 #1
0
ファイル: GdsResTexture.cpp プロジェクト: rodrigobmg/choding
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;
}
コード例 #2
0
ファイル: Texture.cpp プロジェクト: codebachi/ProjectDirectX
// 생성자(로드)
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;
	}
}
コード例 #3
0
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;
}
コード例 #4
0
ファイル: c3DSprite.cpp プロジェクト: deahoum/Project-Tera
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( );
}
コード例 #5
0
ファイル: Sprites.cpp プロジェクト: ShadowDOg100/2D-Engine
	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);
	}
コード例 #6
0
ファイル: Texture.cpp プロジェクト: d3ru/hsjdgal-sdw
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;
}
コード例 #7
0
ファイル: BillBoard.cpp プロジェクト: kaoraswoo/HappyEngine
//-------------------------------------------------------------------------------------
//빌보드 스프라이트 객체 생성
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;
}
コード例 #8
0
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;
}
コード例 #9
0
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;
}
コード例 #10
0
ファイル: Graphics.cpp プロジェクト: gejben/Pathfinding
	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;
	}
コード例 #11
0
ファイル: SkillWnd.cpp プロジェクト: wang35666/3dgame
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
}
コード例 #12
0
ファイル: Sprite.cpp プロジェクト: jmlong94/ContraClone
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;
}
コード例 #13
0
ファイル: Graphics.cpp プロジェクト: gejben/Pathfinding
	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;
	}
コード例 #14
0
ファイル: D3DTexture.cpp プロジェクト: alanzw/JimEngine
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;
}
コード例 #15
0
ファイル: Texture.cpp プロジェクト: doanhtdpl/mario-uit
// 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;
}
コード例 #16
0
/// \param effectDef XML tag containing the effect definition
ParticleEffect::ParticleEffect(TiXmlElement *effectDef)
{
    // assign defaults
    m_nTotalParticleCount = 0;
    m_bCycleParticles = true;
    m_bIsDead = false;
    m_IsDying = false;
    m_nLiveParticleCount = 0;
    m_fEmitPartial = 1.0f; // start with at least one particle
    m_vecGravity = Vector3::kZeroVector;
    m_vecPosition = Vector3::kZeroVector;
    m_txtParticleTexture = NULL;
    m_UpdateFunc.clear();
    m_InitFunc.clear();

    m_fPILife = 1.0f;
    m_fPISpeed = 100.0f;
    m_fPIDragValue = 0.0f;
    m_PIFadeIn = 0.0f;
    m_PIFadeOut = 1.0f;
    m_PIFadeMax = 1.0f;
    m_PIRotationSpeed = 0.0f;
    m_PIRotationStopTime = 0.0f;
    m_distFunc = NULL;

    // default emit rate is all at once (or at least all in the first .01 secs)
    m_nEmitRate = m_nTotalParticleCount * 100;
    m_sort = false;

    m_vertBuffer = NULL;
    m_indexBuffer = NULL;

    // get system data
    effectDef->Attribute("particleCount", &m_nTotalParticleCount);
    const char *filename = effectDef->Attribute("textureName");

    // initialize effect properties from the xml tag
    initProperties(effectDef);

    // allocate memory needed
    m_Particles = new Particle[m_nTotalParticleCount];
    m_drawOrder = new int[m_nTotalParticleCount];

    initParticles();

    // create vertex and index buffers, and initialize index buffer. We can
    // create the index buffer as static since it doesn't change values; this
    // will increase performance a little.
    m_vertBuffer = new VertexLBuffer(m_nTotalParticleCount * 4, true);
    m_indexBuffer = new IndexBuffer(m_nTotalParticleCount * 2);
    initIndexBuffer();

    // this should be replaced with the renderer version of loading a texture
    gDirectoryManager.setDirectory(eDirectoryTextures);
    D3DXIMAGE_INFO structImageInfo; //image information
    HRESULT hres=D3DXCreateTextureFromFileEx(pD3DDevice, filename,
                 0,0,1,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,D3DX_FILTER_NONE,
                 D3DX_DEFAULT,0,&structImageInfo,NULL, &m_txtParticleTexture);
}
コード例 #17
0
ファイル: image_lua.cpp プロジェクト: Amorph/imageprocesstool
int l_Image_Load( lua_State* L )
{
	D3DXIMAGE_INFO imgInfo;
	const char* fileName = lua_tostring( L, 1 );

	bool dxtCompression = false;
	D3DFORMAT d3dfmt = D3DFMT_UNKNOWN;
	//check for dds format
	{
		if( _strcmpi( "dds", fileName + strlen( fileName ) - 3 ) == 0 )
		{
			DDSHEAD header;
			FILE* f;
			if(fopen_s( &f, fileName, "rb" ) == 0)
			{
				if( fread( &header, sizeof(header), 1, f ) == 1 )
				{
					if( strncmp( (const char*)header.Signature, "DDS ", 4 ) == 0 && ( header.FourCC == D3DFMT_DXT1 || header.FourCC == D3DFMT_DXT3 || header.FourCC == D3DFMT_DXT5 ) )
					{
						d3dfmt = D3DFMT_A8R8G8B8;
					}
				}
				fclose(f);
			}
		}
	}

	LPDIRECT3DTEXTURE9 texture; 

	HRESULT hr = D3DXCreateTextureFromFileEx( g_pd3dDevice, fileName, D3DX_DEFAULT_NONPOW2,  D3DX_DEFAULT_NONPOW2, D3DX_FROM_FILE, 0, d3dfmt, D3DPOOL_SCRATCH, D3DX_DEFAULT, D3DX_DEFAULT, 0, &imgInfo, 0, &texture );

	if( FAILED( hr ) )
	{
		return 0;
	}

	ImageData* imgData = createImage();
	imgData->width = imgInfo.Width;
	imgData->height = imgInfo.Height;
	imgData->format = getFormatByD3D( imgInfo.Format );
	imgData->imgData = malloc( imgData->width * imgData->height * imgData->format->bytesPerPixel );

	D3DLOCKED_RECT rect;
	texture->LockRect(0, &rect, 0, 0 );

	memcpy( imgData->imgData, rect.pBits, imgData->width * imgData->height * imgData->format->bytesPerPixel );

	texture->UnlockRect( 0 );

	texture->Release();

	//lua_pushlightuserdata( L, imgData );

	ImageData** luaData = lua_pushimage( L );

	*luaData = imgData;

	return 1;
}
コード例 #18
0
HRESULT EVERYMODULE::CreateTextureFromFile(LPSTR Filename, D3DFORMAT Format /* = D3DFMT_A8R8G8B8 */)
{
	if(TextureNum==MYD3D_MODULETEXTURENUM) return E_FAIL;
	if(FAILED(D3DXCreateTextureFromFileEx(d3ddevice, Filename, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_0, Format, D3DPOOL_DEFAULT, D3DX_FILTER_LINEAR, D3DX_FILTER_LINEAR, 0xffffffff, NULL, NULL, &(Texture[TextureNum]))))
		return E_FAIL;
	else TextureNum++;
	return S_OK;
}
コード例 #19
0
ファイル: D3DTextureItem.cpp プロジェクト: DimondTheCat/xray
void D3DTexture::Bind( LPDIRECT3DDEVICE9 D3D)
{
	// Get the filename
	MString filename;
	MFnDependencyNode( MayaTexture).findPlug( "fileTextureName").getValue( filename);
	if( filename.length())
		D3DXCreateTextureFromFileEx( D3D, filename.asChar(), 0, 0, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &HwTexture);
}
コード例 #20
0
////////////////////////////////////////////////////////////////
//
// CFileTextureItem::CreateUnderlyingData
//
// From file
//
////////////////////////////////////////////////////////////////
void CFileTextureItem::CreateUnderlyingData(const SString& strFilename, bool bMipMaps, uint uiSizeX, uint uiSizeY, ERenderFormat format)
{
    assert(!m_pD3DTexture);

    D3DXIMAGE_INFO imageInfo;
    if (FAILED(D3DXGetImageInfoFromFile(strFilename, &imageInfo)))
        return;

    D3DFORMAT D3DFormat = (D3DFORMAT)format;
    int       iMipMaps = bMipMaps ? D3DX_DEFAULT : 1;
    if (uiSizeX != D3DX_DEFAULT)
        imageInfo.Width = uiSizeX;
    if (uiSizeY != D3DX_DEFAULT)
        imageInfo.Height = uiSizeY;

    m_uiSizeX = imageInfo.Width;
    m_uiSizeY = imageInfo.Height;
    m_uiSurfaceSizeX = imageInfo.Width;
    m_uiSurfaceSizeY = imageInfo.Height;

    if (imageInfo.ResourceType == D3DRTYPE_VOLUMETEXTURE)
    {
        // It's a volume texture!
        if (FAILED(D3DXCreateVolumeTextureFromFileEx(m_pDevice, strFilename, uiSizeX, uiSizeY, D3DX_DEFAULT, iMipMaps, 0, D3DFormat, D3DPOOL_MANAGED,
                                                     D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, (IDirect3DVolumeTexture9**)&m_pD3DTexture)))
            return;
    }
    else if (imageInfo.ResourceType == D3DRTYPE_CUBETEXTURE)
    {
        // It's a cubemap texture!
        if (FAILED(D3DXCreateCubeTextureFromFileEx(m_pDevice, strFilename, uiSizeX, iMipMaps, 0, D3DFormat, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0,
                                                   NULL, NULL, (IDirect3DCubeTexture9**)&m_pD3DTexture)))
            return;
    }
    else
    {
        // It's none of the above!

        // If size not specified, try to use exact image size to prevent blurring
        if (uiSizeX == D3DX_DEFAULT)
            uiSizeX = D3DX_DEFAULT_NONPOW2;
        if (uiSizeY == D3DX_DEFAULT)
            uiSizeY = D3DX_DEFAULT_NONPOW2;

        if (FAILED(D3DXCreateTextureFromFileEx(m_pDevice, strFilename, uiSizeX, uiSizeY, iMipMaps, 0, D3DFormat, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0,
                                               NULL, NULL, (IDirect3DTexture9**)&m_pD3DTexture)))
            return;

        // Update surface size if it's a normal texture
        D3DSURFACE_DESC desc;
        ((IDirect3DTexture9*)m_pD3DTexture)->GetLevelDesc(0, &desc);
        m_uiSurfaceSizeX = desc.Width;
        m_uiSurfaceSizeY = desc.Height;
    }

    // Calc memory usage
    m_iMemoryKBUsed = CRenderItemManager::CalcD3DResourceMemoryKBUsage(m_pD3DTexture);
}
コード例 #21
0
//-----------------------------------------------------------------------------
// Name: ResourceDatabase::AddTexture2D
//-----------------------------------------------------------------------------
Texture2D* ResourceDatabase::AddTexture2D(  CONST CHAR* strFilename, 
                                            DWORD Width, DWORD Height,
                                            D3DFORMAT Format, DWORD Filter,
                                            DWORD MipLevels, DWORD MipFilter )
{
    WCHAR wszConvertedFilename[ _MAX_PATH ];
    Texture2D *pTexture = NULL;
    Resource *pResource = NULL;

    const CHAR* strFileOnly = strrchr( strFilename, '\\' );
    if( strFileOnly == NULL )
    {
        strFileOnly = strFilename;
    }
    else
    {
        strFileOnly++;
    }
    
    MultiByteToWideChar( CP_ACP, 0, strFileOnly, strlen( strFileOnly ) + 1, wszConvertedFilename, MAX_PATH );
    _wcslwr_s( wszConvertedFilename );

    pResource = FindResource( wszConvertedFilename );
    if ( pResource )
    {
        // $ERROR: report error of duplicate name
        assert( pResource->IsDerivedFrom( Texture2D::TypeID ) );
        return (Texture2D*)pResource;            
    }

    LPDIRECT3DTEXTURE9 pD3DTexture;

    Format = D3DFMT_DXT5;
    MipLevels = 0;

    HRESULT hr = D3DXCreateTextureFromFileEx( g_pd3dDevice, 
                                              strFilename, 
                                              Width, Height, MipLevels,
                                              0,
                                              Format,
                                              D3DPOOL_MANAGED,//D3DPOOL_DEFAULT,
                                              Filter, MipFilter, 0, NULL, NULL, 
                                              &pD3DTexture );
    if ( FAILED( hr ) )
    {
        ATG::DebugSpew( "Could not load 2D texture %s.\n", strFilename );
        return NULL;
    }
    
    pTexture = new Texture2D;
    pTexture->SetName( wszConvertedFilename );
    pTexture->SetD3DTexture( pD3DTexture );
    pD3DTexture->Release();

    AddResource( pTexture );
    return pTexture;
}
コード例 #22
0
ファイル: D3D9Texture.cpp プロジェクト: kbinani/dxrip
void D3D9Texture::LoadFromFile(const String &filename, D3DFORMAT format)
{
    FreeMemory();
    D3DValidate(D3DXCreateTextureFromFileEx(_Device, filename.CString(), 0, 0, 0, 0, format, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &_Texture), "D3DXCreateTextureFromFileEx");
    _Width = 1;
    _Height = 1;
    _Format = format;
    _RenderTarget = false;
}
コード例 #23
0
ファイル: DialogManager.cpp プロジェクト: oksangman/Ant
//--------------------------------------------------------------------------------------
HRESULT DialogResourceManager::CreateTexture9( UINT iTexture )
{
	HRESULT hr = S_OK;

	TextureNode* pTextureNode = m_TextureCache.at( iTexture );


	D3DXIMAGE_INFO info;

	if( !pTextureNode->bFileSource )
	{
		if( pTextureNode->nResourceID == 0xFFFF && pTextureNode->hResourceModule == (HMODULE) 0xFFFF )
		{
			// Refactoring : DXUT 독립적으로 교체
			hr = CreateGUITextureFromInternalArray9( m_pd3d9Device, &pTextureNode->pTexture9, &info );
			if( FAILED(hr) )
				return hr;
		}
		else
		{
			LPCWSTR pID = pTextureNode->nResourceID ? (LPCWSTR)(size_t)pTextureNode->nResourceID : pTextureNode->strFilename;

			// Create texture from resource
			hr =  D3DXCreateTextureFromResourceEx( m_pd3d9Device, pTextureNode->hResourceModule, pID, D3DX_DEFAULT, D3DX_DEFAULT, 
				1, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, 
				D3DX_DEFAULT, D3DX_DEFAULT, 0, 
				&info, NULL, &pTextureNode->pTexture9 );
			if( FAILED(hr) )
				return hr;
		}
	}
	else
	{
		// Make sure there's a texture to create
		if( pTextureNode->strFilename[0] == 0 )
			return S_OK;

		// Create texture from file
		hr =  D3DXCreateTextureFromFileEx( m_pd3d9Device, pTextureNode->strFilename, D3DX_DEFAULT, D3DX_DEFAULT, 
			1, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, 
			D3DX_DEFAULT, D3DX_DEFAULT, 0, 
			&info, NULL, &pTextureNode->pTexture9 );
		if( FAILED(hr) )
		{
			wchar_t szTemp[50];
			swprintf(szTemp, L"TextureCreateFromFile Failed\n %s", pTextureNode->strFilename);
			MessageBox(NULL, szTemp, L"ResourceManager error", 0);
			return hr;
		}
	}

	// Store dimensions
	pTextureNode->dwWidth = info.Width;
	pTextureNode->dwHeight = info.Height;

	return S_OK;
}
コード例 #24
0
ファイル: Material.cpp プロジェクト: ericrrichards/fps
//-----------------------------------------------------------------------------
// The material class constructor.
//-----------------------------------------------------------------------------
Material::Material( char *name, char *path ) : Resource< Material >( name, path )
{
	D3DXIMAGE_INFO info;

	// Load the script for this material.
	Script *script = new Script( name, path );

	// Check if the material's texture has transparency.
	if( script->GetColourData( "transparency" )->a == 0.0f )
	{
		// Load the texture without transparency.
		D3DXCreateTextureFromFileEx( g_engine->GetDevice(), script->GetStringData( "texture" ), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE, D3DX_FILTER_TRIANGLE, 0, &info, NULL, &m_texture );
	}
	else
	{
		// Load the texture using a transparency colour value.
		D3DCOLORVALUE *colour = script->GetColourData( "transparency" );
		D3DCOLOR transparency = D3DCOLOR_COLORVALUE( colour->r, colour->g, colour->b, colour->a );
		D3DXCreateTextureFromFileEx( g_engine->GetDevice(), script->GetStringData( "texture" ), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE, D3DX_FILTER_TRIANGLE, transparency, &info, NULL, &m_texture );
	}

	// Store the width and height of the texture.
	m_width = info.Width;
	m_height = info.Height;

	// Set the material's lighting properties.
	m_lighting.Diffuse = *script->GetColourData( "diffuse" );
	m_lighting.Ambient = *script->GetColourData( "ambient" );
	m_lighting.Specular = *script->GetColourData( "specular" );
	m_lighting.Emissive = *script->GetColourData( "emissive" );
	m_lighting.Power = *script->GetFloatData( "power" );

	// Set the ignore face flag.
	m_ignoreFace = *script->GetBoolData( "ignore_face" );

	// Set the ignore fog flag.
	m_ignoreFog = *script->GetBoolData( "ignore_fog" );

	// Set the ignore ray flag.
	m_ignoreRay = *script->GetBoolData( "ignore_ray" );

	// Destory the material's script.
	SAFE_DELETE( script );
}
コード例 #25
0
HRESULT RSManager::redirectD3DXCreateTextureFromFileInMemoryEx(LPDIRECT3DDEVICE9 pDevice, LPCVOID pSrcData, UINT SrcDataSize, UINT Width, UINT Height, UINT MipLevels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, DWORD Filter, DWORD MipFilter, D3DCOLOR ColorKey, D3DXIMAGE_INFO* pSrcInfo, PALETTEENTRY* pPalette, LPDIRECT3DTEXTURE9* ppTexture) {
	if(Settings::get().getEnableTextureOverride()) {
		UINT32 hash = SuperFastHash((char*)const_cast<void*>(pSrcData), SrcDataSize);
		SDLOG(4, "Trying texture override size: %8u, hash: %8x\n", SrcDataSize, hash);
		
		char buffer[128];
		sprintf_s(buffer, "dsfix/tex_override/%08x.png", hash);
		if(fileExists(buffer)) {
			SDLOG(3, "Texture override (png)! hash: %8x\n", SrcDataSize, hash);
			return D3DXCreateTextureFromFileEx(pDevice, buffer, D3DX_DEFAULT, D3DX_DEFAULT, MipLevels, Usage, Format, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);
		}
		sprintf_s(buffer, "dsfix/tex_override/%08x.dds", hash);
		if(fileExists(buffer)) {
			SDLOG(3, "Texture override (dds)! hash: %8x\n", SrcDataSize, hash);
			return D3DXCreateTextureFromFileEx(pDevice, buffer, D3DX_DEFAULT, D3DX_DEFAULT, MipLevels, Usage, Format, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);
		}
	}
	return TrueD3DXCreateTextureFromFileInMemoryEx(pDevice, pSrcData, SrcDataSize, Width, Height, MipLevels, Usage, Format, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);
}
コード例 #26
0
ファイル: Quad.cpp プロジェクト: syuta1852/Rensyu
HRESULT Quad::Load(char* fileName)
{
	//「テクスチャオブジェクト」の作成
	if (FAILED(D3DXCreateTextureFromFileEx(g_pDevice, fileName, 0, 0, 0, 0, D3DFMT_UNKNOWN,
		D3DPOOL_DEFAULT, D3DX_FILTER_NONE, D3DX_DEFAULT, NULL, NULL, NULL, &pTexture)))
	{
		MessageBox(0, "テクスチャの作成に失敗しました", fileName, MB_OK);
		return E_FAIL;
	}
}
コード例 #27
0
void DX9GraphicTexture::SetTextureFromFile(GraphicSystem *graphicSystem, std::string filePath)
{
	DX9GraphicSystem *dx9GraphicSystem = dynamic_cast<DX9GraphicSystem *>(graphicSystem);

	D3DXCreateTextureFromFileEx(dx9GraphicSystem->GetDevice(), filePath.c_str(), D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2,
		1, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_FILTER_NONE,
		NULL, NULL, NULL, &texture);

	if (texture == nullptr)
		Error::Throw<SystemError>("Can't Create GraphicTexture : " + filePath);
}
コード例 #28
0
void Geometry::LoadTexture(LPDIRECT3DDEVICE9 device,
                           const std::string& filename, 
                           int dimensions, int miplevels)
{
    if(FAILED(D3DXCreateTextureFromFileEx(device, filename.c_str(), dimensions, 
        dimensions, miplevels, 0, D3DFMT_FROM_FILE, D3DPOOL_DEFAULT, D3DX_DEFAULT, 
        D3DX_DEFAULT, 0, 0, 0, &m_texture)))
    {
        ShowMessageBox("Cannot create texture " + filename);
    }
}
コード例 #29
0
ファイル: DXImage.cpp プロジェクト: kodack64/koma2011
bool DXImage::Load(const char* filename,Color4f c){
	if(lpd3ddev==NULL)return false;
	HRESULT hr = D3DXCreateTextureFromFileEx(lpd3ddev,filename,D3DX_DEFAULT,D3DX_DEFAULT,D3DX_DEFAULT,0,D3DFMT_A8R8G8B8
		,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,D3DCOLOR_RGBA(c.red,c.green,c.blue,c.alpha),NULL,NULL,&myTexture);
	if(FAILED(hr)){
		Logger::Println("[GraphicAPI] Load Fail : %s",filename);
		return false;
	}
	myTexture->GetLevelDesc(0,&desc);
	return true;
}
コード例 #30
0
// setup creates the api texture from the texture file
//
void APITexture::setup(int width, int height, int key) {

    // create a texture COM object from the texture file
    //
	if (manager && file && FAILED(D3DXCreateTextureFromFileEx(d3dd, file, 
     width, height, D3DX_DEFAULT, NULL, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 
     D3DX_DEFAULT, D3DX_DEFAULT, key, NULL, NULL, &tex))) {
		error(L"APITexture::11 Failed to create texture COM object from file");
		tex = NULL;
	}
}