I'm rolling my own rendering engine for 2d games. Before, I'm using Fixed Function Pipeline (FFP). I'm using dynamic vertex and index buffers. Lock/Unlock the buffers each frame. Batch the sprites(1 drawindexedprimitive() call for consecutive sprites that has the same texture).
Now, I would like to switch to Shader approach. As of now, I was able to draw a single rect using static vertex and index buffers, pass the computed World/View/Projection matrix to the shader (.fx file). It was great! I can now see my awesome rect with vertex colors. I'm no longer Locking/Unlocking my buffers every frame which I believe 1 of the slowest process. Anyway, my problem is how can I pass the vertices of each sprite + transformation matrix of each sprite to the shader? and how will this work on batching? like calling DrawIndexedPrimitive() one time for 10 sprites with same texture. As fas as I know based on what I learned, you can commit changes before calling the DrawIndexedPrimitive(). BUT how can you give all the information for those 10 sprites that will be drawn by this single DrawIndexedPrimitive call? OR it cant be done? Do you need 1 draw call for EACH sprite? I believe draw calls are slow too, right? if Yes, how can I pass the 4 vertices of each sprite to the shader? should i use:
uniform extern float3 vertex1;
uniform extern float3 vertex2;
uniform extern float3 vertex3;
uniform extern float3 vertex4;
then before draw calls, I use:
BUT what if i need to draw a sprite with more than 4 vertices? like TRAILS (imagine the slash of Fruit Ninja).