Jump to content
  • Advertisement
Sign in to follow this  
ProgrammingNerd

sprite interface help

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

I am trying to write a sprite in direct3d. I am having some problems regarding how I should go about this. First, I tried to use the ID3DXSprite interface, but goes all haywire when sprites aren't a power of 2. Then I tried textured quads. They were pretransformed coordinants, but I had to lock the vertex buffer in order to move them. I suspect that if I use nontransformed coordinants, my projection matrix will make it look all distorted. From the above attempts, I am exhausted of ideas. Please help, and thanks.

Share this post


Link to post
Share on other sites
Advertisement
ID3DXSprite can use textures that are not in powers of 2. If you tried to load a non-power of 2 texture with any filter other than D3DX_FILTER_NONE than yes it probably would look weird. It all depends on which filter you use and how you calculate each frames region(source rect).

For textured quads locking the vertex buffer is too slow. You have to remove the RHW component from the FVF and create an orthogonal matrix(not projection), then use the D3DXMATRIX interface to move them around.

Share this post


Link to post
Share on other sites
Quote:
Original post by Scet
For textured quads locking the vertex buffer is too slow. You have to remove the RHW component from the FVF and create an orthogonal matrix(not projection), then use the D3DXMATRIX interface to move them around.


This is not necessarily true... locking and unlocking the vertex buffer once and filling it with all your sprite data isn't that slow, especially if you get the NOOVERWRITE flags and such correct. In fact it's the ideal way to batch your 2D sprites. Changing the matrix for each new sprite position requires a batch (DrawPrimitive...) for every sprite, which can be slow.

Share this post


Link to post
Share on other sites
Quote:
Original post by MasterWorks
This is not necessarily true... locking and unlocking the vertex buffer once and filling it with all your sprite data isn't that slow


I meant locking it each frame which was what he was doing. Of course the vertex buffer must be locked at least once to load to data into it, but that should be it.

Share this post


Link to post
Share on other sites
Thanks for all your help! I'm going to use the ID3DXSprite interface because it is easy and I want to get some stuff up and going quickly. Which is faster: ID3DXSprite or using my old technique with dynamic vertex buffers?

Share this post


Link to post
Share on other sites
Quote:
Original post by ProgrammingNerd
Thanks for all your help! I'm going to use the ID3DXSprite interface because it is easy and I want to get some stuff up and going quickly. Which is faster: ID3DXSprite or using my old technique with dynamic vertex buffers?


ID3DXSprite is 'highly optimized' is the typical response to your basic question, but you CAN achieve greater speed if you have some sort of special case that would allow a cheaper implementation... or, maybe you need more features...

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!