Archived

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

When doing 2d in d3d..

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

When doing 2d in d3d and using D3DXMatrixOrthoLH() to build a orthogonal projection matrix. The movement in the game becomes kinda screenresolution dependant, or atleast i think so...?(eg translationg world 200 units down do place a menu on a 800x600 resolution wont work in a lower res, and endup in the middle of the screen in a higher res) This feels bad since i want to be able to run the game in any resolution. Is there anyway around this? I know that many 3d games(dont know of any 2d in d3d games tough) are resolution independant. Thanks in advance.

Share this post


Link to post
Share on other sites
Generally you''d recalculate where it needs to be on screen when you change resolution. This is like loading, it''s not to bad because it''s one time only. Just be sure you don''t recalculate every frame.

For example, you''ll probably want to put a bar along the bottom of the screen. Well, the screen is 800x600, so you better put it a 600-(0.5 * myheight). Woops, the screen is now 1024x768, better put it at 768-(0.5 * myheight). Even using percentages of the screen wouldn''t fit on the bottom of the screen, you simply have to recalculate where you need to be.

Share this post


Link to post
Share on other sites
I''m not sure..but I think you could set the orthoLH creation to a constant resolution and just assume that for all calculations, but the screen resolution in your device creation parameters is still the actual resolution of the screen. Do some testing.

-Marv

Share this post


Link to post
Share on other sites
quote:
Original post by Wicked Ewok
I''m not sure..but I think you could set the orthoLH creation to a constant resolution and just assume that for all calculations, but the screen resolution in your device creation parameters is still the actual resolution of the screen. Do some testing.

-Marv


Yep - this is what I sometimes do. No matter what I set the screen resolution to the 2D output is always aligned/scaled correctly. The only thing I need remember is that my 2D operations all assume a screen resolution of, for example, 640x480.

---
< Sharky''s Coding Corner >
< Coder @ Strangelite >
---

Share this post


Link to post
Share on other sites