Render targets in xen (Overview)

Render targets in XNA are very powerful; however there are a lot of 'gotchas' when using them.
Things can go wrong, and there are a number of corner cases where things don't always work as expected.
Render targets are handled a bit differently in xen.

In xen, render targets are called DrawTargets.
This is because a DrawTarget not only stores a render target/depth buffer, it also stores a list of objects to draw to the render target.
The DrawTargets classes are DrawTargetScreen, DrawTargetTexture2D, DrawTargetCube and DrawTargetTexture2DGroup (Multiple Render Target).

Any object that can be drawn implements the IDraw interface. To add an item to a DrawTarget, it must implement IDraw.


With this design, creating a DrawTarget is quite straight forward. The only requirement is that the DrawTarget has a default camera.
Once created, IDraw instances can be added to the DrawTarget.

Camera3D camera = new Camera3D();
 
drawToScreen = new DrawTargetScreen(camera);
 
drawToScreen.Add(gameSceneDrawer);


In the main Draw method, performing the draw is very simple:
drawToScreen.Draw(state);

This method call performs all the internal XNA logic for setting up the render targets, depth buffer, etc.
All known corner cases and odd-ball XNA gotchas are dealt with. All IDraw instances that were added will be drawn to the target in order.
Once the method call has completed, the draw operation has also completed.

DrawTargets can also be cloned to share their internal render targets/depth buffers.
This makes performing multi-pass techniques a lot easier and safe.


Read about runtime statistics in xen

Home Current Release Documentation Screenshots

Last edited Apr 8, 2010 at 11:56 PM by StatusUnknown, version 20

Comments

No comments yet.