Telling ID3DXSprite to draw every object OK?
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?
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.
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.
Quote:Original post by Sol BlueIt'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.
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?
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 blueshogun96True. 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.
Minimizing the number of draw calls is usually the most common and best ways to optimize your game (afaik)
This is assuming it doesn't bother checking screen bounds (Since that's probably not worth doing that low down).
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 :-)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement