Direct3D is a state machine; applications set up the state of the lighting, rendering, and transformation modules and then pass data through them. This architecture is integral to Immediate Mode, but it is partially hidden by the Retained-Mode API. The SetRenderState function is a simple way to set the rendering state for a Retained-Mode application.
First, SetRenderState calls the IDirect3DRMDevice::SetQuality method, specifying that the lights are on, that the fill mode is solid, and that Gouraud shading should be used. At this point, applications that need to change the dithering mode or texture quality can call the IDirect3DRMDevice::SetDither or IDirect3DRMDevice::SetTextureQuality methods.
/////////////////////////////////////////////////////////////////////
//
// SetRenderState
// Set the render quality and shade information.
//
/////////////////////////////////////////////////////////////////////
BOOL
SetRenderState(void)
{
HRESULT rval;
// Set the render quality (light toggle, fill mode, shade mode).
rval = myglobs.dev->lpVtbl->SetQuality(myglobs.dev,
D3DRMLIGHT_ON | D3DRMFILL_SOLID | D3DRMSHADE_GOURAUD);
if (rval != D3DRM_OK) {
return FALSE;
}
// If you want to change the dithering mode, call SetDither here.
// If you want a texture quality other than D3DRMTEXTURE_NEAREST
// (the default value), call SetTextureQuality here.
return TRUE;
}