DirectX Graphics 프로그래밍 가이드 고정 기능 파이프라인 텍스처 텍스처 혼합 혼합 스테이지의 생성 [목차열람] [주소복사] [슬롯비우기] |
Microsoft DirectX 9.0 |
혼합 스테이지란, 텍스처의 혼합 방법을 정의하는, 일련의 텍스처 처리와 인수이다. 혼합 스테이지를 생성 할 때 C++ 애플리케이션에서는 IDirect3DDevice9::SetTextureStageState 메서드를 호출한다. 최초의 호출은, 실행하는 처리를 지정한다. 게다가 2 회의 호출을 실시해, 처리를 적용하는 인수를 정의한다. 다음 샘플 코드는, 혼합 스테이지의 생성 방법을 나타내고 있다.
// This example assumes that lpD3DDev is a valid pointer to an // IDirect3DDevice9 interface. // Set the operation for the first texture. d3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_ADD); // Set argument 1 to the texture color. d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); // Set argument 2 to the iterated diffuse color. d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
텍스처의 텍셀 데이터에는, 색값과 알파값이 포함된다. 애플리케이션에서는, 단일의 혼합 스테이지에서 색값과 알파값의 양쪽 모두의 각각의 처리를 정의할 수 있다. 컬러 처리와 알파 처리에는, 각각 독자적인 인수가 있다. 더 자세한 정보는, 「D3DTEXTURESTAGESTATETYPE 」를 참조할것.
Microsoft® Direct3D® 애플리케이션 프로그래밍 인터페이스 (API)에 포함되지 않지만, 다음의 매크로를 애플리케이션에 삽입해, 텍스처 혼합 스테이지의 생성에 필요한 코드를 단축할 수가 있다.
#define SetTextureColorStage( dev, i, arg1, op, arg2 ) \ dev->SetTextureStageState( i, D3DTSS_COLOROP, op); \ dev->SetTextureStageState( i, D3DTSS_COLORARG1, arg1 ); \ dev->SetTextureStageState( i, D3DTSS_COLORARG2, arg2 ); #define SetTextureAlphaStage( dev, i, arg1, op, arg2 ) \ dev->SetTextureStageState( i, D3DTSS_ALPHAOP, op); \ dev->SetTextureStageState( i, D3DTSS_ALPHAARG1, arg1 ); \ dev->SetTextureStageState( i D3DTSS_ALPHAARG2, arg2 );