SND\AstrorEnales_cp dd173478d6 - Wrote the DualTexture shader for GL3 but the rendering is not working yet
- Huge refactoring in the Dx10 RenderSystem + increasing much performance
2012-09-06 09:58:13 +00:00

48 lines
1.7 KiB
C#

using System;
using System.Runtime.InteropServices;
using ANX.Framework.Graphics;
namespace ANX.RenderSystem.Windows.DX10.Helpers
{
internal static class WindowHelper
{
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left; // x position of upper-left corner
public int Top; // y position of upper-left corner
public int Right; // x position of lower-right corner
public int Bottom; // y position of lower-right corner
}
[DllImport("user32.dll")]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int height,
uint uFlags);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
#region ResizeRenderWindow
public static void ResizeRenderWindow(PresentationParameters presentationParameters)
{
RECT windowRect;
RECT clientRect;
if (GetWindowRect(presentationParameters.DeviceWindowHandle, out windowRect) &&
GetClientRect(presentationParameters.DeviceWindowHandle, out clientRect))
{
int width = presentationParameters.BackBufferWidth + ((windowRect.Right - windowRect.Left) - clientRect.Right);
int height = presentationParameters.BackBufferHeight + ((windowRect.Bottom - windowRect.Top) - clientRect.Bottom);
SetWindowPos(presentationParameters.DeviceWindowHandle, IntPtr.Zero, windowRect.Left, windowRect.Top, width,
height, 0);
}
}
#endregion
}
}