Archived

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

2D style

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

Alright, I was wondering which way is "better" for a 2 dimensional engine. Should I use D3DFVF_XYZ or D3DFVF_XYZRHW? The second would be akin to the older days of screen coordinate manipulation, but the first would allow for camera shifts (which might be inconsequential.) And don''t give me any "Depends on what you want to use it for" because I want to use it for everything! So, Which is better? Pros / Cons of each? Experience? Examples? ...thanks in advance!

Share this post


Link to post
Share on other sites
use the XYZ and with the D3DXMatrixOrthoOffCenterLH(&matProj, 0,ScreenWidth,0,ScreenHeight,0,1); projection, i''m making a 2D game, and this is very good for me...

Share this post


Link to post
Share on other sites
Id say to use the D3DXSPRITE interface, as it handles a lot of the work for you. Also, for larger, irregular shaped bitmaps, you may want to use the IDirect3DSurface9 interfaces, as textures can only handle images with dimensions that are a power of two, whereas surfaces can hold any size images.

On the flip side, like you say, using D3DFVF_XYZ would allow for camera shifts and other things too, that D3DXSPRITE (and D3DFVF_XYZRHW) wont let you do, so you may need to use D3DFVF_XYZ if you want your engine to be capable of doing ''everything''.

Share this post


Link to post
Share on other sites
If you use D3DXMatrixOrthoOffCenterLH with XYZ, your coordinates are in screen space AND you can do camera tricks.

Though XYZRWH are a bit more efficient since they don''t have to be transformed when you draw them.

Share this post


Link to post
Share on other sites
However, with XYZ and an orthographic projection, you have the following advantages:

1. You can use Vertex Shaders for vertex processing (For texture coordinate generation and the like), and pixel shaders that require vertex shader setup
2. You can have a virtual screen size (like set the ortho projection size to 800x600 or something, then the game would display the same size independent of resolution)
3. Ability to use transform matrices as opposed to having to use dynamic vertex buffers

I''m sure there''s more, but that''s all I''ve got at the moment

Josh

Share this post


Link to post
Share on other sites
Hmm...well, from that feedback, it would seem like D3DFVF_XYZ is more versatile. I''m not too worried about the extra efficiency of not having to transform the vertices because there''s not going to be enough vertices onscreen at one time to tell the difference. I probably won''t go into vertex/pixel shaders, because a 2d game that requires new video cards is kinda rediculous.

As for D3DXMatrixOrthoOffCenterLH, I''ve been using D3DXMatrixOrthoLH and have liked it....what is the benefit of using the "Off Center" version?

Thanks for all this feedback, by the way!

Share this post


Link to post
Share on other sites
Using the off center version allows you to put the origin where you want. If you use the other the origin is always in the middle of the viewport.

D3DXMatrixOrthoOffCenterLH(&matProj, 0,ScreenWidth,0,ScreenHeight,0,1);

Specifying a projection like that will set the origin in the top left corner and its more like drawing with DirectDraw.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
unless your rotate 180 around the z axis.

Share this post


Link to post
Share on other sites