2D style

Started by
7 comments, last by Funkymunky 20 years, 10 months ago
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!
Advertisement
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...
How appropriate, you fight like a cow!
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''.

Life is all about expression, so express yourself.
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.
Stay Casual,KenDrunken Hyena
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
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!
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.
NOT TOP LEFT
BOTTOM LEFT
when using 3D the Y is going UP not DOWN.
How appropriate, you fight like a cow!
unless your rotate 180 around the z axis.

This topic is closed to new replies.

Advertisement