-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathimgui_module.cpp
More file actions
46 lines (41 loc) · 1.3 KB
/
Copy pathimgui_module.cpp
File metadata and controls
46 lines (41 loc) · 1.3 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
// Public imgui module package end-to-end assertion: import-only consumption
// (imgui.core + glfw_opengl3 backend), context + font atlas + one frame,
// software-only (no window). Linux-only (see mcpp.toml).
#ifdef __linux__
import std;
import imgui.core;
import imgui.backend.glfw_opengl3;
int main() {
auto init = &ImGui::Backend::GlfwOpenGL3::Init;
auto shutdown = &ImGui::Backend::GlfwOpenGL3::Shutdown;
if (init == nullptr || shutdown == nullptr) {
return 1;
}
ImGuiContext* context = ImGui::CreateContext();
if (context == nullptr) {
return 2;
}
ImGui::SetCurrentContext(context);
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2 { 320.0f, 240.0f };
unsigned char* pixels = nullptr;
int width = 0;
int height = 0;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
if (pixels == nullptr || width <= 0 || height <= 0) {
ImGui::DestroyContext(context);
return 3;
}
ImGui::NewFrame();
bool open = true;
ImGui::Begin("mcpp-index imgui smoke", &open);
ImGui::TextUnformatted("import imgui.core");
ImGui::End();
ImGui::Render();
std::println("Dear ImGui {} module package ok", ImGui::GetVersion());
ImGui::DestroyContext(context);
return 0;
}
#else
int main() { return 0; }
#endif