MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / main

Function main

engine/3rdparty/imgui/examples/example_emscripten_wgpu/main.cpp:35–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33static void print_wgpu_error(WGPUErrorType error_type, const char* message, void*);
34
35int main(int, char**)
36{
37 glfwSetErrorCallback(print_glfw_error);
38 if (!glfwInit())
39 return 1;
40
41 // Make sure GLFW does not initialize any graphics context.
42 // This needs to be done explicitly later
43 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
44
45 GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+WebGPU example", NULL, NULL);
46 if (!window)
47 {
48 glfwTerminate();
49 return 1;
50 }
51
52 // Initialize the WebGPU environment
53 if (!init_wgpu())
54 {
55 if (window)
56 glfwDestroyWindow(window);
57 glfwTerminate();
58 return 1;
59 }
60 glfwShowWindow(window);
61
62 // Setup Dear ImGui context
63 IMGUI_CHECKVERSION();
64 ImGui::CreateContext();
65 ImGuiIO& io = ImGui::GetIO(); (void)io;
66 //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
67 //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
68
69 // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.
70 // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage.
71 io.IniFilename = NULL;
72
73 // Setup Dear ImGui style
74 ImGui::StyleColorsDark();
75 //ImGui::StyleColorsClassic();
76
77 // Setup Platform/Renderer backends
78 ImGui_ImplGlfw_InitForOther(window, true);
79 ImGui_ImplWGPU_Init(wgpu_device, 3, WGPUTextureFormat_RGBA8Unorm);
80
81 // Load Fonts
82 // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
83 // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
84 // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
85 // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
86 // - Read 'docs/FONTS.md' for more instructions and details.
87 // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
88 // - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details.
89 //io.Fonts->AddFontDefault();
90#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
91 io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);
92 //io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f);

Callers

nothing calls this directly

Calls 11

glfwSetErrorCallbackFunction · 0.85
glfwInitFunction · 0.85
glfwWindowHintFunction · 0.85
glfwCreateWindowFunction · 0.85
glfwTerminateFunction · 0.85
init_wgpuFunction · 0.85
glfwDestroyWindowFunction · 0.85
glfwShowWindowFunction · 0.85
ImGui_ImplWGPU_InitFunction · 0.85
AddFontFromFileTTFMethod · 0.80

Tested by

no test coverage detected