|
@@ -20,6 +20,11 @@
|
|
#pragma comment(lib, "legacy_stdio_definitions")
|
|
#pragma comment(lib, "legacy_stdio_definitions")
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+// This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details.
|
|
|
|
+#ifdef __EMSCRIPTEN__
|
|
|
|
+#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
|
|
|
+#endif
|
|
|
|
+
|
|
static void glfw_error_callback(int error, const char* description)
|
|
static void glfw_error_callback(int error, const char* description)
|
|
{
|
|
{
|
|
fprintf(stderr, "GLFW Error %d: %s\n", error, description);
|
|
fprintf(stderr, "GLFW Error %d: %s\n", error, description);
|
|
@@ -85,6 +90,7 @@ int main(int, char**)
|
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
|
|
|
+ // - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
|
|
//io.Fonts->AddFontDefault();
|
|
//io.Fonts->AddFontDefault();
|
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18.0f);
|
|
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18.0f);
|
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
|
@@ -99,7 +105,14 @@ int main(int, char**)
|
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
|
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
|
|
|
|
|
// Main loop
|
|
// Main loop
|
|
|
|
+#ifdef __EMSCRIPTEN__
|
|
|
|
+ // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.
|
|
|
|
+ // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage.
|
|
|
|
+ io.IniFilename = NULL;
|
|
|
|
+ EMSCRIPTEN_MAINLOOP_BEGIN
|
|
|
|
+#else
|
|
while (!glfwWindowShouldClose(window))
|
|
while (!glfwWindowShouldClose(window))
|
|
|
|
+#endif
|
|
{
|
|
{
|
|
// Poll and handle events (inputs, window resize, etc.)
|
|
// Poll and handle events (inputs, window resize, etc.)
|
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
|
@@ -161,6 +174,9 @@ int main(int, char**)
|
|
|
|
|
|
glfwSwapBuffers(window);
|
|
glfwSwapBuffers(window);
|
|
}
|
|
}
|
|
|
|
+#ifdef __EMSCRIPTEN__
|
|
|
|
+ EMSCRIPTEN_MAINLOOP_END;
|
|
|
|
+#endif
|
|
|
|
|
|
// Cleanup
|
|
// Cleanup
|
|
ImGui_ImplOpenGL3_Shutdown();
|
|
ImGui_ImplOpenGL3_Shutdown();
|