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


C++ D3DXCreateEffectFromFile函数代码示例

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


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

示例1: D3DXCreateSphere

Sky::Sky(std::string strSkyTextureFileName, float fSkyRadius)
	:m_fSkyRadius(fSkyRadius)
{
	D3DXCreateSphere(pDxDevice, m_fSkyRadius, 160, 160, &m_pSkyMesh, 0);
	D3DXCreateCubeTextureFromFile(pDxDevice, strSkyTextureFileName.c_str(), &m_pSkyTexture);

	D3DXCreateEffectFromFile(pDxDevice, "../../Resources/shaders/SkyShader.fx", 0, 0, 0, 0, &m_pEffect, 0);

	m_hEffectTechnique	= m_pEffect->GetTechniqueByName("SkyTech");
	m_hWVPMatrix		= m_pEffect->GetParameterByName(0, "WVP");
	m_hSkyTexture		= m_pEffect->GetParameterByName(0, "tex0");

	m_pEffect->SetTechnique(m_hEffectTechnique);
	m_pEffect->SetTexture(m_hSkyTexture, m_pSkyTexture);
}
开发者ID:todorzhelev,项目名称:FableWorld,代码行数:15,代码来源:Sky.cpp

示例2: D3DXCreateEffectFromFile

	void GUIBasicEffect::Initialize()
	{
		LPD3DXBUFFER pErrors = NULL;
		HRESULT hr = D3DXCreateEffectFromFile(MyApp::GetSingleton()->GetD3DDevice(), L"Content\\Effects\\GUI\\BasicEffect.fx",
			NULL, NULL, NULL, NULL, &pEffect, &pErrors);

		#if defined( _DEBUG )
			if ( FAILED( hr ) && pErrors != NULL && pErrors->GetBufferPointer() != NULL )
				MyApp::GetSingleton()->Error(strcat("Effect Compilation Error: ", (char *)pErrors->GetBufferPointer()));
		#endif 
		if( pErrors != NULL )
			pErrors->Release();

		return;
	}
开发者ID:bobxiv,项目名称:AnalizadorPulsos,代码行数:15,代码来源:GUIMaterial.cpp

示例3: LoadShader

int _stdcall LoadShader(const char* path) {
	if(GraphicsMode < 4) return -1;
	if(strstr(path, "..")) return -1;
	if(strstr(path, ":")) return -1;
	char buf[MAX_PATH];
	strcpy_s(buf, "data\\shaders\\");
	strcat_s(buf, path);
	for(DWORD d=0;d<shaders.size();d++) {
		if(!shaders[d].Effect) {
			if(FAILED(D3DXCreateEffectFromFile(d3d9Device, buf, 0, 0, 0, 0, &shaders[d].Effect, 0))) return -1;
			else return d;
		}
	}
	sShader shader=sShader();
	if(FAILED(D3DXCreateEffectFromFile(d3d9Device, buf, 0, 0, 0, 0, &shader.Effect, 0))) return -1;

	shader.Effect->SetFloatArray("rcpres", rcpres, 2);

	for(int i=1;i<128;i++) {
		char buf[MAX_PATH];
		const char* name;
		IDirect3DTexture9* tex;

		sprintf_s(buf, "texname%d", i);
		if(FAILED(shader.Effect->GetString(buf, &name))) break;
		sprintf_s(buf, "data\\art\\stex\\%s", name);
		if(FAILED(D3DXCreateTextureFromFileA(d3d9Device,buf,&tex))) continue;
		sprintf_s(buf, "tex%d", i);
		shader.Effect->SetTexture(buf, tex);
		shaderTextures.push_back(tex);
	}
	
	shader.ehTicks=shader.Effect->GetParameterByName(0, "tickcount");
	shaders.push_back(shader);
	return shaders.size()-1;
}
开发者ID:Vennor,项目名称:sfall,代码行数:36,代码来源:ddraw2.cpp

示例4: EffectCompile

HRESULT Effect::EffectCompile(){

	LPD3DXBUFFER err=NULL;
	if(FAILED(D3DXCreateEffectFromFile(GetDevice(),info.fileName.c_str(),NULL,NULL,D3DXSHADER_DEBUG,NULL,&pFX,&err))){
		// コンパイルエラーの場合はエラーを表示して終了
		if (!pFX) {
			MessageBox(
				NULL, 
				err?(LPCTSTR)err->GetBufferPointer():NULL, 
				"エフェクトファイルの読込エラー", MB_OK);
		}
		return E_FAIL;
	}
	return S_OK;
}
开发者ID:rupy,项目名称:fighting-3d-game,代码行数:15,代码来源:Effect.cpp

示例5: D3DXCreateEffectFromFile

