Using the Effect Interfaces (XNA Game Studio 4.0 Programming)

BasicEffect implements three different interfaces that are generic enough to be used by multiple types of effects. Each of the built-in effects in Game Studio 4.0 uses at least one of these interfaces, and your own custom effects could also.This enables you to easily cast your effects to these interface types to do common operations.The most common is the following:

tmpD-171_thumb

This is to give you a spot to set your matrices generically. As expected, there is also one to handle basic lighting:

tmpD-172_thumb

Finally, there is an interface you can use if your effect supports fog:

tmpD-173_thumb


All of these interfaces are used by the built-in effects and are there for you to implement in your own custom effect classes to write generic code for many common operations. Now let’s move on to the next built-in effect type.

Next post:

Previous post: