Created
May 12, 2019 18:40
-
-
Save mellinoe/5eca1a109a71566f620a05fcb70e74ca to your computer and use it in GitHub Desktop.
A complete example using Veldrid.ImGui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ImGuiNET; | |
using Veldrid; | |
using Veldrid.StartupUtilities; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
VeldridStartup.CreateWindowAndGraphicsDevice( | |
new WindowCreateInfo(100, 100, 1280, 720, Veldrid.WindowState.Normal, "ImGui Example"), | |
out var window, | |
out var gd); | |
ImGuiRenderer imguiRenderer = new ImGuiRenderer( | |
gd, gd.MainSwapchain.Framebuffer.OutputDescription, | |
(int)gd.MainSwapchain.Framebuffer.Width, (int)gd.MainSwapchain.Framebuffer.Height); | |
var cl = gd.ResourceFactory.CreateCommandList(); | |
while (window.Exists) | |
{ | |
var input = window.PumpEvents(); | |
if (!window.Exists) { break; } | |
imguiRenderer.Update(1f / 60f, input); // Compute actual value for deltaSeconds. | |
// Draw stuff | |
ImGui.Text("Hello World"); | |
cl.Begin(); | |
cl.SetFramebuffer(gd.MainSwapchain.Framebuffer); | |
cl.ClearColorTarget(0, RgbaFloat.Black); | |
imguiRenderer.Render(gd, cl); | |
cl.End(); | |
gd.SubmitCommands(cl); | |
gd.SwapBuffers(gd.MainSwapchain); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment