• Advertisement
Sign in to follow this  

Telling ID3DXSprite to draw every object OK?

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

Hi all, I'm writing a 2D game with ID3DXSprite. Right now, I tell the Sprite object to draw everything without regard to whether it's currently in the client area or not. For example, the world map's dimensions are many thousands of pixels, but the Sprite object is told to draw all the tiles, even though most of them are off-screen. Is this slow? Should I figure out what's currently in the screen boundaries and draw only that?

Share this post


Link to post
Share on other sites
Advertisement
Minimizing the number of draw calls is usually the most common and best ways to optimize your game (afaik) so I do agree that only drawing what's visible is a good idea personally. Just remember to keep sprites attributes updated even though they aren't being rendered if necessary.

I'm also writing a 2D game at this time but I'm using a tile based engine. Not sure what you're using, but if you're using a tile based engine like me, I'd definetly recommend reducing the number of draw calls on sprites that are not being rendered.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sol Blue
I'm writing a 2D game with ID3DXSprite. Right now, I tell the Sprite object to draw everything without regard to whether it's currently in the client area or not. For example, the world map's dimensions are many thousands of pixels, but the Sprite object is told to draw all the tiles, even though most of them are off-screen.

Is this slow? Should I figure out what's currently in the screen boundaries and draw only that?
It's preferable to not draw things outside the screen if possible. It's quite straightforward to check if a rectangle is in another rectangle (I.e. sprite in screen), and probably worth doing.
Having said that, profile your app and see if ID3DXSprite calls are a bottleneck. There's no point in optimising something that isn't a problem.

Quote:
Original post by blueshogun96
Minimizing the number of draw calls is usually the most common and best ways to optimize your game (afaik)
True. ID3DXSprite batches everything as much as possible; for instance sorting by texture will cause it to render all sprites using texture A, then all sprites using texture B. If all sprites that use texture B are offscreen, then ID3DXSprite won't need to change texture and render a new batch.
This is assuming it doesn't bother checking screen bounds (Since that's probably not worth doing that low down).

Share this post


Link to post
Share on other sites
It depends, just do some simple math and see how many data you're sending to your GPU and how many memory you're using. If it's a complicated 2d game, you could better start setting up a quadtree :-)

Share this post


Link to post
Share on other sites
Thanks people! I'll only draw stuff in the screen, then, and plan on getting a profiler soon.

rating++;

Share this post


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

  • Advertisement