Skip to main content
gamedev.net
🔒 Locked

DrawPrimtive 2D

Started by ProgrammerDX Sep 21, 2010 at 6:59 AM 0 replies 600+ views
Original Post
ProgrammerDX
ProgrammerDX
DirectX 9.0

Hello

I have a few straightforward questions.

Assuming that for drawing any 2D using D3DX Sprites, that 1 Sprite is enough for the whole 2D part of the game (HUD) (I dont know if it's better to use more than 1 Sprite).

What is faster?

Sprite->Begin(...);Sprite->Draw(Texture1...);Sprite->Draw(Texture2...);Sprite->Draw(Texture3...);Sprite->Draw(Texture4...);Sprite->Draw(Texture5...);Sprite->Draw(Texture6...);Sprite->End();


Device->SetStreamSource();Device->SetTexture(Texture1);Device->DrawPrimitive(...);


Thanks
Evil Steve
Evil Steve
The second, because it's one draw call.

If you mean the second one should be repeated 7 times, locking the vertex buffer each time, then the first will be marginally faster, because ID3DXSprite uses a static index buffer and a dynamic vertex buffer internally, whereas your second uses non-indexd primitives.

If you have 7 vertex buffers, and go with method #2, then #2 might be slightly faster since there won't be any buffer locking occuring.

If in doubt, profile it.

Topic Locked

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

Sign in to reply to this topic.