For the record, I have no experience with Direct3D, so if these ideas don't sound like they would work well, let me know. =)
Here is how I'm planning on representing different things in D3D terms.
Front Buffer -
ID3DSurface9
Back Buffer(s) -
ID3DSurface9
(s)
Tiles - MipMapped
ID3DTexture9
s (64x64, 32x32, and 16x16)
Sprites -
ID3DTexture9
s
Layers - Arrays of pointers to tiles (textures)
I'm thinking maybe load an entire tileset into an
ID3DSurface9
and generate a series of release the surface once the
ID3DTexture9
s have been created. I'm not sure how efficient this is. Monolith, I'd appreciate your thoughts on how Direct3D should be used, as it seems like you've had some experience.
A kind of 'quad-map' would be used to write tiles (textures) to the back buffer. While the quad-map would generally contain all square quads, it would occasionally morph (under water, around large explosions, etc.) to make for easy warping of scenery. I hope that made sense.
I'm not planning on using COM architecture, just interfaces. For those that aren't sure, here's how interfaces work using seudo-C++.
/*
* Base item class
* i.e. defines basic properties and methods of all items
*/
class ItemBase
{
float weight;
string name;
virtual void Use() = 0;
};
/*
* Inherrited by all container objects
* i.e. objects that can hold other objects
*/
class IContainer
{
virtual Item GetNextItem() = 0;
virtual void AddItem(Item) = 0;
};
/*
* Sample item that implements the container interface
* i.e. inherrits from IContainer
*/
class BackPack : public ItemBase, public IContainer
{
// From ItemBase class
void Use() { ... };
// From IContainer interface
Item GetNextItem() { ... };
void AddItem(Item i) { ... };
};
The idea is, an interface doesn't actually contain any code on 'how' an object should perform a specific task. It mearly defines what tasks an object must perform. If you're unfamiliar with the 'virtual' or '= 0' bit I've added to the functions, that's just the way to define a function that 'must' be overridden in all derrived classes.
The benefit of using interfaces instead of full-blown base classes is that your derrived objects can be much more specialized in how they perform tasks. More examples:
An
IDrawable
interface might declare (but not define) functions for coloring, transforming, and rendering.
An
ICharacter
interface might declare (but not define) functions for walking, jumping, and dying.
An
IHasMass
interface might declare (but not define) functions for applying forces such as gravity, wind, friction, or magnetism.