Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void RecalulateWindowSize()
- {
- uiOffset = new Vector3();
- var v1 = (float)GraphicsDevice.PresentationParameters.BackBufferWidth / (float)GraphicsDevice.PresentationParameters.BackBufferHeight;
- var v2 = 16f / 9f;
- if (Math.Round(v1, 1) != Math.Round(v2, 1))
- {
- if (v1 > Math.Round(v2, 1))
- {
- var newWidth = GraphicsDevice.PresentationParameters.BackBufferHeight / 9 * 16;
- var unusedWidth = GraphicsDevice.PresentationParameters.BackBufferWidth - newWidth;
- uiOffset.X = unusedWidth / 2;
- uiOffset.Z = (float)GraphicsDevice.PresentationParameters.BackBufferHeight / 1080f;
- }
- else
- {
- var newHeight = GraphicsDevice.PresentationParameters.BackBufferWidth / 16 * 9;
- var unusedHeight = GraphicsDevice.PresentationParameters.BackBufferHeight - newHeight;
- uiOffset.Y = unusedHeight / 2;
- uiOffset.Z = (float)GraphicsDevice.PresentationParameters.BackBufferWidth / 1920f;
- }
- }
- else
- {
- uiOffset.Z = (float)GraphicsDevice.PresentationParameters.BackBufferWidth / 1920f;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment