Exemplo n.º 1
0
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     if (RenderDoc.IsInstalled() && !RenderDoc.IsLoaded())
     {
         menu.AddItem(GameView.Styles.loadRenderDocContent, false, new GenericMenu.MenuFunction(this.LoadRenderDoc));
     }
 }
Exemplo n.º 2
0
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     if (RenderDoc.IsInstalled() && !RenderDoc.IsLoaded())
     {
         menu.AddItem(new GUIContent("Load RenderDoc"), false, new GenericMenu.MenuFunction(this.LoadRenderDoc));
     }
 }
Exemplo n.º 3
0
 public VeldridEngine(GraphicsBackend backend, bool useRenderDoc)
 {
     On <LoadRenderDocEvent>(e =>
     {
         if (_renderDoc == null && RenderDoc.Load(out _renderDoc))
         {
             _newBackend     = GraphicsDevice.BackendType;
             _recreateWindow = true;
         }
     });
     On <GarbageCollectionEvent>(e => GC.Collect());
     On <QuitEvent>(e => _done = true);
     On <RunRenderDocEvent>(e => _renderDoc?.LaunchReplayUI());
     On <SetCursorPositionEvent>(e => _pendingCursorUpdate = new Vector2(e.X, e.Y));
     On <ToggleFullscreenEvent>(e => ToggleFullscreenState());
     On <ToggleHardwareCursorEvent>(e => _window.CursorVisible = !_window.CursorVisible);
     On <ToggleResizableEvent>(e => _window.Resizable          = !_window.Resizable);
     On <ToggleVisibleBorderEvent>(e => _window.BorderVisible  = !_window.BorderVisible);
     On <SetMsaaLevelEvent>(e => _newSampleCount = e.SampleCount switch
     {
         1 => TextureSampleCount.Count1,
         2 => TextureSampleCount.Count2,
         4 => TextureSampleCount.Count4,
         8 => TextureSampleCount.Count8,
         16 => TextureSampleCount.Count16,
         32 => TextureSampleCount.Count32,
         _ => throw new InvalidOperationException($"Invalid sample count {e.SampleCount}")
     });
Exemplo n.º 4
0
        private void DoToolbarGUI()
        {
            ScriptableSingleton <GameViewSizes> .instance.RefreshStandaloneAndWebplayerDefaultSizes();

            if (ScriptableSingleton <GameViewSizes> .instance.GetChangeID() != this.m_SizeChangeID)
            {
                this.EnsureSelectedSizeAreValid();
                this.m_SizeChangeID = ScriptableSingleton <GameViewSizes> .instance.GetChangeID();
            }
            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            if (this.ShouldShowMultiDisplayOption())
            {
                GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.Width(80f) };
                int num = EditorGUILayout.Popup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopup, optionArray1);
                EditorGUILayout.Space();
                if (num != this.m_TargetDisplay)
                {
                    this.m_TargetDisplay = num;
                    this.GameViewAspectWasChanged();
                }
            }
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(160f) };
            EditorGUILayout.GameViewSizePopup(currentSizeGroupType, this.selectedSizeIndex, new Action <int, object>(this.SelectionCallback), EditorStyles.toolbarDropDown, options);
            if (FrameDebuggerUtility.IsLocalEnabled())
            {
                GUILayout.FlexibleSpace();
                Color color = GUI.color;
                GUI.color *= AnimationMode.animatedPropertyColor;
                GUILayout.Label("Frame Debugger on", EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUI.color = color;
                if (Event.current.type == EventType.Repaint)
                {
                    FrameDebuggerWindow.RepaintAll();
                }
            }
            GUILayout.FlexibleSpace();
            if (RenderDoc.IsLoaded())
            {
                EditorGUI.BeginDisabledGroup(!RenderDoc.IsSupported());
                if (GUILayout.Button(this.renderdocContent, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    base.m_Parent.CaptureRenderDoc();
                    GUIUtility.ExitGUI();
                }
                EditorGUI.EndDisabledGroup();
            }
            this.m_MaximizeOnPlay         = GUILayout.Toggle(this.m_MaximizeOnPlay, "Maximize on Play", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, "Mute audio", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            this.m_Stats = GUILayout.Toggle(this.m_Stats, "Stats", EditorStyles.toolbarButton, new GUILayoutOption[0]);
            Rect position = GUILayoutUtility.GetRect(this.gizmosContent, s_GizmoButtonStyle);
            Rect rect2    = new Rect(position.xMax - s_GizmoButtonStyle.border.right, position.y, (float)s_GizmoButtonStyle.border.right, position.height);

            if (EditorGUI.ButtonMouseDown(rect2, GUIContent.none, FocusType.Passive, GUIStyle.none) && AnnotationWindow.ShowAtPosition(GUILayoutUtility.topLevel.GetLast(), true))
            {
                GUIUtility.ExitGUI();
            }
            this.m_Gizmos = GUI.Toggle(position, this.m_Gizmos, this.gizmosContent, s_GizmoButtonStyle);
            GUILayout.EndHorizontal();
        }
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     menu.AddItem(new GUIContent("Reload"), false, m_Main.InitSimulation);
     if (RenderDoc.IsInstalled() && !RenderDoc.IsLoaded())
     {
         menu.AddItem(EditorGUIUtility.TrTextContent(RenderDocUtil.loadRenderDocLabel), false, LoadRenderDoc);
     }
 }
Exemplo n.º 6
0
 private void LoadRenderDoc()
 {
     if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         RenderDoc.Load();
         ShaderUtil.RecreateGfxDevice();
     }
 }
