Пример #1
0
        private void SetRenderWindowTitle(string title)
        {
            MyRenderThread renderThread = MySandboxGame.Static?.GameRenderComponent?.RenderThread;

            if (renderThread == null)
            {
                return;
            }
            FieldInfo renderWindowField = typeof(MyRenderThread).GetField("m_renderWindow",
                                                                          BindingFlags.Instance | BindingFlags.NonPublic);

            if (renderWindowField == null)
            {
                return;
            }
            var window = renderWindowField.GetValue(MySandboxGame.Static.GameRenderComponent.RenderThread) as System.Windows.Forms.Form;

            if (window != null)
            {
                renderThread.Invoke(() =>
                {
                    window.Text = title;
                });
            }
        }
        public void SetMaxFPS(float maxFrameRate)
        {
            MyRenderThread renderThread = MySandboxGame.Static.GameRenderComponent.RenderThread;
            FieldInfo      field        = renderThread.GetType().GetField("m_waiter", BindingFlags.Instance | BindingFlags.NonPublic);
            FieldInfo      field2       = renderThread.GetType().GetField("m_timer", BindingFlags.Instance | BindingFlags.NonPublic);

            field.SetValue(renderThread, new WaitForTargetFrameRate((MyGameTimer)field2.GetValue(renderThread), maxFrameRate));
        }
 /// <summary>
 /// Stops and clears render thread
 /// </summary>
 public void Stop()
 {
     RenderThread.Exit();
     RenderThread = null;
 }
 public void StartSync(MyGameTimer timer, IMyRenderWindow window, MyRenderDeviceSettings? settings, MyRenderQualityEnum renderQuality, float maxFrameRate)
 {
     RenderThread = MyRenderThread.StartSync(timer, window, settings, renderQuality, maxFrameRate);
 }
 /// <summary>
 /// Creates and starts render thread
 /// </summary>
 public void Start(MyGameTimer timer, InitHandler windowInitializer, MyRenderDeviceSettings? settingsToTry, MyRenderQualityEnum renderQuality, float maxFrameRate)
 {
     RenderThread = MyRenderThread.Start(timer, windowInitializer, settingsToTry, renderQuality, maxFrameRate);
 }