bool CWaterRender::Setup()
{
	ID3DXBuffer *errors;
	HRESULT result = D3DXCreateEffectFromFile(g_Device,"resources/Shaders/water.fx", 0, 0, 0, 0, &m_pEffect, &errors);
	if(!CDebug::CheckForShaderErrors(errors, "CWaterRender", "water", result))
	{
		return false;
	}
	D3DXCreateTextureFromFile(g_Device,"resources/Textures/Water_NormalN.png",&tNormalN);
	D3DXCreateTextureFromFile(g_Device,"resources/Textures/Water_NormalW.png",&tNormalW);
	D3DXCreateTextureFromFile(g_Device,"resources/Textures/Waves.png",&tNormalH1);
	D3DXCreateTextureFromFile(g_Device,"resources/Textures/Foam.png",&FoamTexture);
	D3DXCreateTextureFromFile(g_Device,"resources/Textures/Foam.dds",&FoamTexture2);
	return true;
}
开发者ID:Azon099,项目名称:sa-render,代码行数:15,代码来源:CWaterRender.cpp

示例6: ShaderImport

YAMANGDXDLL_API HRESULT ShaderImport( LPCTSTR effectFile, int id )
{
	DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE | D3DXSHADER_DEBUG | D3DXSHADER_NO_PRESHADER;

	HRESULT hr = S_OK;
	hr = D3DXCreateEffectFromFile( g_D3dDevice, effectFile, NULL, NULL, dwShaderFlags, NULL, &g_Effects[id], NULL );

	if ( FAILED( hr ) )
	{
		MessageBox( NULL, L"Effect Load Failed", effectFile, MB_OK );
		return E_FAIL;
	}

	return S_OK;
}
开发者ID:NHNNEXT,项目名称:2014-01-HUDIGAME-EunJaRim,代码行数:15,代码来源:YaMangShader.cpp

示例7: D3DXCreateEffectFromFile

void noisemaker::LoadEffect(){

	char *errortext;
	LPD3DXBUFFER errors;
	// load the perlin noise effect
	D3DXCreateEffectFromFile(device, "noisemakermk2.fx", 
		NULL, NULL, 0, NULL, &anim_effect, &errors );
	if (errors != NULL){
		errortext = (char*) errors->GetBufferPointer();
		MessageBox(NULL, errortext, "Textures.exe", MB_OK);		
	}
	D3DXHANDLE hTechnique;
	anim_effect->FindNextValidTechnique(NULL, &hTechnique);    
	anim_effect->SetTechnique(hTechnique);

	// and the normalmap effect
	D3DXCreateEffectFromFile(device, "normalmapgenerator.fx", 
		NULL, NULL, 0, NULL, &normalmap_effect, &errors );
	if (errors != NULL){
		errortext = (char*) errors->GetBufferPointer();
		MessageBox(NULL, errortext, "Textures.exe", MB_OK);		
	}	
	normalmap_effect->FindNextValidTechnique(NULL, &hTechnique);    
	normalmap_effect->SetTechnique(hTechnique);

	// and the noise_octaves effect
	D3DXCreateEffectFromFile(device, "noise_octaves.fx", 
		NULL, NULL, 0, NULL, &noise_octaves_effect, &errors );
	if (errors != NULL){
		errortext = (char*) errors->GetBufferPointer();
		MessageBox(NULL, errortext, "Textures.exe", MB_OK);		
	}	
	noise_octaves_effect->FindNextValidTechnique(NULL, &hTechnique);    
	noise_octaves_effect->SetTechnique(hTechnique);

}
开发者ID:lenxyang,项目名称:sandbox_water,代码行数:36,代码来源:noisemaker.cpp

示例8: DXTRACE_ERR