Exemplo n.º 7
0
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     if (RenderDoc.IsInstalled() && !RenderDoc.IsLoaded())
     {
         menu.AddItem(Styles.loadRenderDocContent, false, LoadRenderDoc);
     }
     menu.AddItem(Styles.noCameraWarningContextMenuContent, m_NoCameraWarning, ToggleNoCameraWarning);
     menu.AddItem(Styles.clearEveryFrameContextMenuContent, m_ClearInEditMode, ToggleClearInEditMode);
 }
Exemplo n.º 8
0
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     if (RenderDoc.IsInstalled() && !RenderDoc.IsLoaded())
     {
         menu.AddItem(GameView.Styles.loadRenderDocContent, false, new GenericMenu.MenuFunction(this.LoadRenderDoc));
     }
     menu.AddItem(GameView.Styles.noCameraWarningContextMenuContent, this.m_NoCameraWarning, new GenericMenu.MenuFunction(this.ToggleNoCameraWarning));
     menu.AddItem(GameView.Styles.clearEveryFrameContextMenuContent, this.m_ClearInEditMode, new GenericMenu.MenuFunction(this.ToggleClearInEditMode));
 }
Exemplo n.º 9
0
        private string GetWordDocumentFromHtml(string outputFileName)
        {
            var renderDoc   = new RenderDoc();
            var html        = File.ReadAllText(outputFileName);
            var docFileName = Path.Combine(RootFolder, TempFolder) + @"\" + $"{Path.GetFileNameWithoutExtension(outputFileName)}_mod.{GetOutputFileNameExtension(OutputPresentationType.Word)}";

            renderDoc.HtmlToWordPartial(html, docFileName);
            DeleteFile(outputFileName);


            return(docFileName);
        }
Exemplo n.º 10
0
        public static void Init()
        {
            string CapturePath = Path.GetFullPath("./RenderDocCapture/");

            if (!Directory.Exists(CapturePath))
            {
                Directory.CreateDirectory(CapturePath);
            }

            if (RenderDoc.Load(out RDoc))
            {
                RDoc.SetCaptureSavePath(CapturePath);
            }
        }
