protected void OnSizeChanged(int newWidth, int newHeight) { if (PresentationSource.FromVisual(this) != null) { Point upperLeft = PointToScreen(new Point(0, 0)); CRenderer renderer = CRenderer.Instance; renderer.Dispatch(ERendererDispatcherPriority.BeginFrame, () => renderer.Resize(newWidth, newHeight, (int)upperLeft.X, (int)upperLeft.Y, Hwnd)); CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { World?.ViewManager.ResizeView(newWidth, newHeight, (float)upperLeft.X, (float)upperLeft.Y); }); } }
protected override void OnResizeEnd(EventArgs e) { if (engineWorld != null) { System.Drawing.Point topLeft = PointToScreen(new System.Drawing.Point(0, 0)); CRenderer renderer = CRenderer.Instance; IntPtr handlePtr = Handle; renderer.Dispatch(ERendererDispatcherPriority.BeginFrame, () => renderer.Resize(ClientSize.Width, ClientSize.Height, topLeft.X, topLeft.Y, handlePtr)); CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { engineWorld.ViewManager.ResizeView(ClientSize.Width, ClientSize.Height, topLeft.X, topLeft.Y); }); } base.OnResizeEnd(e); }
private void ShowWorld(CWorld world) { engineWorld = world; System.Drawing.Point topLeft = PointToScreen(new System.Drawing.Point(0, 0)); CRenderer renderer = CRenderer.Instance; IntPtr handlePtr = Handle; renderer.Dispatch(ERendererDispatcherPriority.BeginFrame, () => renderer.Resize(ClientSize.Width, ClientSize.Height, topLeft.X, topLeft.Y, handlePtr)); CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { engineWorld.ViewManager.ResizeView(ClientSize.Width, ClientSize.Height, topLeft.X, topLeft.Y); }); Show(); }
internal void CreateEngineAndShow() { RenderFormSurface surface = new RenderFormSurface(this); CLogger logger = new CLogger("game.log", true, true, true); CInitializer initializer = new CInitializer(); initializer.Add("Viewport"); initializer.Add <IRenderSurface>(surface); initializer.Add(logger); CEngine.Create(initializer, true); CKlaxScriptRegistry dummy = CKlaxScriptRegistry.Instance; Input.SetReferenceHWND(Handle); Input.CursorVisibilitySetter = (arg) => { if (arg) { Cursor.Show(); } else { Cursor.Hide(); } }; Width = WindowWidth; Height = WindowHeight; CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { CEngine.Instance.LoadWorld(null, WorldLoadedCallback); }); Point size = new Point(ClientSize.Width, ClientSize.Height); System.Drawing.Point topLeft = PointToScreen(new System.Drawing.Point(0, 0)); IntPtr handlePtr = Handle; CRenderer renderer = CRenderer.Instance; CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { renderer.Resize(size.X, size.Y, topLeft.X, topLeft.Y, handlePtr); CEngine.Instance.CurrentWorld.StartPlayMode(); }); }