where to create effects?

Started by
1 comment, last by MJP 16 years, 3 months ago
What is a good way of creating and organizing ID3DXEffects? It seems natural to put an effect in the class where it will be used. But sometimes an effect could be used by different classes. Is it good to create all effects in one place (like an effect manager class), and other classes can just query the effects they need?
-----Quat
Advertisement
In my code base i have a renderer class that manages all the rendering. It stores resources such as textures it has loaded with d3d and effects it is uses to draw. This has it's good and bad points, but i like it because it keeps all of the D3D resources in a single place.

The D3D resources that are stored in the renderer might not be loaded from disk there (textures for example are loaded with my own TGA loader and then loaded from system memory into D3D), but it does give a single point of reference. The game identifies textures and effects by handles.
I use a class that you could call an Effects Manager to load all of my effects. Like my other resource managers, it's spawned by the renderer and is responsible for loading resources off disk and providing a handle or interface to all entities that need a particular resource. You'll probably want some sort of facility like this in your engine, whethere it's in a separate class or built into your renderer. Without it, it may be difficult to avoid loading redundant resources which can result in wasted memory or reduced performance.

This topic is closed to new replies.

Advertisement