2D Drawing in Direct3D

Started by
4 comments, last by MasterWorks 18 years, 5 months ago
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
Advertisement
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.

throw table_exception("(? ???)? ? ???");

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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I've tried texture quads but i see the image is blurred?
how can i solve it?
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]
The number of mip levels in the texture can influence how 'blurry' things look as well.

This topic is closed to new replies.

Advertisement