Directx11 Sprite class

Started by
3 comments, last by Tispe 9 years, 1 month ago

Hello,

I am pretty new with working with directx and i cant seem to think of a good way to set up my vertex buffer. so my problem i have a sprite sheet with different size sprites on it. what is the best way to make my vertex buffer so that i don't care about the size of my sprite.

should i make a vertex buffer for each sprite? or cal i pass in vertex information into the shader and do stuff in their.

greetings,

Roy

Edit:

would Instancing mentioned in the below article be what i am looking for? this is the first time i am reading about it, but seems to be what i am looking for but i still dont fully understand how the vertex buffer would work. do i have 1 with 4 verts and just draw that at different positions?

http://stackoverflow.com/questions/3884885/what-is-the-best-pratice-to-render-sprites-in-directx-11

Advertisement

Unless you're set on implementing your own sprite API, I would recommend the SpriteBatch class in the DirectX Tool Kit.

I second Dave Hunt's recommendation to use the DirectX TK sprites.

If you decide to implement your own sprites, you still may want to look at the source code for the SpriteBatch class in the DirectX TK.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Hmm interesting. i will have a look at it. thanks

I'm interested to learn what ways there are to implement this sort of stuff.

Off the top of my head I could imagine that a single vertex in a vertex buffer with format D3D11_PRIMITIVE_TOPOLOGY_POINTLIST is instanced equal to the number of sprites to draw in one call.

The vertex is passed to a geometry shader which fetches from a StructuredBuffer the sprite data using the index SV_PrimitiveID. The GS would output the generated quad, and possibly an index to allow multiple textures to be used at the same draw call, which gives the possibility to draw from multiple texture altases.

I think this is somewhat how Point Sprite Expansion operates, but i'm not sure.

This topic is closed to new replies.

Advertisement