Skip to main content
GameDev.net gamedev.net
🔒 Locked

ID3DXSPRITE slows down my game

Started by Daryl01 Nov 27, 2009 at 4:44 PM 8 replies 1.2k views
Original Post
Daryl01
Daryl01
I'm developing a 2D game for a school project. It's a brick breaker (with the paddle, the ball and targets to hit) and I created a ID3DXSPRITE variable to handle drawing all my targets from a texture of a 32x32 bitmap (about that size). In my render() function the code to display the targets on screen looks like this: float step; // the space between each target as it is being drawn float xPos; int nTargets = 5; // number of targets to draw sprite->Begin (/*alphablend*/); for (int i=0; i < nTargets; i ++) { xPos += step; D3DXVECTOR3 position (xPos, 0.0f, 0.0f); sprite->Draw (tex_target, NULL, NULL, position, D3DCOLOR_XRGB (255,255,255)); } sprite->End (); and tex_target is my texture of the target bitmap. So during my render function, sprite draws the target texture 5 times which is what slows down my game. If I changed nTargets to 1 then my game runs fast again. I was hoping to have 20 - 30 targets displayed. Does anyone have advice or a technique to share which would help with this problem? I was thinking that I could have the sprite draw the textures to the back buffer before I call the render() function, maybe in a pre_render() function.. but that would most likely take up the same amount of time
clashie
clashie
I don't see anything wrong there, really.


What is your hardware? Struggling to draw 5 things sounds strange. I tried to draw 81,000 32x32 sprites at the same time and my fps was around 130.
Daryl01
Daryl01
Could you check out my source code here?
Daryl01
Daryl01
Windows XP uh intel pentium 4 2.20GHz 640 RAM.
It slowed down on a dell xps 430 with vista as well :/
_the_phantom_
_the_phantom_
what do you mean by 'slows down'? What kind of drawing time are you seeing?
Daryl01
Daryl01
no time i just want smooth movement of the ball
eFoDay
eFoDay
what is your frames per second before adding more targets and what is the fps after you add the targets?
_the_phantom_
_the_phantom_
and keep in mind that frames per seconds is a pretty meaningless guide; what is important is milliseconds per frame as that gives you a better idea of performance loss.

Chances are however if you are seeing a 'loss' which impacts the smoothness of the game then you have hard coded the values for movement and are relying on a certain update frequency to achieve them, which isn't fast enough now.

The correct choice, if this is the case, is to refactor your loop so that it updates in a better manner; in reality 50 to 60 updates a second is fine for most things.
eFoDay
eFoDay
Quote:
Original post by phantom

Chances are however if you are seeing a 'loss' which impacts the smoothness of the game then you have hard coded the values for movement and are relying on a certain update frequency to achieve them, which isn't fast enough now.

The correct choice, if this is the case, is to refactor your loop so that it updates in a better manner; in reality 50 to 60 updates a second is fine for most things.


exactly what I was getting at :)
Daryl01
Daryl01
Hmm Ok fellars it must be my update area. I didnt organize the code well enough and its kinda confusing to get back in to. Well the next time I'll know what to do better :-)-l--<

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.