Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ElmEye
- open Veldrid
- open Veldrid.StartupUtilities
- let CreateApp windowWidth windowHeight name =
- let windowCI = WindowCreateInfo(
- X = 400,
- Y =400,
- WindowWidth = windowWidth,
- WindowHeight = windowHeight,
- WindowTitle = name
- )
- let window = VeldridStartup.CreateWindow(windowCI)
- window.add_Closed (fun () -> exit 0 |>ignore )
- window.Resizable <- true
- window.BorderVisible <-true
- window
- open System.Diagnostics
- open System.Numerics
- open ImGuiNET
- [<EntryPoint>]
- let main argv =
- let window = CreateApp 640 480 "ElmEye"
- let gdo = GraphicsDeviceOptions()
- let gd = VeldridStartup.CreateGraphicsDevice(window)
- let gui = new ImGuiRenderer(gd, (gd.MainSwapchain.Framebuffer.OutputDescription),window.Width, window.Height)
- let sw = Stopwatch.StartNew()
- let mutable lastFrame = sw.ElapsedMilliseconds
- window.add_Resized ( fun ()-> gd.ResizeMainWindow(uint32 window.Width,uint32 window.Height)
- gui.WindowResized(window.Width, window.Height)
- )
- while window.Exists do
- let cl = gd.ResourceFactory.CreateCommandList()
- let events = window.PumpEvents()
- gui.Update( float32(sw.ElapsedMilliseconds - lastFrame) ,events)
- //If the font is too small
- //ImGui.SetWindowFontScale (float32 1.8)
- //Use these commands to create an anchor-style panel
- ImGui.SetNextWindowSize(Vector2(float32 (window.Width/2), float32 window.Height))
- ImGui.SetNextWindowPos( Vector2(float32 0,float32 0), ImGuiCond.Always)
- ImGui.Begin("main", ImGuiWindowFlags.NoMove
- ||| ImGuiWindowFlags.NoCollapse
- ||| ImGuiWindowFlags.NoTitleBar
- ||| ImGuiWindowFlags.NoResize)|>ignore
- ImGui.Text "Hello Veldrid"
- ImGui.End()
- //the actual Veldrid drawing part
- cl.Begin()
- cl.SetFramebuffer(gd.MainSwapchain.Framebuffer)
- //A simple interaction to show you how to capture mouse events in GUI vs your game
- if ImGui.GetIO().WantCaptureMouse then
- cl.ClearColorTarget(uint32 0 , RgbaFloat.Black)
- else
- cl.ClearColorTarget(uint32 0 , RgbaFloat.CornflowerBlue)
- gui.Render (gd, cl)
- cl.End()
- gd.SubmitCommands cl
- gd.SwapBuffers()
- printfn "%A" argv
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement