• Advertisement
Sign in to follow this  

Directx11 Sprite class

This topic is 1143 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Edited by precious roy

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement