-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.swift
45 lines (36 loc) · 1.29 KB
/
main.swift
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
import ImGui
// IMGUI_CHECKVERSION();
IMGUI_CHECKVERSION()
// ImGui::CreateContext();
let ctx = ImGuiCreateContext(nil)
// ImGuiIO& io = ImGui::GetIO();
let io = ImGuiGetIO()!
/// Build font atlas
var pixels: UnsafeMutablePointer<UInt8>?
var width: Int32 = 0
var height: Int32 = 0
var bytesPerPixel: Int32 = 0
// io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h);
ImFontAtlas_GetTexDataAsRGBA32(io.pointee.Fonts, &pixels, &width, &height, &bytesPerPixel)
for n in 0 ..< 20 {
print("NewFrame() \(n)")
// io.DisplaySize = ImVec2(1920, 1080);
io.pointee.DisplaySize = ImVec2(x: 1920, y: 1080)
// io.DeltaTime = 1.0f / 60.0f;
io.pointee.DeltaTime = 1.0 / 60.0
// ImGui::NewFrame();
ImGuiNewFrame()
var f: Float = 0.0
// ImGui::Text("Hello, world!");
ImGuiTextV("Hello, world!")
// ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
ImGuiSliderFloat("float", &f, 0.0, 1.0, nil, 1)
// ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGuiTextV("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / io.pointee.Framerate, io.pointee.Framerate)
// ImGui::ShowDemoWindow(NULL);
ImGuiShowDemoWindow(nil)
// ImGui::Render();
ImGuiRender()
}
print("DestroyContext()")
ImGuiDestroyContext(ctx)