-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimple.cr
47 lines (36 loc) · 1.04 KB
/
simple.cr
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
require "crsfml"
require "imgui"
require "../src/imgui-sfml"
window = SF::RenderWindow.new(SF::VideoMode.new(1280, 720), "ImGui + SFML = <3")
window.framerate_limit = 60
ImGui::SFML.init(window)
io = ImGui.get_io
io.config_flags |= ImGui::ImGuiConfigFlags::NavEnableKeyboard
io.config_flags |= ImGui::ImGuiConfigFlags::NavEnableGamepad
shape = SF::CircleShape.new(100)
shape.fill_color = SF::Color::Green
buf = ImGui::TextBuffer.new(100)
f = 0.6f32
delta_clock = SF::Clock.new
while window.open?
while (event = window.poll_event)
ImGui::SFML.process_event(window, event)
if event.is_a? SF::Event::Closed
window.close
end
end
ImGui::SFML.update(window, delta_clock.restart)
ImGui.show_demo_window
ImGui.begin("Hello, world!")
if ImGui.button("Save")
p! buf.to_s, f # Executed when the button gets clicked
end
ImGui.input_text("string", buf)
ImGui.slider_float("float", pointerof(f), 0.0, 1.0)
ImGui.end
window.clear
window.draw(shape)
ImGui::SFML.render(window)
window.display
end
ImGui::SFML.shutdown