Game Development Reference
In-Depth Information
&proj,
D3DX_PI * 0.5f, // 90 - degree
(float)Width / (float)Height,
1.0f,
1000.0f);
Device->SetTransform(D3DTS_PROJECTION, &proj);
// don't use lighting for this sample
Device->SetRenderState(D3DRS_LIGHTING, false);
return true;
}
We can now render our quad as normal, and the currently set texture is
mapped to it:
bool Display(float timeDelta)
{
if( Device )
{
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
0xffffffff, 1.0f, 0);
Device->BeginScene();
Device->SetStreamSource(0, Quad, 0, sizeof(Vertex));
Device->SetFVF(Vertex::FVF);
// Draw primitives using presently enabled texture.
Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
Device->EndScene();
Device->Present(0, 0, 0, 0);
}
return true;
}
6.7 Summary
Texture coordinates are used to define a triangle on the texture
that gets mapped to the 3D triangle.
We can create textures from image files stored on disk using the
D3DXCreateTextureFromFile function.
We can filter textures by using the minification, magnification, and
mipmap filter sampler states.
Address modes define what Direct3D is supposed to do with tex-
ture coordinates outside the [0, 1] range. For example, should the
texture be tiled, mirrored, clamped, etc.?
Search WWH ::




Custom Search