纹理

//声明纹理接口
IDirect3DTexture9* Tex  = 0;

//载入纹理
D3DXCreateTextureFromFile(
	Device,
	"dx5_logo.bmp",
	&Tex);

//设置纹理
Device->SetTexture(0, Tex);

//设置纹理参数,将缩小过滤器和放大过滤器设置为线性过滤模式,并将渐进纹理过滤器设为D3DTEXF_POINT
Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);

//关闭光照
Device->SetRenderState(D3DRS_LIGHTING, false);

//设置寻址模式
//wrap address mode
if( ::GetAsyncKeyState('W') & 0x8000f )
{
	Device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
	Device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
}

//border color address mode
if( ::GetAsyncKeyState('B') & 0x8000f )
{
	Device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
	Device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
	Device->SetSamplerState(0,  D3DSAMP_BORDERCOLOR, 0x000000ff);
}

//clamp address mode
if( ::GetAsyncKeyState('C') & 0x8000f )
{
	Device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
	Device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
}

//mirror address mode
if( ::GetAsyncKeyState('M') & 0x8000f )
{
	Device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);
	Device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);
}	

//绘制
...

你可能感兴趣的:(纹理)