Firstly, my engine can now use vertex shaders quite happily. Only models use them at the moment, not sprites - but I'll get around to that fairly soon. I was actually quite surprised at how easy vertex shaders are to use, and it also got me thinking that I really need a way to precompile shaders instead of compiling them at load time, although I don't know if that's likely to cause any problems; or rather if D3DX does any optimisation for the card when it's compiling. But I'll burn that bridge when I come to it.
I've also got MD2 model loading working, and animaion, and a helper class to handle animation sequences. Some example code:
// Load model
EModel::SP pModel = new EModel(L"gladiator.mdl");
m_pModelAnim = new EModelAnimator(pModel, 1000.0f / 15.0f); // Animate at 15 FPS
// Main loop:
EInput& input = EInput::Get();
Touching a model will create the context for the model, which will load it from the resource pack, get the shader (load and compile it if needed), and set up the VB and IB for the model. The SetSequence() function has an optional parameter that lets you specify if you want to blend to the new sequence, or just snap to it, defaulting to "blend".
And yes, yes, I know I've got singletonitus. I've been doing a bit of tidying up in the engine code, E.g. passing a PGraphics reference to PVertexBuffer::Create() instead of using the singleton Get() function, but there's still quite a few singletons that I think fit perfectly well with the singleton pattern. Those are:
- EInput - Keyboard and mouse input
- EResourceManager - Unpacks, caches and returns resources from the pack file
- EGraphics - Graphics system
- EAudio - Audio manager
I know someone's going to have something to say about my "manager" classes, particularly graphics and input. But my reasoning is there will only ever be one output device. There will only ever be one input and audio system, and they need to be referenced from all over the app (Primarily for convenience, the game class could store them internally I suppose).
Anyway, I still heart singletons. And they haven't shat on me (yet).