//-------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: ����̽��� ���������� �ʱ�ȭ
//       �����ӹ��� ���˰� ����̽� ������ ���ѵڿ� ȣ��
//       ���⼭ Ȯ���� �޸𸮴� DeleteDeviceObjects()���� ����
//-------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
    HRESULT hr;

	// UFO�б�
	if( FAILED( hr=m_pMesh  ->Create( m_pd3dDevice, _T("ufo.x"))))
        return DXTRACE_ERR( "LoadCar", hr );
	m_pMesh->SetFVF(m_pd3dDevice, D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 );
	// �����б�
	if( FAILED( hr=m_pMeshBg->Create( m_pd3dDevice, _T("map.x"))))
        return DXTRACE_ERR( "LoadChess", hr );
        
    // �������� �ؽ�ó�� ���������� ���� �ʴ´�
	m_pMesh  ->UseMeshMaterials(FALSE);
	m_pMeshBg->UseMeshMaterials(FALSE);

	// ��Ʈ
    m_pFont->InitDeviceObjects( m_pd3dDevice );

	// ���̴� �б�
	LPD3DXBUFFER pErr;
    if( FAILED( hr = D3DXCreateEffectFromFile(
					m_pd3dDevice, "hlsl.fx", NULL, NULL, 
				D3DXSHADER_DEBUG , NULL, &m_pEffect, &pErr ) ) ){
		MessageBox( NULL, (LPCTSTR)pErr->GetBufferPointer(), "ERROR", MB_OK);
		return DXTRACE_ERR( "CreateEffectFromFile", hr );
	}
	m_hTechnique = m_pEffect->GetTechniqueByName( "TShader" );
	m_hmWVP = m_pEffect->GetParameterByName( NULL, "mWVP" );
	m_hmWLP = m_pEffect->GetParameterByName( NULL, "mWLP" );
	m_hmWLPB= m_pEffect->GetParameterByName( NULL, "mWLPB" );
	m_hvCol = m_pEffect->GetParameterByName( NULL, "vCol" );
	m_hvDir = m_pEffect->GetParameterByName( NULL, "vLightDir" );
	m_htShadowMap = m_pEffect->GetParameterByName( NULL, "ShadowMap" );

	// �������������Ʈ ����(������)
	D3DVERTEXELEMENT9 decl[] =
	{
		{0,  0, D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
		{0, 12, D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,	0},
		{0, 24, D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
		D3DDECL_END()
	};
	if( FAILED( hr = m_pd3dDevice->CreateVertexDeclaration( decl, &m_pDecl )))
		return DXTRACE_ERR ("CreateVertexDeclaration", hr);

    return S_OK;
}
开发者ID:jjuiddong,项目名称:Dx9-Shader,代码行数:54,代码来源:main.cpp

示例9: InitEffect

//-----------------------------------------------------------------------------
// Name: InitEffect
// Desc: This function creates an effect
//-----------------------------------------------------------------------------
void InitEffect( char* filename, LPDIRECT3DDEVICE9 device, LPD3DXEFFECT *effect )
{
	HRESULT hr;

	LPD3DXBUFFER pBufferErrors = NULL;

	WCHAR Wfilename[256];
	OutputMessage::ToWchar( filename, Wfilename );
	hr = D3DXCreateEffectFromFile( device, Wfilename, 0, 0, 0, 0, effect, &pBufferErrors );

	if( FAILED(hr) )
	{
		LPVOID pCompilErrors = pBufferErrors->GetBufferPointer();
		ERROR((char*)pCompilErrors);
	}
}
开发者ID:coderofgames,项目名称:noise,代码行数:20,代码来源:Effect.cpp

示例10: Init

//------------------------------------------------------------------------
// 
// [2011/3/23 jjuiddong]
//------------------------------------------------------------------------
BOOL CShader::Init(char *szFileName, char *szTechnique)
{
	// 쉐이더 파일 읽기
	HRESULT hr;
	LPD3DXBUFFER pErr;
	if (FAILED(hr = D3DXCreateEffectFromFile(g_pDevice, szFileName, NULL, NULL, 
		D3DXSHADER_DEBUG , NULL, &m_pEffect, &pErr))) {
			MessageBox( NULL, (LPCTSTR)pErr->GetBufferPointer(), "ERROR", MB_OK);
			//DXTRACE_ERR( "CreateEffectFromFile", hr );
			return FALSE;
	}

	m_hTechnique = m_pEffect->GetTechniqueByName( "TShader" );

	return TRUE;
}
开发者ID:jjuiddong,项目名称:Dx3D-Study,代码行数:20,代码来源:shader.cpp

示例11: Load

bool Shader::Load(LPDIRECT3DDEVICE9 d3ddev, const std::string& filename)
{
    ID3DXBuffer* errorlog = nullptr;
    if(FAILED(D3DXCreateEffectFromFile(d3ddev,filename.c_str(),0,0,
        D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY,0, &m_effect, &errorlog)))
    {
        std::string errorMessage("Shader " + filename + " has failed!");
        if(errorlog)
        {
            errorMessage += (char*)errorlog->GetBufferPointer();
        }
        Diagnostic::ShowMessage(errorMessage);
        return false;
    }
    return true;
}
开发者ID:podxboq,项目名称:Cloth_android_app,代码行数:16,代码来源:shader.cpp

示例12: Effect

HUD::HUD(IDirect3DDevice9 *device, int width, int height)
	: Effect(device), width(width), height(height)
{

	DWORD flags = D3DXFX_NOT_CLONEABLE;

	// Load effect from file
	SDLOG(0, "Hud Effect load");
	ID3DXBuffer* errors;
	HRESULT hr = D3DXCreateEffectFromFile(device, GetDirectoryFile("dsfix\\HUD.fx"), NULL, NULL, flags, NULL, &effect, &errors);
	if(hr != D3D_OK) SDLOG(0, "ERRORS:\n %s", errors->GetBufferPointer());

	// get handles
	frameTexHandle = effect->GetParameterByName(NULL, "frameTex2D");
	opacityHandle = effect->GetParameterByName(NULL, "opacity");
}
开发者ID:Nucleoprotein,项目名称:dsfix,代码行数:16,代码来源:Hud.cpp

示例13: D3DXCreateTeapot

Teapot::Teapot()
{
	D3DXCreateTeapot(theDevice, &m_mesh, nullptr);
	
	ID3DXBuffer* errorBuffer;
	D3DXCreateEffectFromFile(theDevice, "Teapot.fx", 0, 0,
		D3DXSHADER_DEBUG, 0, &m_effect, &errorBuffer);

	if (errorBuffer)
	{
		Error((char*)errorBuffer->GetBufferPointer());
		errorBuffer->Release();
	}

	m_hWorldViewProj = m_effect->GetParameterByName(0, "matWorldViewProj");
}
开发者ID:tcye,项目名称:DXEngine,代码行数:16,代码来源:Teapot.cpp

示例14: OnD3D9CreateDevice

//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
                                     void* pUserContext )
{
    HRESULT hr;

    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
    V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );

    V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
                              OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                              L"Arial", &g_pFont9 ) );

    // Read the D3DX effect file
    WCHAR str[MAX_PATH];
    DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE | D3DXFX_LARGEADDRESSAWARE;
