Sign in to follow this  
eroy4u

2D Drawing in Direct3D

Recommended Posts

I'm making a 2D game with directx 9.0. I have read some of the articles concerning 2D Drawing in Direct3D. Some say use texture, some say use Sprite, It seems using sprite is easier then i dun understand why to use texture? thx

Share this post


Link to post
Share on other sites
Using textured quads will allow you to have greater control over how your graphics are batched together, which may allow for greater performance. I'm not sure how well, D3DXSprite(???) batches, but I believe it does.

If you don't want to worry about it use Sprite, If you're concerned that performance might be an issue *AND* that you can do better than Sprite already does (AFAIK) then use textured quads.

Share this post


Link to post
Share on other sites
There are two main reasons why you might want to "roll your own" and use textures/vertices directly:

1. You're used to it! I was writing sprite engines a long time before the ID3DXSprite interface came along... so I can write and use my own code about as quickly as I can the D3DX code

2. You need more control. If you're wanting to do some clever shader-related trickery, or you want to use some complex transformations/deformations, then you need to have access to the inner workings.

Performance is a bit of a moot point - you might be able to write something thats faster, but for the most part it's unlikely that it'd be worth the effort.

Bottom line - if you're happy with D3DX sprites (etc..) then go with it [smile]

hth
Jack

Share this post


Link to post
Share on other sites
You'll have to map texels to pixels.

Also, if you'll be doing that, you might as well disable the magnification and minification filters for the textures, this is done by setting the sampler states like this:

device->SetTextureStageState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
device->SetTextureStageState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT );


And as the below poster stated, mip mapping will 'blurry' your textures. So, make sure that it's not that causing the problem.

[edit] Added some code.

[Edited by - Kamikaze15 on November 10, 2005 6:27:07 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this