Archived

This topic is now archived and is closed to further replies.

Normie

A buncha ID3DXSprite Questions...

Recommended Posts

First of all, mad props to the guy who wrote that wrapper... your name escapes me at this moment, but thanks! That got me off my feet (I''m not using the wrapper anymore, building my own, but it was still a great guide) ...unfortunately, I still have a few questions. 1. The only way I could think of to move a sprite created with this interface is by releasing the texture, recreating it, and redrawing in the new location. There has got to be a better way to do this...any ideas? 2. Does using ID3DXSprite cause a performance drop relative to drawing the vertices with a vertexbuffer and all that matrix crap manually? 3. How would I go about setting translations/rotations to be relative to the center of the texture, instead of the upper-left corner? OK, so these are probably really basic questions...so sue me, I''m a basic programmer -Normie "But time flows like a river... and history repeats." ... So...what about beaver dams?

Share this post


Link to post
Share on other sites
I''m not an expert, but I will answers some of the questions:
1: ???? If you understand the parameters to the draw function, Simply blit to a different position on the screen. If you don''t know all the parameters look in the directx documentation.
2: No
3: You create a D3DXVECTOR2 and set it to the center of your picture, e.g:

D3DXVECTOR2 Bob
Bob.x=10.0f; // pixels
Bob.y=10.0f; // Don''t ask me why they are floats......

and then you pass it into your draw function...Learn the parameters!

Share this post


Link to post
Share on other sites
I wrote the wrapper, glad you found it useful

1) The only time u need to reload a texture is when it is lost due to a screen saver taking over or something similar. Just load the texture when you need to start using it, then use ->draw to put it on the screen every frame.

2) Nope. As long as you use D3DXSprite->begin and ->end once every frame.

3) The modifications needed to convert the vals to rotate from the center are also in the wrapper I created, just rip the code u need from it.

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
quote:
Original post by SikCiv
2) Nope. As long as you use D3DXSprite->begin and ->end once every frame.


G''day!

That''s not strictly true. You CAN do it faster if you roll your own. It usually doesn''t take too much effort in this case to get benefits either (batching, etc). The important question is, is it worth the effort?

In most cases D3DXSprite will be good enough, in which case it is a waste of time to write your own.

My personal issue with it is that you can''t (easily, reliably?) mess with render/texture states since begin() sets them up the way it likes them. You lose some flexibility.

That being said, if D3DXSprite does what you need, go for it. You can always optimize later if it turns out to be too slow.



Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
DrunkenHyena,

You could be right about the performance difference, though I havent seen a good comparison yet so its probable the performance is virtually un-noticable.

I use D3DXSprite mainly because I couldnt be bothered to code it from scratch, and it supports precise scaling and rotation - why re-invent the wheel. My Platform game runs at around 50-75FPS on average, even with literally hundreds of blits on the screen at once (P2/450 GeForce) so i''m happy

As for the customization of render states, as you said, it really depends on what you need. D3DXSprite supplies everything plus more when compared to DDraw. I''m guessing, but I think you may be able to set your own states after ->begin is called, I''ll try it and see how it goes...

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
quote:

Is it still possible/easy to use the lighting and other features of DX8 if you use the D3DXSprite interface?



Yes, though there may be a performance loss if you switch between D3DXSprite and other drawing techniques too many times during a frame. D3DXSprite->Begin() sets up the matrice, projection etc.. so excess calling will slow things down If u draw all your 3D objects then use D3DXSprite to blit energy bars etc it shouldnt be a problem.

I'm not sure about lighting up the D3DXSprite blits, you may be able to get it working by calling D3DXSprite->Begin, then setting up the lights, then calling D3DXSprite->Draw.

  Downloads:  ZeroOne Realm

Edited by - SikCiv on August 9, 2001 7:03:47 PM

Share this post


Link to post
Share on other sites