Advertisement Jump to content
Sign in to follow this  

Drawing A LOT of sprites? (Directx9)

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

Hey. I've been having some really hard time with drawing large amount of sprites.
Basically what I want to do is draw lots of sprites, so many that giving them their position etc. like I did before is not possible.

This is how I did it before:
void render_frame(void)
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(128, 64, 0), 1.0f, 0);


D3DXVECTOR3 center(1280.0f, 1280.0f, 0.0f);
D3DXVECTOR3 position(1150.0f, 200.0f, 0.0f);
d3dsce->Draw(mysprite, NULL, ¢er, &position, D3DCOLOR_ARGB(255, 128, 128, 128));


d3ddev->Present(NULL, NULL, NULL, NULL);


But now I have atleast 100 sprites, so obviously I'm not going to do that now.

I've been trying to make an array of D3DXVECTOR3 aswell as of the sprites, and then assign the values for "position" and "center" in a for-loop. But the problem is that making something like this: D3DXVECTOR3 center = (floatx, floaty, floatz) gives an error.

Do you have any idea how to make that work, or can I even do it? And if I can't, then do you know any alternative way(s)?

So in a nutshell: I need to draw a lot of sprites. How do I do it?

Thanks in advance.

Share this post

Link to post
Share on other sites
I would create a struct like this:

struct Location
D3DXVECTOR3 center;
D3DXVECTOR3 position;

Then you create an array of locations:

Location locs[100];
locs[0].center = D3DXVECTOR3(1.0f,1.0f,1.0f);
locs[0].position = D3DXVECTOR3(2.0f,2.0f,1.0f);
locs[1].center = D3DXVECTOR3(44.0f,44.0f,44.0f);
locs[1].position = D3DXVECTOR3(2.0f,2.0f,1.0f);

And then you create a for loop:

for(int x = 0; x < 100; x++)
d3dsce->Draw(mysprite, NULL, &locs[x].center, &locs[x].position, D3DCOLOR_ARGB(255, 128, 128, 128));

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!