Should my 2D engine use ID3DXSPRITE for tiles?
I'm working on a simple 2D engine in DirectX 9 and am already using ID3DXSPRITE for my sprites... Should I be using ID3DXSPRITE for my tiles (it's a scrolling tile-based engine) too or is there another alternative? Right now I'm just blitting from surface to the screen and it seems okay, but I feel like there should be a better way.
I don't see why there's anything wrong with using ID3DXSPRITE for your tiles. Tiles are just sprites themselves, really.
Yes, ID3DXSprite is a good choice for this. If you can manage to get as many tiles onto one texture as possible, you'll see better performance too.
Awesome, I already have all my tiles on one surface so it shouldn't be a problem putting them on one texture.
Thanks for the help guys!
Thanks for the help guys!
Here's another dumb question - but related... Since I'm going to be using ID3DXSPRITE for everything, do I need to even define my own custom vertex format like so?
Edit:
Additionally, would these be correct?
Instead of passing in my custom vertex format, would I pass in the LP3DXSPRITE? I could be way off base here, so please let me know if I am.
[Edited by - Gary the Llama on September 16, 2007 1:40:02 PM]
struct Vertex{ float x, y, z, rhw; D3DCOLOR color; float u, v;};
Edit:
Additionally, would these be correct?
CreateVertexBuffer(sizeof(LPD3DXSPRITE) * num, NULL, D3DFVF_VERTEX, D3DPOOL_MANAGED, &vertexBuffer, NULL);d3ddev->SetStreamSource(0, vertexBuffer, 0, sizeof(LPD3DXSPRITE));
Instead of passing in my custom vertex format, would I pass in the LP3DXSPRITE? I could be way off base here, so please let me know if I am.
[Edited by - Gary the Llama on September 16, 2007 1:40:02 PM]
Nope. ID3DXSprite manages all that internally, you just need to give the sprite position in screen coordinates.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement