-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtimgui.nim
More file actions
78 lines (53 loc) · 1.65 KB
/
timgui.nim
File metadata and controls
78 lines (53 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright 2018, NimGL contributors.
import nimgl/imgui, nimgl/imgui/[impl_opengl, impl_glfw]
import nimgl/[opengl, glfw]
proc main() =
doAssert glfwInit()
glfwWindowHint(GLFWContextVersionMajor, 3)
glfwWindowHint(GLFWContextVersionMinor, 3)
glfwWindowHint(GLFWOpenglForwardCompat, GLFW_TRUE)
glfwWindowHint(GLFWOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(GLFWResizable, GLFW_FALSE)
var w: GLFWWindow = glfwCreateWindow(1280, 720)
if w == nil:
quit(-1)
w.makeContextCurrent()
doAssert glInit()
let context = igCreateContext()
#let io = igGetIO()
doAssert igGlfwInitForOpenGL(w, true)
doAssert igOpenGL3Init()
igStyleColorsCherry()
var show_demo: bool = true
var somefloat: float32 = 0.0f
var counter: int32 = 0
while not w.windowShouldClose:
glfwPollEvents()
igOpenGL3NewFrame()
igGlfwNewFrame()
igNewFrame()
if show_demo:
igShowDemoWindow(show_demo.addr)
# Simple window
igBegin("Hello, world!")
igText("This is some useful text.")
igCheckbox("Demo Window", show_demo.addr)
igSliderFloat("float", somefloat.addr, 0.0f, 1.0f)
if igButton("Button", ImVec2(x: 0, y: 0)):
counter.inc
igSameLine()
igText("counter = %d", counter)
igText("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / igGetIO().framerate, igGetIO().framerate)
igEnd()
# End simple window
igRender()
glClearColor(0.45f, 0.55f, 0.60f, 1.00f)
glClear(GL_COLOR_BUFFER_BIT)
igOpenGL3RenderDrawData(igGetDrawData())
w.swapBuffers()
igOpenGL3Shutdown()
igGlfwShutdown()
context.igDestroyContext()
w.destroyWindow()
glfwTerminate()
main()