Posted 29 October 2012 - 02:00 PM
Hi Mike - thanks for the post.
Specifically I'm looking for at the least recommended class attributes and methods. From what I can tell after initialisation of the SpriteBatch class, as you prepare to render a frame you 'Add' sprites by invoking the SpriteBatch.Add method, passing the vectors in the form of a rectangle, and the texture for that sprite. As I understand it, this necessitates the dynamic vertex buffer, such that we can draw all sprites via only one draw call - as opposed to reloading vertex buffers with a new data stream per sprite.
I guess I could derive the pseudo-code for the SpriteBatch from a paragraph or two - but as you can tell really I want to nail down the principles of operation before I start coding it.
At the moment I have a Sprite class which contains a vertex buffer, index buffer, and vertices data stream. It has a draw method, meaning at the moment if I want 100 sprites then I've got 100 draw calls for each Sprite object. Instead of this (which is clearly horrifically inefficient - but works...) I want a single draw call - somehow - and the answer is SpriteBatch, I think. Is this right?