private void Awake() { if (_controller == null) { _controller = new ImGuiController(); } }
public void Begin() { ImGuiController.ImGui_ImplOpenGL3_NewFrame(); ImGuiController.ImGui_ImplGlfw_NewFrame(); ImGui.NewFrame(); ImGuizmo.BeginFrame(); }
public override bool OnUserCreate() { _controller = new ImGuiController(ScreenWidth(), ScreenHeight(), this); velocity = new vf2d(0, 0); offset = new vf2d(0, 0); map = new Pixel[mapWidth, mapHeight]; intMap = new int[mapWidth, mapHeight]; Random rng = new Random(); for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { map[x, y] = new Pixel(x / (float)mapWidth, y / (float)mapHeight, 1f - (y / (float)mapHeight), 1f); intMap[x, y] = rng.Next(20); } } spr = new Sprite(0, 0); spr.LoadFromFile("assets/spritesheet03.png"); decal = new Decal(spr); mGameLayer = CreateLayer(); EnableLayer(mGameLayer, true); SetLayerCustomRenderFunction(mGameLayer, DrawImGui); return(true); }
/// <summary> /// Signals that the window is now loaded, which means we can load our graphics now. /// </summary> protected override void OnLoad() { base.OnLoad(); MasterRenderer.Load(); if (Settings.UseSystemUIScaling) { if (TryGetCurrentMonitorDpi(out float hdpi, out _)) { Settings.UIScaling = hdpi / 100; } else { Log.WriteInfo("Failed to fetch system dpi scaling."); } } controller = new ImGuiController(ClientSize.X, ClientSize.Y); controller.SetScale(Settings.UIScaling); window = new ImGuiWindow(this, controller); var minimum = ClientRectangle.Min; ClientRectangle = new Box2i(minimum.X, minimum.Y, Settings.GraphWidth + minimum.X, Settings.GraphHeight + minimum.Y); IsLoaded = true; }
private unsafe bool SetupComputeResources() { Debug.Assert(_gd is not null, "Init not called"); ResourceFactory factory = _gd.ResourceFactory; if (_gd.Features.ComputeShader is false) { Logging.RecordError("Error: Compute shaders are unavailable"); return(false); } byte[]? noteattribShaderBytes = ImGuiController.LoadEmbeddedShaderCode(factory, "sim-nodeAttrib", ShaderStages.Vertex); _nodeAttribShader = factory.CreateShader(new ShaderDescription(ShaderStages.Fragment, noteattribShaderBytes, "FS")); _nodeAttribComputeLayout = factory.CreateResourceLayout(new ResourceLayoutDescription( new ResourceLayoutElementDescription("Params", ResourceKind.UniformBuffer, ShaderStages.Compute), new ResourceLayoutElementDescription("nodeAttrib", ResourceKind.StructuredBufferReadOnly, ShaderStages.Compute), new ResourceLayoutElementDescription("edgeIndices", ResourceKind.StructuredBufferReadOnly, ShaderStages.Compute), new ResourceLayoutElementDescription("edgeData", ResourceKind.StructuredBufferReadOnly, ShaderStages.Compute), new ResourceLayoutElementDescription("resultData", ResourceKind.StructuredBufferReadWrite, ShaderStages.Compute))); _attribsParamsBuffer = VeldridGraphBuffers.TrackedVRAMAlloc(_gd, (uint)Unsafe.SizeOf <AttribShaderParams>(), BufferUsage.UniformBuffer, name: "AttribShaderParams"); ComputePipelineDescription attribCPL = new ComputePipelineDescription(_nodeAttribShader, _nodeAttribComputeLayout, 16, 16, 1); _nodeAttribComputePipeline = factory.CreateComputePipeline(attribCPL); return(true); }
/// <inheritdoc /> protected override void OnLoad() { Title = $"Box2DSharp Testbed - Runtime Version: {_environment}"; var testBaseType = typeof(TestBase); var testTypes = typeof(HelloWorld).Assembly.GetTypes() .Where(e => testBaseType.IsAssignableFrom(e) && !e.IsAbstract && e.GetCustomAttribute <TestCaseAttribute>() != null) .ToHashSet(); var inheritedTest = this.GetType() .Assembly.GetTypes() .Where( e => testBaseType.IsAssignableFrom(e) && e.GetCustomAttribute <TestInheritAttribute>() != null && e.GetCustomAttribute <TestCaseAttribute>() != null) .ToList(); foreach (var type in inheritedTest) { testTypes.Remove(type.BaseType); } var typeList = new List <Type>(testTypes.Count + inheritedTest.Count); typeList.AddRange(testTypes); typeList.AddRange(inheritedTest); Global.SetupTestCases(typeList); GL.ClearColor(0.2f, 0.2f, 0.2f, 1.0f); _controller = new ImGuiController(Size.X, Size.Y); DebugDrawer.Create(); _currentTestIndex = Math.Clamp(_currentTestIndex, 0, Global.Tests.Count - 1); _testSelected = _currentTestIndex; LoadTest(_testSelected); base.OnLoad(); }
public SceneView() { imGuiController = MainWindow.imGuiController; Project.OnChangeProject += Project_OnChangeProject; }
public void Run() { Logger.Info("Welcome to the Fury Engine!"); Logger.Info("Platform: " + RuntimeInformation.OSDescription); ImGuiController.Init(window); while (running) { double time = GLFW.GetTime(); float elapsed = (float)(time - lastFrameTime); Time.deltaTime = elapsed; lastFrameTime = time; if (!window.Minimised) { foreach (Layer layer in layerStack.Layers) { layer.OnUpdate(); } ImGuiController.Begin(window); foreach (Layer layer in layerStack.Layers) { layer.OnImGuiRender(); } ImGuiController.End(); } window.OnUpdate(); } }
public override void OnDetach() { ImGui.DestroyPlatformWindows(); //ImGui.*DestroyContext*(ImGuiContext); // this somehow destroys to much ImGuiContext = IntPtr.Zero; Log.Core.Info("ImGui context destroyed"); ImGuiController.ImGui_ImplOpenGL3_Shutdown(); ImGuiController.ImGui_ImplGlfw_Shutdown(); }
public void OnGraphicsDeviceCreated(GraphicsDevice gd, ResourceFactory factory, Swapchain sc) { GraphicsDevice = gd; ResourceFactory = factory; MainSwapchain = sc; CreateResources(factory); CreateSwapchainResources(factory); _controller = new ImGuiController(this.GraphicsDevice, this.GraphicsDevice.MainSwapchain.Framebuffer.OutputDescription, (int)this.Window.Width, (int)this.Window.Height); }
public void Run() { if (glfwInit() == 0) { throw new Exception("glfwInit"); } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); _window = glfwCreateWindow(640, 480, "Hello World", IntPtr.Zero, IntPtr.Zero); if (_window == IntPtr.Zero) { glfwTerminate(); throw new Exception("glfwCreateWindow"); } glfwMakeContextCurrent(_window); LoadEntryPoints(); _imGuiController = new ImGuiController(_window); _imGuiController.Init(); while (glfwWindowShouldClose(_window) == 0) { glfwPollEvents(); if (glfwGetKey(_window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { glfwSetWindowShouldClose(_window, GLFW_TRUE); } _imGuiController.Update(); ImGui.Begin("Info"); ImGui.Text(glGetString(GL_VERSION)); ImGui.Text($"FPS : {ImGui.GetIO().Framerate.ToString("0")}"); if (ImGui.Button("Show demo")) { _showDemo = true; } ImGui.End(); if (_showDemo) { ImGui.ShowDemoWindow(ref _showDemo); } glClear(GL_COLOR_BUFFER_BIT); _imGuiController.Render(); glfwSwapBuffers(_window); } }
/// <inheritdoc /> protected override void OnLoad() { GL.ClearColor(0.2f, 0.2f, 0.2f, 1.0f); _controller = new ImGuiController(Size.X, Size.Y); Global.Settings.Load(); Global.DebugDraw.Create(); _currentTestIndex = Math.Clamp(_currentTestIndex, 0, Global.Tests.Count - 1); _testSelection = _currentTestIndex; RestartTest(); base.OnLoad(); }
/// <inheritdoc /> protected override void OnClosed() { Test?.Dispose(); Test = null; Global.DebugDraw.Destroy(); Global.Settings.Save(); _controller.Dispose(); _controller = null; _stopwatch.Stop(); base.OnClosed(); }
/// <summary> /// Create a preview graph widget /// </summary> /// <param name="controller">ImGui controller</param> /// <param name="clientState">rgat state object</param> public PreviewGraphsWidget(ImGuiController controller, rgatState clientState) { IrregularTimer = new System.Timers.Timer(600); IrregularTimer.Elapsed += FireTimer; IrregularTimer.AutoReset = true; IrregularTimer.Start(); _ImGuiController = controller; ForegroundLayoutEngine = new GraphLayoutEngine($"Preview_Foreground"); ForegroundLayoutEngine.Init(controller.GraphicsDevice); BackgroundLayoutEngine = new GraphLayoutEngine($"Preview_Background"); BackgroundLayoutEngine.Init(controller.GraphicsDevice); }
private void InitImGui() { _imGuiController = new ImGuiController( _vk, _window, _inputContext = _window.CreateInput(), _physicalDevice, _graphicsFamilyIndex, _swapchainImages.Length, _swapchainImageFormat, null ); }
public EditorManager(Vector2i Size) { this.Size = Size; EditorWindows = new List <EditorWindow>(); GuiController = new ImGuiController(Size.X, Size.Y); LoadEditors(); evp = GetWindow <EditorViewportWindow>() !; gvp = GetWindow <GameViewportWindow>() !; gvp.IsActive = true; evp.IsActive = true; GetWindow <HierarchyWindow>() !.IsActive = true; GetWindow <InspectorWindow>() !.IsActive = true; }
public override bool OnUserCreate() { _controller = new ImGuiController(ScreenWidth(), ScreenHeight(), this); radius = Math.Min(ScreenWidth(), ScreenHeight()) / 2; p = new Pixel(127, 127, 127); mGameLayer = CreateLayer(); EnableLayer(mGameLayer, true); SetLayerCustomRenderFunction(mGameLayer, DrawImGui); return(true); }
private UIOverlayController(IView window, IInputContext input, GL gl) { _window = window; _input = input; _imGuiController = new ImGuiController( gl, window, _input); _imGuiFadeInOut = new ImGuiFadeInOut(); _pinMameController = PinMameController.Instance(_input); _dmdController = DmdController.Instance(); }
public static void DrawIcon(ImGuiController controller, string name, int countCaption = 1, Vector2?offset = null) { Texture btnIcon = controller.GetImage(name); IntPtr CPUframeBufferTextureId = controller.GetOrCreateImGuiBinding(controller.GraphicsDevice.ResourceFactory, btnIcon, $"Icon" + name); Vector2 size = new Vector2(btnIcon.Width, btnIcon.Height); Vector2 corner = ImGui.GetCursorScreenPos() + (offset ?? Vector2.Zero); ImGui.GetWindowDrawList().AddImage(CPUframeBufferTextureId, corner, corner + size, Vector2.Zero, Vector2.One); if (countCaption > 1) { ImGui.SetCursorScreenPos(corner + new Vector2(size.X * 0.8f, 5)); ImGui.Text($"{countCaption}"); } }
public static void Init() { VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 1024, 768, WindowState.Normal, "MCHI"), new GraphicsDeviceOptions(true, null, true), out _window, out _gd); _window.Resized += () => { _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height); _controller.WindowResized(_window.Width, _window.Height); }; _cl = _gd.ResourceFactory.CreateCommandList(); _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height); }
public unsafe UserInterface(Api api, Window window, SwapChain swapChain, DepthBuffer depthBuffer) { _swapChain = swapChain; // Initialise ImGui _imGuiController = new ImGuiController(api.Vk, window.IWindow, window.InputContext, new ImGuiFontConfig("./assets/fonts/Cousine-Regular.ttf", 13), api.Device.PhysicalDevice, api.Device.GraphicsFamilyIndex, swapChain.VkImages.Count, swapChain.Format, depthBuffer.Format); }
static void Main(string[] args) { /* * if (!ColliderCon.connect()) * { * Console.WriteLine("Cannot connect to ColliderconVR service.\nMake Sure VRChat is running and that ColliderCon is loaded"); * Console.ReadLine(); * Environment.Exit(-1); * }*/ BTManager.rescanDevices(); VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 1024, 768, WindowState.Normal, "Lovetap"), new GraphicsDeviceOptions(true, null, true), out _window, out _gd); _window.Resized += () => { _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height); _controller.WindowResized(_window.Width, _window.Height); }; _cl = _gd.ResourceFactory.CreateCommandList(); _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height); CollideSystem.updateColliders(); StartUI(); // CollideSystem.colliders.Add(new WatchedCollider(CollideSystem.getColliderByName("celhandleft"), CollideSystem.getColliderByName("celhandright"))); while (_window.Exists) { InputSnapshot snapshot = _window.PumpEvents(); if (!_window.Exists) { break; } _controller.Update(1f / 60f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui. SubmitUI(); _cl.Begin(); _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, new RgbaFloat(_clearColor.X, _clearColor.Y, _clearColor.Z, 1f)); _controller.Render(_gd, _cl); _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_gd.MainSwapchain); } }
static void Main(string[] args) { // Create window, GraphicsDevice, and all resources necessary for the demo. //VeldridStartup.CreateWindowAndGraphicsDevice( VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 1280, 720, WindowState.Normal, "ImGui.NET Sample Program"), new GraphicsDeviceOptions(true, null, true), GraphicsBackend.OpenGL, out _window, out _gd); _window.Resized += () => { _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height); _controller.WindowResized(_window.Width, _window.Height); }; _cl = _gd.ResourceFactory.CreateCommandList(); _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height); //_memoryEditor = new MemoryEditor(); //Random random = new Random(); //_memoryEditorData = Enumerable.Range(0, 1024).Select(i => (byte)random.Next(255)).ToArray(); _state = new GlobalUIState(_window); // Main application loop while (_window.Exists) { InputSnapshot snapshot = _window.PumpEvents(); if (!_window.Exists) { break; } _controller.Update(1f / 60f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui. SubmitUI(); _cl.Begin(); _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, new RgbaFloat(_clearColor.X, _clearColor.Y, _clearColor.Z, 1f)); _controller.Render(_gd, _cl); _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_gd.MainSwapchain); } // Clean up Veldrid resources _gd.WaitForIdle(); _controller.Dispose(); _cl.Dispose(); _gd.Dispose(); }
public static void DrawSpinner(ImGuiController controller, int count, uint colour) { if (controller._fontTexture is null) { return; } ImFontGlyphPtr glyph = controller.UnicodeFont.FindGlyph(ImGuiController.FA_ICON_ROTATION); ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero); IntPtr CPUframeBufferTextureId = controller.GetOrCreateImGuiBinding(controller.GraphicsDevice.ResourceFactory, controller._fontTexture, "Spinner"); ImGui.SetCursorPos(ImGui.GetCursorPos() + new Vector2(3, 3)); Vector2 size = new Vector2(18, 18); Vector2 corner = ImGui.GetCursorScreenPos() + new Vector2(0, size.Y); Vector2 center = corner + new Vector2(size.X * 0.5f, size.Y * -0.5f); float rotation = -1 * ((float)DateTime.Now.TimeOfDay.TotalMilliseconds / 360); float cos_a = (float)Math.Cos(rotation); float sin_a = (float)Math.Sin(rotation); Vector2[] pos = new Vector2[] { center + ImRotate(new Vector2(-size.X, -size.Y) * 0.5f, cos_a, sin_a), center + ImRotate(new Vector2(+size.X, -size.Y) * 0.5f, cos_a, sin_a), center + ImRotate(new Vector2(+size.X, +size.Y) * 0.5f, cos_a, sin_a), center + ImRotate(new Vector2(-size.X, +size.Y) * 0.5f, cos_a, sin_a) }; ImGui.GetWindowDrawList().AddImageQuad(CPUframeBufferTextureId, pos[0], pos[1], pos[2], pos[3], new Vector2(glyph.U0, glyph.V0), new Vector2(glyph.U1, glyph.V0), new Vector2(glyph.U1, glyph.V1), new Vector2(glyph.U0, glyph.V1), colour); if (count > 1) { ImGui.SetCursorPos(ImGui.GetCursorPos() + new Vector2(size.X, 4)); ImGui.Text($"{count}"); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - size.Y); ImGui.InvisibleButton($"#invisBtn{rotation}", new Vector2(18, 18)); } else { //tooltip hover target ImGui.InvisibleButton($"#invisBtn{rotation}", new Vector2(18, 24)); } ImGui.PopStyleVar(); }
protected override void OnLoad(EventArgs e) { VertexArrayObject = GL.GenVertexArray(); GL.ClearColor(0.2f, 0.3f, 0.3f, 1.0f); VertexBufferObject = GL.GenBuffer(); GL.Enable(EnableCap.Texture2D); // Disable texture filtering GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMagFilter.Nearest); _controller = new ImGuiController(Width, Height); gbTexId = GL.GenTexture(); tsTexId = GL.GenTexture(); base.OnLoad(e); }
private void LoadGUI() { inspector = new Inspector(); hierarchy = new Hierarchy(); _controller = new ImGuiController(ClientSize.X, ClientSize.Y); GameViewWindow = new GameViewWindow(this); frameBuffer = new FrameBuffer(1440, 900); inspector.currentObject = firstObject; ImGuiController.DarkTheme(); /* * Debug.Log("hour: " + DateTime.Now.Hour); * if (DateTime.Now.Hour > 16 || DateTime.Now.Hour < 5) ImGuiController.DarkTheme(); * else ImGui.StyleColorsLight(); */ }
public void End() { ImGuiIOPtr io = ImGui.GetIO(); Application app = Application.Instance; io.DisplaySize = new Vector2((float)app.Window.Width, (float)app.Window.Height); // Rendering ImGui.Render(); ImGuiController.ImGui_ImplOpenGL3_RenderDrawData(ImGui.GetDrawData()); if ((io.ConfigFlags & ImGuiConfigFlags.ViewportsEnable) > 0) { GLFW.Window backup_current_context = GLFW.Glfw.CurrentContext; ImGui.UpdatePlatformWindows(); ImGui.RenderPlatformWindowsDefault(); GLFW.Glfw.MakeContextCurrent(backup_current_context); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); _controller = new ImGuiController(Width, Height); //Set the current theme instance ColorTheme.UpdateTheme(new DarkTheme()); //Disable the docking buttons ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; //Enable docking support ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.DockingEnable; //Enable up/down key navigation ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard; //Only move via the title bar instead of the whole window ImGui.GetIO().ConfigWindowsMoveFromTitleBarOnly = true; //Init rendering data TimelineWindow.OnLoad(); Pipeline.InitBuffers(); camera_speed = Pipeline._camera.KeyMoveSpeed; InitDock(); LoadRecentList(); RenderTools.Init(); ReloadGlobalShaders(); var Thread2 = new Thread((ThreadStart)(() => { //Init plugins Toolbox.Core.FileManager.GetFileFormats(); })); Thread2.Start(); ForceFocused = true; }
protected override void OnLoad() { base.OnLoad(); openGLString = "OpenGL " + GL.GetString(StringName.Version); Title = String.Format("Replanetizer ({0})", openGLString); controller = new ImGuiController(ClientSize.X, ClientSize.Y); UpdateInfoFrame.CheckForNewVersion(this); if (args.Length > 0) { LevelFrame lf = new LevelFrame(this); Level l = new Level(args[0]); lf.LoadLevel(l); AddFrame(lf); } }
public void initialize() { // Create window, GraphicsDevice, and all resources necessary for the demo. VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 1280, 720, WindowState.Normal, "ImGui.NET Sample Program"), new GraphicsDeviceOptions(true, null, true, ResourceBindingModel.Improved, true, true), out _window, out _gd); _window.Resized += () => { _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height); _controller.WindowResized(_window.Width, _window.Height); }; _cl = _gd.ResourceFactory.CreateCommandList(); _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height); _memoryEditor = new MemoryEditor(); Random random = new Random(); _memoryEditorData = Enumerable.Range(0, 1024).Select(i => (byte)random.Next(255)).ToArray(); }