http://blog.daum.net/naganolacpp/37
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE(0.0f,0.0f,1.0f,1.0f), 1.0f, 0 );
g_pd3dDevice->BeginScene();
g_pEffect->SetTechnique( "Technique0" );
setTechniqueVariables();
UINT uPasses;
g_pEffect->Begin( &uPasses, 0 );
for( UINT uPass = 0; uPass < uPasses; ++uPass )
{
g_pEffect->BeginPass( uPass );
// 단일 스트림 사용
//g_pd3dDevice->SetStreamSource( 0, g_pVertexBuffer, 0, sizeof(Vertex) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
// 다중 스트림 사용
g_pd3dDevice->SetVertexDeclaration( g_vertex_declaration );
/* SetFVF와 SetvertexDeclaration은 같이 쓸경우 주의해야한다.
잘못하면 괴물이 출력된다*/
g_pd3dDevice->SetStreamSource( 0, g_pVertexBuffer0, 0, sizeof(Vertex0) );
g_pd3dDevice->SetStreamSource( 1, g_pVertexBuffer1, 0, sizeof(Vertex1) );
// 인덱스 버퍼 Set
g_ib->SetIndices();
// 출력
g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLESTRIP, 0, 0, 4, 0, 2 );
g_pEffect->EndPass();
}
g_pEffect->End();
g_pd3dDevice->EndScene();
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
/*
이건 사용된 버택스 버퍼 데이터
*/
struct Vertex0
{
float x, y;
float tu, tv;
};
struct Vertex1
{
float z;
};
Vertex0 g_quadVertices0[] =
{
{-1.0f,-1.0f, 0.0f,1.0f },
{ 1.0f,-1.0f, 1.0f,1.0f },
{-1.0f, 1.0f, 0.0f,0.0f },
{ 1.0f, 1.0f, 1.0f,0.0f }
};
Vertex1 g_quadVertices1[] =
{
{ 0.0f },
{ 0.0f },
{ 0.0f },
{ 0.0f }
};
D3DVERTEXELEMENT9 g_vertex_description[]=
{
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 8, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 1, 0, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 1 },
D3DDECL_END()
};
*/
'그래픽스(Graphics) > DirectX9~12' 카테고리의 다른 글
인스턴싱 (Instancing) (1) | 2013.01.25 |
---|---|
D3DXCreateTextureFromFile 함수 (0) | 2013.01.22 |
D3DVERTEXELEMENT9 사용법 (0) | 2013.01.21 |
Fast Object Picking (0) | 2013.01.19 |
게임 이펙트에서의 D3DRS_ZWRITEENABLE의 사용 (1) | 2013.01.19 |