damongant

Untitled

Apr 22nd, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public void RecalulateWindowSize()
  2. {
  3. uiOffset = new Vector3();
  4. var v1 = (float)GraphicsDevice.PresentationParameters.BackBufferWidth / (float)GraphicsDevice.PresentationParameters.BackBufferHeight;
  5. var v2 = 16f / 9f;
  6. if (Math.Round(v1, 1) != Math.Round(v2, 1))
  7. {
  8. if (v1 > Math.Round(v2, 1))
  9. {
  10. var newWidth = GraphicsDevice.PresentationParameters.BackBufferHeight / 9 * 16;
  11. var unusedWidth = GraphicsDevice.PresentationParameters.BackBufferWidth - newWidth;
  12. uiOffset.X = unusedWidth / 2;
  13. uiOffset.Z = (float)GraphicsDevice.PresentationParameters.BackBufferHeight / 1080f;
  14. }
  15. else
  16. {
  17. var newHeight = GraphicsDevice.PresentationParameters.BackBufferWidth / 16 * 9;
  18. var unusedHeight = GraphicsDevice.PresentationParameters.BackBufferHeight - newHeight;
  19. uiOffset.Y = unusedHeight / 2;
  20. uiOffset.Z = (float)GraphicsDevice.PresentationParameters.BackBufferWidth / 1920f;
  21. }
  22. }
  23. else
  24. {
  25. uiOffset.Z = (float)GraphicsDevice.PresentationParameters.BackBufferWidth / 1920f;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment