-
Notifications
You must be signed in to change notification settings - Fork 0
/
examplemultipleguis.nim
49 lines (37 loc) · 1019 Bytes
/
examplemultipleguis.nim
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
import nimgui
import nimgui/backends
# This won't work on emscripten.
# Also crashes on glfw backend when both windows are closed, not sure how to fix.
let gui1 = Gui.new()
gui1.backgroundColor = rgb(255, 255, 255)
gui1.setupBackend()
gui1.show()
let gui2 = Gui.new()
gui2.backgroundColor = rgb(0, 0, 0)
gui2.setupBackend()
gui2.show()
gui1.onFrame = proc(gui: Gui) =
gui.beginFrame()
let path = Path.new()
path.rect(vec2(50, 50), vec2(200, 200))
gui.fillPath(path, rgb(255, 0, 0))
gui.endFrame()
gui2.onFrame = proc(gui: Gui) =
gui.beginFrame()
let path = Path.new()
path.rect(vec2(50, 50), vec2(200, 200))
gui.fillPath(path, rgb(0, 255, 0))
gui.endFrame()
while true:
if not gui1.closeRequested:
gui1.pollEvents()
gui1.makeContextCurrent()
gui1.processFrame()
gui1.swapBuffers()
if not gui2.closeRequested:
gui2.pollEvents()
gui2.makeContextCurrent()
gui2.processFrame()
gui2.swapBuffers()
if gui1.closeRequested and gui2.closeRequested:
break