TNL
hr = D3DXCreateEffectFromFile( g_pd3dDevice,
L"effect.fx",
NULL,
NULL,
0,
NULL,
&m_pEffect,
&pBufferErrors );
//이펙트 파일을 불러온다
if( FAILED(hr) )
{
LPVOID pCompilErrors = pBufferErrors->GetBufferPointer();
MessageBox(NULL, (const TCHAR*)pCompilErrors, L"Fx Compile Error",
MB_OK|MB_ICONEXCLAMATION);
}
이펙트 파일에 불러올떄 에러가 날때 에러 메세지를 받아와서 멀티바이트를 유니코드로 바꿔어서 출력한다.
m_pEffect->SetTexture( "texture0", m_pTexture_0 );
텍스트를 찾아서 텍스쳐를 설정한다
UINT uPasses;
m_pEffect->Begin( &uPasses, 0 );
for( UINT uPass = 0; uPass < uPasses; ++uPass )
{
m_pEffect->BeginPass( uPass );
g_pd3dDevice->SetStreamSource( 0, m_pVertexBuffer, 0, sizeof(Vertex) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
m_pEffect->EndPass();
}
m_pEffect->End();
Begin 으로 열고 엔드 페스로 닫는다
// Handle operations
STDMETHOD_(D3DXHANDLE, GetParameter)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE;
STDMETHOD_(D3DXHANDLE, GetParameterByName)(THIS_ D3DXHANDLE hParameter, LPCSTR pName) PURE;
STDMETHOD_(D3DXHANDLE, GetParameterBySemantic)(THIS_ D3DXHANDLE hParameter, LPCSTR pSemantic) PURE;
STDMETHOD_(D3DXHANDLE, GetParameterElement)(THIS_ D3DXHANDLE hParameter, UINT Index) PURE;
STDMETHOD_(D3DXHANDLE, GetTechnique)(THIS_ UINT Index) PURE;
STDMETHOD_(D3DXHANDLE, GetTechniqueByName)(THIS_ LPCSTR pName) PURE;
//핸들이 리던에 됨
STDMETHOD_(D3DXHANDLE, GetPass)(THIS_ D3DXHANDLE hTechnique, UINT Index) PURE;
//
STDMETHOD_(D3DXHANDLE, GetPassByName)(THIS_ D3DXHANDLE hTechnique, LPCSTR pName) PURE;
STDMETHOD_(D3DXHANDLE, GetFunction)(THIS_ UINT Index) PURE;
STDMETHOD_(D3DXHANDLE, GetFunctionByName)(THIS_ LPCSTR pName) PURE;
STDMETHOD_(D3DXHANDLE, GetAnnotation)(THIS_ D3DXHANDLE hObject, UINT Index) PURE;
STDMETHOD_(D3DXHANDLE, GetAnnotationByName)(THIS_ D3DXHANDLE hObject, LPCSTR pName) PURE;
// Get/Set Parameters
STDMETHOD(SetValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT Bytes) PURE;
STDMETHOD(GetValue)(THIS_ D3DXHANDLE hParameter, LPVOID pData, UINT Bytes) PURE;
//이펙트 안에 잇는 특정한 변수값을 받아 올수 없다.
STDMETHOD(SetBool)(THIS_ D3DXHANDLE hParameter, BOOL b) PURE;
STDMETHOD(GetBool)(THIS_ D3DXHANDLE hParameter, BOOL* pb) PURE;
STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hParameter, CONST BOOL* pb, UINT Count) PURE;
STDMETHOD(GetBoolArray)(THIS_ D3DXHANDLE hParameter, BOOL* pb, UINT Count) PURE;
STDMETHOD(SetInt)(THIS_ D3DXHANDLE hParameter, INT n) PURE;
STDMETHOD(GetInt)(THIS_ D3DXHANDLE hParameter, INT* pn) PURE;
STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hParameter, CONST INT* pn, UINT Count) PURE;
STDMETHOD(GetIntArray)(THIS_ D3DXHANDLE hParameter, INT* pn, UINT Count) PURE;
STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT f) PURE;
STDMETHOD(GetFloat)(THIS_ D3DXHANDLE hParameter, FLOAT* pf) PURE;
STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hParameter, CONST FLOAT* pf, UINT Count) PURE;
STDMETHOD(GetFloatArray)(THIS_ D3DXHANDLE hParameter, FLOAT* pf, UINT Count) PURE;
STDMETHOD(SetVector)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector) PURE;
STDMETHOD(GetVector)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector) PURE;
STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXVECTOR4* pVector, UINT Count) PURE;
STDMETHOD(GetVectorArray)(THIS_ D3DXHANDLE hParameter, D3DXVECTOR4* pVector, UINT Count) PURE;
STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE;
STDMETHOD(GetMatrix)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE;
STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE;
STDMETHOD(GetMatrixArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE;
STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE;
STDMETHOD(GetMatrixPointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE;
STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix) PURE;
STDMETHOD(GetMatrixTranspose)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix) PURE;
STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX* pMatrix, UINT Count) PURE;
STDMETHOD(GetMatrixTransposeArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX* pMatrix, UINT Count) PURE;
STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE;
STDMETHOD(GetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hParameter, D3DXMATRIX** ppMatrix, UINT Count) PURE;
STDMETHOD(SetString)(THIS_ D3DXHANDLE hParameter, LPCSTR pString) PURE;
STDMETHOD(GetString)(THIS_ D3DXHANDLE hParameter, LPCSTR* ppString) PURE;
STDMETHOD(SetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 pTexture) PURE;
STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE;
STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE;
STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE;
// Using current technique
// Begin starts active technique
// BeginPass begins a pass
// CommitChanges updates changes to any set calls in the pass. This should be called before
// any DrawPrimitive call to d3d
// EndPass ends a pass
// End ends active technique
STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE;
STDMETHOD(BeginPass)(THIS_ UINT Pass) PURE;
STDMETHOD(CommitChanges)(THIS) PURE;
//endpass 이전에 한번씩 호출하면 좋다.
STDMETHOD(EndPass)(THIS) PURE;
STDMETHOD(End)(THIS) PURE;
쉐이더
버텍스 쉐이더
LPDIRECT3DVERTEXSHADER9 m_pVertexShader;
LPDIRECT3DVERTEXDECLARATION9 m_pVertexDeclaration;
LPD3DXCONSTANTTABLE m_pConstantTableVS;
LPDIRECT3DPIXELSHADER9 m_pPixelShader;
LPD3DXCONSTANTTABLE m_pConstantTablePS;
//인터페이스와 같이 사용해야 한다.
D3DVERTEXELEMENT9 declaration[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
{ 0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
D3DDECL_END()
};
//값을 성정한다.
hr = D3DXCompileShaderFromFile( L"vertex_shader.vsh", NULL, NULL, "main",
"vs_2_0", dwShaderFlags, &pCode,
&pBufferErrors, &m_pConstantTableVS );
//위의 파일을 쉐이더로 컴파일한다. pCode 에 파일을 넣어준다.
// Create the vertex shader
g_pd3dDevice->CreateVertexShader( (DWORD*)pCode->GetBufferPointer(),
&m_pVertexShader );
//위의 pcode를 가지고 쉐이더를 넣어준다.
VertexShader = compile vs_2_0 myvs();
PixelShader = compile ps_2_0 myps();
//이펙트에서 쉐이더를 사용하여 컴파일한다.
//이렇게 이펙트 테크놀로지를 사용하여 쉐이더를 사용하는게 더 좋을수도 있다고함...
'프로그래밍 > 기타정보' 카테고리의 다른 글
스택덤프/미니덤프로 뻑난곳 알아내는 법 (버그트랩관련)(스크랩) (0) | 2011.05.18 |
---|---|
쉐이더 참고자료 (0) | 2010.09.28 |
분석 익스포터 (0) | 2010.09.17 |
매쉬 익스포트 (0) | 2010.09.14 |
케릭터 애니메이션 로더 (0) | 2010.09.14 |