/// <inheritdoc /> public void Initialize(ref GameGraphicsParameters parameters) { if (_isInitialized) { return; } _renderForm.WindowState = parameters.DisplayType == DisplayType.FullscreenWindow ? RenderForm.FormWindowState.Maximized : RenderForm.FormWindowState.Normal; _renderForm.BorderStyle = parameters.DisplayType == DisplayType.Window ? RenderForm.FormBorderStyle.Fixed : RenderForm.FormBorderStyle.None; parameters.Handle = _renderForm.CreateWindow(parameters.Width, parameters.Height); if (parameters.DisplayType == DisplayType.FullscreenWindow) { User32.GetClientRect(parameters.Handle, out RECT rcRect); parameters.Width = rcRect.RightBottom.X; parameters.Height = rcRect.RightBottom.Y; } bool isMouseVisible = parameters.IsMouseVisible; bool clipCursor = parameters.ClipCursor; _renderForm.MouseEnter += hWnd => { if (!isMouseVisible) { User32.ShowCursor(false); } if (clipCursor) { RECT rect = new RECT(Width, Height); if (User32.ClientToScreen(hWnd, ref rect.LeftTop) && User32.ClientToScreen(hWnd, ref rect.RightBottom)) { User32.ClipCursor(ref rect); } } }; _renderForm.MouseLeave += hWnd => { if (!isMouseVisible) { User32.ShowCursor(true); } }; if (clipCursor) { RECT rect = new RECT(Width, Height); if (User32.ClientToScreen(parameters.Handle, ref rect.LeftTop) && User32.ClientToScreen(parameters.Handle, ref rect.RightBottom)) { User32.ClipCursor(ref rect); } } _isInitialized = true; }