Graphics Reference
In-Depth Information
See also
F Chapter 3 , Rendering Meshes , provides further information about the depth buffer
Creating a Direct3D renderer class
In this recipe, we will look at the final component of our sample rendering framework,
the renderer. These are classes that implement specific rendering logic, such as drawing
a mesh or utility classes that wish to participate within the Direct3D resource lifecycle
management of the rendering framework.
Getting ready
We continue on from where we left off in the Using the sample rendering framework recipe.
How to do it…
We will first look at the steps necessary to create a Common.RendererBase descendent
and then how this class would be created, initialized, and finally execute its Direct3D
draw commands.
1.
Creating a renderer class within the sample framework requires the following
minimal code:
public class MyRenderer : Common.RendererBase
{
// Create device dependent resources
protected override void CreateDeviceDependentResources()
{ ... }
// Create size dependent resources
protected override void CreateSizeDependentResources()
{ ... }
// Perform rendering commands
protected override void DoRender()
{ ... }
}
2.
Within a class that is ultimately descending from D3DApplicationBase , you would
create and initialize an instance of this renderer class as follows:
var myRenderer = ToDispose(new MyRenderer());
myRenderer.Initialize(this);
 
Search WWH ::




Custom Search