#ifdef DEBUG_VS
        dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
    #endif
#ifdef DEBUG_PS
        dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
    #endif
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"DDSWithoutD3DX.fx" ) );
    V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags,
                                        NULL, &g_pEffect9, NULL ) );

    g_hRenderScene = g_pEffect9->GetTechniqueByName( "RenderScene" );
    g_hmWorld = g_pEffect9->GetParameterByName( NULL, "g_mWorld" );
    g_hmWorldViewProjection = g_pEffect9->GetParameterByName( NULL, "g_mWorldViewProjection" );
    g_htxDiffuse = g_pEffect9->GetParameterByName( NULL, "g_txDiffuse" );

    // Create a decl for the object data.
    D3DVERTEXELEMENT9 declDesc[] =
    {
        {0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
        {0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
        {0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
        {0xFF,0,D3DDECLTYPE_UNUSED, 0,0,0}// D3DDECL_END 
    };
    V_RETURN( pd3dDevice->CreateVertexDeclaration( declDesc, &g_pDecl9 ) );

    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 0.0f, -5.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f,  0.0f );
    g_Camera.SetViewParams( &vecEye, &vecAt );

    return S_OK;
}
开发者ID:KNeal,项目名称:Oculus,代码行数:51,代码来源:DDSWithoutD3DX9.cpp

示例15: DXconvAnsiToWide

	Shader::Shader(std::string xmlPath)
	{	
		CWsbXmlSP xml = CWsbXml::LoadXmlFile(xmlPath);
		std::string path = xml->GetElement("path")->GetString();

		_path = path;

		WCHAR bufferName[256] = {0};
		DXconvAnsiToWide(bufferName, path.c_str(), (path.length()+1));
		
		// シェーダ ファイルのロード
		LPD3DXBUFFER compilationErrors = NULL;

		HRESULT hr = D3DXCreateEffectFromFile( 
					GraphicsManager::_device, 
					bufferName, 
					NULL, 
					NULL, 
					D3DXSHADER_DEBUG, 
					NULL, 
					&_effect, 
					&compilationErrors
					);

		// ロードに失敗した場合
		if(FAILED(hr))
		{
			if(compilationErrors)	
				DXUTOutputDebugStringA((LPCSTR)compilationErrors->GetBufferPointer());
			
			SAFE_RELEASE(compilationErrors);
			return;
		}
		// ハンドルの読み込み
		_technique = _effect->GetTechniqueByName(xml->GetElement("technique")->GetString().c_str());
		_wvp = _effect->GetParameterByName(NULL, xml->GetElement("wvp")->GetString().c_str());
		_color = _effect->GetParameterByName(NULL, xml->GetElement("color")->GetString().c_str());
		_sourceTexture = _effect->GetParameterByName(NULL, xml->GetElement("srctex")->GetString().c_str());

		// 他、ロード
		for (int i = 0; i < xml->GetElementNum("handle"); i++)
		{
			// XMLからKeyを読み込みロードする
			D3DXHANDLE shaderTemporary = _effect->GetParameterByName(NULL, xml->GetElement("handle", i)->GetString().c_str());
			_handles.insert(std::make_pair(xml->GetElement("handle", i)->GetString(), shaderTemporary));
		}
	}
开发者ID:nuponsalt,项目名称:Game001,代码行数:47,代码来源:Shader.cpp


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