示例#1
0
        internal void OnGraphicsContextInitialized(GLControl context, WindowsFormsHost host)
        {
            m_control = context;

            m_editorCore             = new EditorCore();
            m_intervalTimer          = new System.Windows.Forms.Timer();
            m_intervalTimer.Interval = 16; // 60 FPS roughly
            m_intervalTimer.Enabled  = true;
            m_intervalTimer.Tick    += (args, o) =>
            {
                Vector2 mousePosGlobal     = new Vector2(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y);
                Vector2 glControlPosGlobal = new Vector2((float)host.PointToScreen(new Point(0, 0)).X, (float)host.PointToScreen(new Point(0, 0)).Y);

                var delta = mousePosGlobal - glControlPosGlobal;

                delta.X = MathE.Clamp(delta.X, 0, m_control.Width);
                delta.Y = MathE.Clamp(delta.Y, 0, m_control.Height);

                ((MainWindow)Application.Current.MainWindow).Tick();

                m_editorCore.GetWorldByName("main").Input.SetMousePosition(delta);
                m_editorCore.Tick();

                if (m_control != null)
                {
                    m_control.SwapBuffers();
                }
            };

            m_editorCore.PropertyChanged += OnEditorPropertyChanged;
            EntityOutliner.m_world        = m_editorCore.GetWorldByName("main");
        }
示例#2
0
 internal void OnOutputResized(float width, float height)
 {
     m_editorCore.GetWorldByName("main").RenderSystem.SetOutputSize(width, height);
 }