Sign in to follow this  

Batching With Vertex Buffer

This topic is 2635 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

I'm trying to figure out a way to batch sprites with a dynamic vertex buffer. But, the problem is that each sprite has a different texture. Is there a way to draw each sprite with the correct texture using 1 vertex buffer in Directx9 (C++)?

Share this post


Link to post
Share on other sites
One vertex-buffer, yes, but not one draw-call. Each Draw or DrawIndexed call has a vertex-start index, which lets you decide which vertex in the buffer is the first to use. So you could store 2 triangles in the same vertex buffer of 6 vertices, and use 2 different Draw-calls where the first draws the first 3 vertices and the second the last 3 vertices.
If you want to use a single Draw-call, then you must use the same texture. You could build a texture-atlas where you put all your textures side by side into a larger texture for example.

Share this post


Link to post
Share on other sites
Hmmm, this is rather for 3D meshes.

If all your textures have the same size, a uniform grid does the trick. If not, google for "rectangle packing". Either way you need a way to combine your images into one and calculate the corresponding (new) tex-coords. For the former you could abuse DX, but a image library or GDI+ is likely easier to use. Don't know but there are probably also tools for that (or GIMP/PhotoShop plugins).

Share this post


Link to post
Share on other sites
Quote:
Original post by unbird
Hmmm, this is rather for 3D meshes.


Oh yeah, i didn't see the "sprite" thing. Just saw "texture atlas" and first reaction was Hoppe and D3D UVAtlas :)

Share this post


Link to post
Share on other sites
Quote:
Original post by justin12343
Hmmm, sounds complicated. I may just go with d3dxsprite or something if I can't figure this out.
Is there any reason you're not going with ID3DXSprite? It's about the fastest and easiest you're going to get...

Share this post


Link to post
Share on other sites

This topic is 2635 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this