Exemplo n.º 11
0
        private void Update(float deltaSeconds)
        {
            _fta.AddTime(deltaSeconds);
            _scene.Update(deltaSeconds);

            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("Settings"))
                {
                    if (ImGui.BeginMenu("Graphics Backend"))
                    {
                        if (ImGui.MenuItem("Vulkan", string.Empty, _gd.BackendType == GraphicsBackend.Vulkan, GraphicsDevice.IsBackendSupported(GraphicsBackend.Vulkan)))
                        {
                            ChangeBackend(GraphicsBackend.Vulkan);
                        }
                        if (ImGui.MenuItem("OpenGL", string.Empty, _gd.BackendType == GraphicsBackend.OpenGL, GraphicsDevice.IsBackendSupported(GraphicsBackend.OpenGL)))
                        {
                            ChangeBackend(GraphicsBackend.OpenGL);
                        }
                        if (ImGui.MenuItem("OpenGL ES", string.Empty, _gd.BackendType == GraphicsBackend.OpenGLES, GraphicsDevice.IsBackendSupported(GraphicsBackend.OpenGLES)))
                        {
                            ChangeBackend(GraphicsBackend.OpenGLES);
                        }
                        if (ImGui.MenuItem("Direct3D 11", string.Empty, _gd.BackendType == GraphicsBackend.Direct3D11, GraphicsDevice.IsBackendSupported(GraphicsBackend.Direct3D11)))
                        {
                            ChangeBackend(GraphicsBackend.Direct3D11);
                        }
                        if (ImGui.MenuItem("Metal", string.Empty, _gd.BackendType == GraphicsBackend.Metal, GraphicsDevice.IsBackendSupported(GraphicsBackend.Metal)))
                        {
                            ChangeBackend(GraphicsBackend.Metal);
                        }
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("MSAA"))
                    {
                        if (ImGui.Combo("MSAA", ref _msaaOption, _msaaOptions, _msaaOptions.Length))
                        {
                            ChangeMsaa(_msaaOption);
                        }

                        ImGui.EndMenu();
                    }
                    bool threadedRendering = _scene.ThreadedRendering;
                    if (ImGui.MenuItem("Render with multiple threads", string.Empty, threadedRendering, true))
                    {
                        _scene.ThreadedRendering = !_scene.ThreadedRendering;
                    }
                    bool tinted = _fsq.UseTintedTexture;
                    if (ImGui.MenuItem("Tinted output", string.Empty, tinted, true))
                    {
                        _fsq.UseTintedTexture = !tinted;
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Window"))
                {
                    bool isFullscreen = _window.WindowState == WindowState.BorderlessFullScreen;
                    if (ImGui.MenuItem("Fullscreen", "F11", isFullscreen, true))
                    {
                        ToggleFullscreenState();
                    }
                    if (ImGui.MenuItem("Always Recreate Sdl2Window", string.Empty, _recreateWindow, true))
                    {
                        _recreateWindow = !_recreateWindow;
                    }
                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip(
                            "Causes a new OS window to be created whenever the graphics backend is switched. This is much safer, and is the default.");
                    }
                    if (ImGui.MenuItem("sRGB Swapchain Format", string.Empty, _colorSrgb, true))
                    {
                        _colorSrgb = !_colorSrgb;
                        ChangeBackend(_gd.BackendType);
                    }
                    bool vsync = _gd.SyncToVerticalBlank;
                    if (ImGui.MenuItem("VSync", string.Empty, vsync, true))
                    {
                        _gd.SyncToVerticalBlank = !_gd.SyncToVerticalBlank;
                    }
                    bool resizable = _window.Resizable;
                    if (ImGui.MenuItem("Resizable Window", string.Empty, resizable))
                    {
                        _window.Resizable = !_window.Resizable;
                    }
                    bool bordered = _window.BorderVisible;
                    if (ImGui.MenuItem("Visible Window Border", string.Empty, bordered))
                    {
                        _window.BorderVisible = !_window.BorderVisible;
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Materials"))
                {
                    if (ImGui.BeginMenu("Brick"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Brick);
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Vase"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Vase);
                        ImGui.EndMenu();
                    }
                    if (ImGui.BeginMenu("Reflective"))
                    {
                        DrawIndexedMaterialMenu(CommonMaterials.Reflective);
                        ImGui.EndMenu();
                    }

                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Debug"))
                {
                    if (ImGui.MenuItem("Refresh Device Objects"))
                    {
                        RefreshDeviceObjects(1);
                    }
                    if (ImGui.MenuItem("Refresh Device Objects (10 times)"))
                    {
                        RefreshDeviceObjects(10);
                    }
                    if (ImGui.MenuItem("Refresh Device Objects (100 times)"))
                    {
                        RefreshDeviceObjects(100);
                    }
                    if (_controllerTracker != null)
                    {
                        if (ImGui.MenuItem("Controller State"))
                        {
                            _controllerDebugMenu = true;
                        }
                    }
                    else
                    {
                        if (ImGui.MenuItem("Connect to Controller"))
                        {
                            Sdl2ControllerTracker.CreateDefault(out _controllerTracker);
                            _scene.Camera.Controller = _controllerTracker;
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("RenderDoc"))
                {
                    if (_renderDoc == null)
                    {
                        if (ImGui.MenuItem("Load"))
                        {
                            if (RenderDoc.Load(out _renderDoc))
                            {
                                ChangeBackend(_gd.BackendType);
                            }
                        }
                    }
                    else
                    {
                        if (ImGui.MenuItem("Trigger Capture"))
                        {
                            _renderDoc.TriggerCapture();
                        }
                        if (ImGui.BeginMenu("Options"))
                        {
                            bool allowVsync = _renderDoc.AllowVSync;
                            if (ImGui.Checkbox("Allow VSync", ref allowVsync))
                            {
                                _renderDoc.AllowVSync = allowVsync;
                            }
                            bool validation = _renderDoc.APIValidation;
                            if (ImGui.Checkbox("API Validation", ref validation))
                            {
                                _renderDoc.APIValidation = validation;
                            }
                            int delayForDebugger = (int)_renderDoc.DelayForDebugger;
                            if (ImGui.InputInt("Debugger Delay", ref delayForDebugger))
                            {
                                delayForDebugger            = Math.Clamp(delayForDebugger, 0, int.MaxValue);
                                _renderDoc.DelayForDebugger = (uint)delayForDebugger;
                            }
                            bool verifyBufferAccess = _renderDoc.VerifyBufferAccess;
                            if (ImGui.Checkbox("Verify Buffer Access", ref verifyBufferAccess))
                            {
                                _renderDoc.VerifyBufferAccess = verifyBufferAccess;
                            }
                            bool overlayEnabled = _renderDoc.OverlayEnabled;
                            if (ImGui.Checkbox("Overlay Visible", ref overlayEnabled))
                            {
                                _renderDoc.OverlayEnabled = overlayEnabled;
                            }
                            bool overlayFrameRate = _renderDoc.OverlayFrameRate;
                            if (ImGui.Checkbox("Overlay Frame Rate", ref overlayFrameRate))
                            {
                                _renderDoc.OverlayFrameRate = overlayFrameRate;
                            }
                            bool overlayFrameNumber = _renderDoc.OverlayFrameNumber;
                            if (ImGui.Checkbox("Overlay Frame Number", ref overlayFrameNumber))
                            {
                                _renderDoc.OverlayFrameNumber = overlayFrameNumber;
                            }
                            bool overlayCaptureList = _renderDoc.OverlayCaptureList;
                            if (ImGui.Checkbox("Overlay Capture List", ref overlayCaptureList))
                            {
                                _renderDoc.OverlayCaptureList = overlayCaptureList;
                            }
                            ImGui.EndMenu();
                        }
                        if (ImGui.MenuItem("Launch Replay UI"))
                        {
                            _renderDoc.LaunchReplayUI();
                        }
                    }
                    ImGui.EndMenu();
                }

                if (_controllerDebugMenu)
                {
                    if (ImGui.Begin("Controller State", ref _controllerDebugMenu, ImGuiWindowFlags.NoCollapse))
                    {
                        if (_controllerTracker != null)
                        {
                            ImGui.Columns(2);
                            ImGui.Text($"Name: {_controllerTracker.ControllerName}");
                            foreach (SDL_GameControllerAxis axis in (SDL_GameControllerAxis[])Enum.GetValues(typeof(SDL_GameControllerAxis)))
                            {
                                ImGui.Text($"{axis}: {_controllerTracker.GetAxis(axis)}");
                            }
                            ImGui.NextColumn();
                            foreach (SDL_GameControllerButton button in (SDL_GameControllerButton[])Enum.GetValues(typeof(SDL_GameControllerButton)))
                            {
                                ImGui.Text($"{button}: {_controllerTracker.IsPressed(button)}");
                            }
                        }
                        else
                        {
                            ImGui.Text("No controller detected.");
                        }
                    }
                    ImGui.End();
                }

                ImGui.Text(_fta.CurrentAverageFramesPerSecond.ToString("000.0 fps / ") + _fta.CurrentAverageFrameTimeMilliseconds.ToString("#00.00 ms"));

                ImGui.EndMainMenuBar();
            }

            if (InputTracker.GetKeyDown(Key.F11))
            {
                ToggleFullscreenState();
            }

            if (InputTracker.GetKeyDown(Key.Keypad6))
            {
                _window.X += 10;
            }
            if (InputTracker.GetKeyDown(Key.Keypad4))
            {
                _window.X -= 10;
            }
            if (InputTracker.GetKeyDown(Key.Keypad8))
            {
                _window.Y += 10;
            }
            if (InputTracker.GetKeyDown(Key.Keypad2))
            {
                _window.Y -= 10;
            }

            _window.Title = _gd.BackendType.ToString();
        }
Exemplo n.º 12
0
        private void DoToolbarGUI()
        {
            GameViewSizes.instance.RefreshStandaloneAndRemoteDefaultSizes();

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                var availableTypes = GetAvailableWindowTypes();
                if (availableTypes.Count > 1)
                {
                    var typeNames = availableTypes.Values.ToList();
                    var types     = availableTypes.Keys.ToList();
                    int viewIndex = EditorGUILayout.Popup(typeNames.IndexOf(titleContent.text), typeNames.ToArray(),
                                                          EditorStyles.toolbarPopup,
                                                          GUILayout.Width(90));
                    EditorGUILayout.Space();
                    if (types[viewIndex] != typeof(GameView))
                    {
                        SwapMainWindow(types[viewIndex]);
                    }
                }

                if (ModuleManager.ShouldShowMultiDisplayOption())
                {
                    int display = EditorGUILayout.Popup(targetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopupLeft, GUILayout.Width(80));
                    if (display != targetDisplay)
                    {
                        targetDisplay = display;
                        UpdateZoomAreaAndParent();
                    }
                }
                EditorGUILayout.GameViewSizePopup(currentSizeGroupType, selectedSizeIndex, this, EditorStyles.toolbarPopup, GUILayout.Width(160f));

                DoZoomSlider();
                // If the previous platform and current does not match, update the scale
                if ((int)currentSizeGroupType != prevSizeGroupType)
                {
                    UpdateZoomAreaAndParent();
                    // Update the platform to the recent one
                    prevSizeGroupType = (int)currentSizeGroupType;
                }

                if (FrameDebuggerUtility.IsLocalEnabled())
                {
                    GUILayout.FlexibleSpace();
                    Color oldCol = GUI.color;
                    // This has nothing to do with animation recording.  Can we replace this color with something else?
                    GUI.color *= AnimationMode.recordedPropertyColor;
                    GUILayout.Label(Styles.frameDebuggerOnContent, EditorStyles.toolbarLabel);
                    GUI.color = oldCol;
                    // Make frame debugger windows repaint after each time game view repaints.
                    // We want them to always display the latest & greatest game view
                    // rendering state.
                    if (Event.current.type == EventType.Repaint)
                    {
                        FrameDebuggerWindow.RepaintAll();
                    }
                }

                GUILayout.FlexibleSpace();

                if (RenderDoc.IsLoaded())
                {
                    using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported()))
                    {
                        if (GUILayout.Button(Styles.renderdocContent, EditorStyles.toolbarButton))
                        {
                            m_Parent.CaptureRenderDocScene();
                            GUIUtility.ExitGUI();
                        }
                    }
                }

                // Allow the user to select how the XR device will be rendered during "Play In Editor"
                if (PlayerSettings.virtualRealitySupported)
                {
                    int selectedRenderMode = EditorGUILayout.Popup(m_XRRenderMode, Styles.xrRenderingModes, EditorStyles.toolbarPopup, GUILayout.Width(80));
                    SetXRRenderMode(selectedRenderMode);
                }

                maximizeOnPlay = GUILayout.Toggle(maximizeOnPlay, Styles.maximizeOnPlayContent, EditorStyles.toolbarButton);

                EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, Styles.muteContent, EditorStyles.toolbarButton);

                m_Stats = GUILayout.Toggle(m_Stats, Styles.statsContent, EditorStyles.toolbarButton);

                if (EditorGUILayout.DropDownToggle(ref m_Gizmos, Styles.gizmosContent, EditorStyles.toolbarDropDownToggleRight))
                {
                    Rect rect = GUILayoutUtility.topLevel.GetLast();
                    if (AnnotationWindow.ShowAtPosition(rect, true))
                    {
                        GUIUtility.ExitGUI();
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 13
0
        private void DoToolbarGUI()
        {
            ScriptableSingleton <GameViewSizes> .instance.RefreshStandaloneAndRemoteDefaultSizes();

            GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            if (ModuleManager.ShouldShowMultiDisplayOption())
            {
                int num = EditorGUILayout.Popup(this.m_TargetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopup, new GUILayoutOption[]
                {
                    GUILayout.Width(80f)
                });
                EditorGUILayout.Space();
                if (num != this.m_TargetDisplay)
                {
                    this.m_TargetDisplay = num;
                    this.UpdateZoomAreaAndParent();
                }
            }
            EditorGUILayout.GameViewSizePopup(GameView.currentSizeGroupType, this.selectedSizeIndex, this, EditorStyles.toolbarPopup, new GUILayoutOption[]
            {
                GUILayout.Width(160f)
            });
            this.DoZoomSlider();
            if (FrameDebuggerUtility.IsLocalEnabled())
            {
                GUILayout.FlexibleSpace();
                Color color = GUI.color;
                GUI.color *= AnimationMode.recordedPropertyColor;
                GUILayout.Label(GameView.Styles.frameDebuggerOnContent, EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUI.color = color;
                if (Event.current.type == EventType.Repaint)
                {
                    FrameDebuggerWindow.RepaintAll();
                }
            }
            GUILayout.FlexibleSpace();
            if (RenderDoc.IsLoaded())
            {
                using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported()))
                {
                    if (GUILayout.Button(GameView.Styles.renderdocContent, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                    {
                        this.m_Parent.CaptureRenderDoc();
                        GUIUtility.ExitGUI();
                    }
                }
            }
            this.m_MaximizeOnPlay         = GUILayout.Toggle(this.m_MaximizeOnPlay, GameView.Styles.maximizeOnPlayContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, GameView.Styles.muteContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            this.m_Stats = GUILayout.Toggle(this.m_Stats, GameView.Styles.statsContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
            Rect rect     = GUILayoutUtility.GetRect(GameView.Styles.gizmosContent, GameView.Styles.gizmoButtonStyle);
            Rect position = new Rect(rect.xMax - (float)GameView.Styles.gizmoButtonStyle.border.right, rect.y, (float)GameView.Styles.gizmoButtonStyle.border.right, rect.height);

            if (EditorGUI.DropdownButton(position, GUIContent.none, FocusType.Passive, GUIStyle.none))
            {
                Rect last = GUILayoutUtility.topLevel.GetLast();
                if (AnnotationWindow.ShowAtPosition(last, true))
                {
                    GUIUtility.ExitGUI();
                }
            }
            this.m_Gizmos = GUI.Toggle(rect, this.m_Gizmos, GameView.Styles.gizmosContent, GameView.Styles.gizmoButtonStyle);
            GUILayout.EndHorizontal();
        }
Exemplo n.º 14
0
        private void DoToolbarGUI()
        {
            GameViewSizes.instance.RefreshStandaloneAndRemoteDefaultSizes();

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            {
                if (ModuleManager.ShouldShowMultiDisplayOption())
                {
                    int display = EditorGUILayout.Popup(m_TargetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopup, GUILayout.Width(80));
                    EditorGUILayout.Space();
                    if (display != m_TargetDisplay)
                    {
                        m_TargetDisplay = display;
                        UpdateZoomAreaAndParent();
                    }
                }
                EditorGUILayout.GameViewSizePopup(currentSizeGroupType, selectedSizeIndex, this, EditorStyles.toolbarPopup, GUILayout.Width(160f));

                DoZoomSlider();

                if (FrameDebuggerUtility.IsLocalEnabled())
                {
                    GUILayout.FlexibleSpace();
                    Color oldCol = GUI.color;
                    // This has nothing to do with animation recording.  Can we replace this color with something else?
                    GUI.color *= AnimationMode.recordedPropertyColor;
                    GUILayout.Label(Styles.frameDebuggerOnContent, EditorStyles.miniLabel);
                    GUI.color = oldCol;
                    // Make frame debugger windows repaint after each time game view repaints.
                    // We want them to always display the latest & greatest game view
                    // rendering state.
                    if (Event.current.type == EventType.Repaint)
                    {
                        FrameDebuggerWindow.RepaintAll();
                    }
                }

                GUILayout.FlexibleSpace();

                if (RenderDoc.IsLoaded())
                {
                    using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported()))
                    {
                        if (GUILayout.Button(Styles.renderdocContent, EditorStyles.toolbarButton))
                        {
                            m_Parent.CaptureRenderDoc();
                            GUIUtility.ExitGUI();
                        }
                    }
                }

                m_MaximizeOnPlay = GUILayout.Toggle(m_MaximizeOnPlay, Styles.maximizeOnPlayContent, EditorStyles.toolbarButton);
                EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, Styles.muteContent, EditorStyles.toolbarButton);
                m_Stats = GUILayout.Toggle(m_Stats, Styles.statsContent, EditorStyles.toolbarButton);

                Rect r         = GUILayoutUtility.GetRect(Styles.gizmosContent, Styles.gizmoButtonStyle);
                Rect rightRect = new Rect(r.xMax - Styles.gizmoButtonStyle.border.right, r.y, Styles.gizmoButtonStyle.border.right, r.height);
                if (EditorGUI.DropdownButton(rightRect, GUIContent.none, FocusType.Passive, GUIStyle.none))
                {
                    Rect rect = GUILayoutUtility.topLevel.GetLast();
                    if (AnnotationWindow.ShowAtPosition(rect, true))
                    {
                        GUIUtility.ExitGUI();
                    }
                }
                m_Gizmos = GUI.Toggle(r, m_Gizmos, Styles.gizmosContent, Styles.gizmoButtonStyle);
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Setups the engine and initialises the window
        /// </summary>
        internal void MainLoop()
        {
            VesselLogger.Logger.Info("Initialising Vessel...");

            //Setup the window
            VesselWindow window;

            window = new VesselWindow(GraphicsDevice, config.Name, config.Width, config.Height);
            Window = window;

            // Initialise RenderDoc
            if (config.RenderDoc)
            {
                RenderDoc.Initialise();
            }

            //Initialise the Graphics Device
            GraphicsDevice.Initialise(window, config);
            Window.Invalidate();

            //Callback for the engine
            Initialise();

            VesselLogger.Logger.Info($"Started Vessel using {GraphicsDevice.GraphicsAPI}!");

            //Deltatime variables
            long      previousFrameTicks = 0;
            Stopwatch sw = new Stopwatch();

            sw.Start();

            //Main Loop
            while (Window.Exists)
            {
                Window.ProcessEvents();

                //Calculate delta-time
                long   currentFrameTicks = sw.ElapsedTicks;
                double deltaSeconds      = (currentFrameTicks - previousFrameTicks) / (double)Stopwatch.Frequency;

                //Wait till next frame if we are locking the target framerate
                while (LimitFrameRate && deltaSeconds < TargetFrameTime)
                {
                    currentFrameTicks = sw.ElapsedTicks;
                    deltaSeconds      = (currentFrameTicks - previousFrameTicks) / (double)Stopwatch.Frequency;
                }

                DeltaTime = (float)deltaSeconds;

                previousFrameTicks = currentFrameTicks;

                //Update method
                Update();

                //Only Draw if the window is still open
                if (!Window.Exists)
                {
                    break;
                }

                GraphicsDevice.OnFrameBegin();

                // Draw the scene
                GraphicsDevice.Debug.PushGroup("Draw Scene");
                Draw();
                GraphicsDevice.Debug.PopGroup();

                // Draw layers + post processing
                GraphicsDevice.Debug.PushGroup("Draw Layers");
                RenderLayers.Draw();
                GraphicsDevice.Debug.PopGroup();

                GraphicsDevice.OnFrameEnd();
            }

            // Cleanup
            VesselLogger.Logger.Info("Shutting down Vessel...");
            Exiting();
        }
Exemplo n.º 16
0
        public override void Load()
        {
            CrosshairTex = Engine.Load <Texture>("/content/textures/gui/crosshair_default.png");
            UtilityGun UtilGun = new UtilityGun();

            Console.WriteLine("Loading map");
            Engine.Map = BSPMap.LoadMap("/content/maps/lt_test.bsp");
            Engine.Map.InitPhysics();
            Console.WriteLine("Done!");

            PlayerSpawn[] SpawnPositions = Engine.Map.GetEntities <PlayerSpawn>().ToArray();
            PlayerEnt = new Player();
            PlayerEnt.SetPosition((PlySpawnPos = SpawnPositions.Random().SpawnPosition) + new Vector3(0, 100, 0));
            PlayerEnt.Camera.LookAt(Vector3.Zero);

            PlayerEnt.SetPosition(new Vector3(-285.1535f, -964.8776f, 229.2883f));

            Engine.Map.SpawnEntity(UtilGun);
            Engine.Map.SpawnEntity(PlayerEnt);
            PlayerEnt.WeaponPickUp(UtilGun);

            /*foreach (var L in Engine.Map.GetLights())
             *      Engine.Map.RemoveEntity(L);*/

            LightEmitter = Engine.Map.GetEntities <EntPhysics>().Skip(5).First();
            Light        = new DynamicLight(Vector3.Zero, Color.Red);
            Engine.Map.SpawnEntity(Light);


            EntStatic TestEntity = new EntStatic(new libTechModel(Obj.Load("content/models/cube.obj"), Engine.GetMaterial(FogMaterial.Name)));

            TestEntity.Model.Scale = new Vector3(120);             // 20
            //DragonEnt.Model.Position = new Vector3(0, -1120, 0);
            TestEntity.Model.Position = new Vector3(0, -1000, 0);
            Engine.Map.SpawnEntity(TestEntity);

            /*
             * EntStatic TestEntity2 = new EntStatic(new libTechModel(TestEntity.Model));
             * TestEntity2.Model.Position = new Vector3(240, -1000, 0);
             * Engine.Map.SpawnEntity(TestEntity2);
             * //*/

            PlayerEnt.Camera.LookAt(TestEntity.Position);



            Engine.Camera3D.MouseMovement = true;
            Engine.Window.CaptureCursor   = true;

            Engine.Window.OnMouseMoveDelta += (Wnd, X, Y) => {
                PlayerEnt.MouseMove(new Vector2(-X, -Y));
            };

            Engine.Window.OnKey += (Wnd, Key, Scancode, Pressed, Repeat, Mods) => {
                PlayerEnt.OnKey(Key, Pressed, Mods);
                if (Key == Key.Escape && Pressed)
                {
                    Engine.Exit();
                }

                if (Key == Key.F5 && Pressed)
                {
                    RenderDoc.CaptureFrame();
                }

                if (Key == Key.F6 && Pressed)
                {
                    if (!Debugger.IsAttached)
                    {
                        Debugger.Launch();
                    }
                }
            };
        }
Exemplo n.º 17
0
 public DrawTriangle()
     : base("BasicTest")
 {
     // Initialize RenderDoc before the graphics context.
     RenderDoc.Load(out this.renderDoc);
 }
Exemplo n.º 18
0
        /// <summary>
        /// Draws a utility window for interacting with RenderDoc
        /// </summary>
        public static void ShowRenderDocWindow()
        {
            if (RenderDoc.IsLoaded)
            {
                ImGui.SetNextWindowSize(new Vector2(264, 487));
            }
            else
            {
                ImGui.SetNextWindowSize(new Vector2(264, 80));
            }
            if (ImGui.Begin("RenderDoc"))
            {
                if (!RenderDoc.IsLoaded)
                {
                    if (ImGui.Button("Load RenderDoc"))
                    {
                        RenderDoc.Initialise();
                    }
                }
                else
                {
                    if (ImGui.Button("Start Replay UI"))
                    {
                        RenderDoc.LaunchReplayUI();
                    }

                    if (ImGui.Button("Capture Frame"))
                    {
                        RenderDoc.TriggerCapture();
                    }

                    ImGui.Text("Debug");
                    ImGui.BeginChild("Debug", new Vector2(0, 82), true);

                    bufferBool = RenderDoc.APIValidation;
                    ImGui.Checkbox("API Validation", ref bufferBool);
                    RenderDoc.APIValidation = bufferBool;

                    bufferBool = RenderDoc.VerifyBufferAccess;
                    ImGui.Checkbox("Verify Buffer Access", ref bufferBool);
                    RenderDoc.VerifyBufferAccess = bufferBool;

                    bufferBool = RenderDoc.DebugOutputMute;
                    ImGui.Checkbox("Debug Output Mute", ref bufferBool);
                    RenderDoc.DebugOutputMute = bufferBool;

                    ImGui.EndChild();

                    ImGui.Text("Behavior");
                    ImGui.BeginChild("Behavior", new Vector2(0, 160 + (RenderDoc.CaptureCallstacks ? 26 : 0)), true);

                    bufferBool = RenderDoc.AllowFullscreen;
                    ImGui.Checkbox("Allow Fullscreen", ref bufferBool);
                    RenderDoc.AllowFullscreen = bufferBool;

                    bufferBool = RenderDoc.AllowVSync;
                    ImGui.Checkbox("Allow V-Sync", ref bufferBool);
                    RenderDoc.AllowVSync = bufferBool;

                    bufferBool = RenderDoc.RefAllResources;
                    ImGui.Checkbox("Reference All Resources", ref bufferBool);
                    RenderDoc.RefAllResources = bufferBool;

                    bufferBool = RenderDoc.CaptureAllCmdLists;
                    ImGui.Checkbox("Capture All Command Lists", ref bufferBool);
                    RenderDoc.CaptureAllCmdLists = bufferBool;

                    bufferBool = RenderDoc.CaptureCallstacks;
                    ImGui.Checkbox("Capture Callstacks", ref bufferBool);
                    RenderDoc.CaptureCallstacks = bufferBool;

                    if (RenderDoc.CaptureCallstacks)
                    {
                        bufferBool = RenderDoc.CaptureCallstacksOnlyDraws;
                        ImGui.Checkbox("Capture Callstacks (Only Draws)", ref bufferBool);
                        RenderDoc.CaptureCallstacksOnlyDraws = bufferBool;
                    }

                    bufferBool = RenderDoc.HookIntoChildren;
                    ImGui.Checkbox("Hook Into Child Processes", ref bufferBool);
                    RenderDoc.HookIntoChildren = bufferBool;

                    ImGui.EndChild();

                    ImGui.Text("Overlay");
                    ImGui.BeginChild("Overlay", new Vector2(0, 26 + (RenderDoc.OverlayEnabled ? 26 * 3 : 10)), true);

                    bufferBool = RenderDoc.OverlayEnabled;
                    ImGui.Checkbox("Enable Overlay", ref bufferBool);
                    RenderDoc.OverlayEnabled = bufferBool;

                    if (RenderDoc.OverlayEnabled)
                    {
                        bufferBool = RenderDoc.OverlayFrameRate;
                        ImGui.Checkbox("Overlay Framerate", ref bufferBool);
                        RenderDoc.OverlayFrameRate = bufferBool;

                        bufferBool = RenderDoc.OverlayFrameNumber;
                        ImGui.Checkbox("Overlay Frame Number", ref bufferBool);
                        RenderDoc.OverlayFrameNumber = bufferBool;

                        bufferBool = RenderDoc.OverlayCaptureList;
                        ImGui.Checkbox("Overlay Capture List", ref bufferBool);
                        RenderDoc.OverlayCaptureList = bufferBool;
                    }

                    ImGui.EndChild();
                }
                ImGui.End();
            }
        }
Exemplo n.º 19
0
        unsafe public MapStudioNew()
        {
            CFG.AttemptLoadOrDefault();

            if (UseRenderdoc)
            {
                RenderDoc.Load(out RenderDocManager);
                RenderDocManager.OverlayEnabled = false;
            }

            WindowCreateInfo windowCI = new WindowCreateInfo
            {
                X                  = CFG.Current.GFX_Display_X,
                Y                  = CFG.Current.GFX_Display_Y,
                WindowWidth        = CFG.Current.GFX_Display_Width,
                WindowHeight       = CFG.Current.GFX_Display_Height,
                WindowInitialState = WindowState.Maximized,
                WindowTitle        = "Dark Souls Map Studio " + _version + " by Katalash",
            };
            GraphicsDeviceOptions gdOptions = new GraphicsDeviceOptions(false, PixelFormat.R32_Float, true, ResourceBindingModel.Improved, true, true, _colorSrgb);

#if DEBUG
            gdOptions.Debug = true;
#endif

            VeldridStartup.CreateWindowAndGraphicsDevice(
                windowCI,
                gdOptions,
                //VeldridStartup.GetPlatformDefaultBackend(),
                //GraphicsBackend.Metal,
                GraphicsBackend.Vulkan,

                //GraphicsBackend.Direct3D11,
                //GraphicsBackend.OpenGL,
                //GraphicsBackend.OpenGLES,
                out _window,
                out _gd);
            _window.Resized += () => _windowResized = true;
            _window.Moved   += (p) => _windowMoved = true;

            Sdl2Native.SDL_Init(SDLInitFlags.GameController);
            //Sdl2ControllerTracker.CreateDefault(out _controllerTracker);

            var factory = _gd.ResourceFactory;
            TextureSamplerResourceLayout = factory.CreateResourceLayout(new ResourceLayoutDescription(
                                                                            new ResourceLayoutElementDescription("SourceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment),
                                                                            new ResourceLayoutElementDescription("SourceSampler", ResourceKind.Sampler, ShaderStages.Fragment)));

            Scene.Renderer.Initialize(_gd);

            ImguiRenderer = new ImGuiRenderer(_gd, _gd.SwapchainFramebuffer.OutputDescription, CFG.Current.GFX_Display_Width,
                                              CFG.Current.GFX_Display_Height, ColorSpaceHandling.Legacy);
            MainWindowCommandList = factory.CreateCommandList();
            GuiCommandList        = factory.CreateCommandList();

            _assetLocator = new AssetLocator();
            MSBEditor     = new MsbEditor.MsbEditorScreen(_window, _gd, _assetLocator);
            ModelEditor   = new MsbEditor.ModelEditorScreen(_window, _gd, _assetLocator);
            ParamEditor   = new MsbEditor.ParamEditorScreen(_window, _gd);
            TextEditor    = new MsbEditor.TextEditorScreen(_window, _gd);

            MsbEditor.ParamBank.LoadParams(_assetLocator);
            MsbEditor.FMGBank.LoadFMGs(_assetLocator);
            MsbEditor.MtdBank.LoadMtds(_assetLocator);

            ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard;
            var fonts    = ImGui.GetIO().Fonts;
            var fileJp   = Path.Combine(AppContext.BaseDirectory, $@"Assets\Fonts\NotoSansCJKtc-Light.otf");
            var fontJp   = File.ReadAllBytes(fileJp);
            var fileEn   = Path.Combine(AppContext.BaseDirectory, $@"Assets\Fonts\RobotoMono-Light.ttf");
            var fontEn   = File.ReadAllBytes(fileEn);
            var fileIcon = Path.Combine(AppContext.BaseDirectory, $@"Assets\Fonts\forkawesome-webfont.ttf");
            var fontIcon = File.ReadAllBytes(fileIcon);
            //fonts.AddFontFromFileTTF($@"Assets\Fonts\NotoSansCJKtc-Medium.otf", 20.0f, null, fonts.GetGlyphRangesJapanese());
            fonts.Clear();
            fixed(byte *p = fontEn)
            {
                var ptr = ImGuiNative.ImFontConfig_ImFontConfig();
                var cfg = new ImFontConfigPtr(ptr);

                cfg.GlyphMinAdvanceX = 5.0f;
                cfg.OversampleH      = 5;
                cfg.OversampleV      = 5;
                var f = fonts.AddFontFromMemoryTTF((IntPtr)p, fontEn.Length, 14.0f, cfg, fonts.GetGlyphRangesDefault());
            }

            fixed(byte *p = fontJp)
            {
                var ptr = ImGuiNative.ImFontConfig_ImFontConfig();
                var cfg = new ImFontConfigPtr(ptr);

                cfg.MergeMode        = true;
                cfg.GlyphMinAdvanceX = 7.0f;
                cfg.OversampleH      = 5;
                cfg.OversampleV      = 5;
                var f = fonts.AddFontFromMemoryTTF((IntPtr)p, fontJp.Length, 16.0f, cfg, fonts.GetGlyphRangesJapanese());
            }

            fixed(byte *p = fontIcon)
            {
                ushort[] ranges = { ForkAwesome.IconMin, ForkAwesome.IconMax, 0 };
                var      ptr    = ImGuiNative.ImFontConfig_ImFontConfig();
                var      cfg    = new ImFontConfigPtr(ptr);

                cfg.MergeMode        = true;
                cfg.GlyphMinAdvanceX = 12.0f;
                cfg.OversampleH      = 5;
                cfg.OversampleV      = 5;
                ImFontGlyphRangesBuilder b = new ImFontGlyphRangesBuilder();

                fixed(ushort *r = ranges)
                {
                    var f = fonts.AddFontFromMemoryTTF((IntPtr)p, fontIcon.Length, 16.0f, cfg, (IntPtr)r);
                }
            }

            fonts.Build();
            ImguiRenderer.RecreateFontDeviceTexture();
            ImguiRenderer.OnSetupDone();

            var style = ImGui.GetStyle();
            style.TabBorderSize = 0;

            if (CFG.Current.LastProjectFile != null && CFG.Current.LastProjectFile != "")
            {
                if (File.Exists(CFG.Current.LastProjectFile))
                {
                    var project = MsbEditor.ProjectSettings.Deserialize(CFG.Current.LastProjectFile);
                    AttemptLoadProject(project, CFG.Current.LastProjectFile, false);
                }
            }
        }
Exemplo n.º 20
0
 void UpdateState()
 {
     style.display = RenderDoc.IsLoaded() && RenderDoc.IsSupported() ? DisplayStyle.Flex : DisplayStyle.None;
 }