mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-07 20:08:24 +00:00
Examples: Made example_sdl_opengl3 and example_glfw_opengl3 build with Emscripten. Removed dedicated examples. (#2492, #2494, #3699, #3705)
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||
|
||||
// This example can also compile and run with Emscripten. See Makefile.emscripten for details.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_sdl.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
@@ -19,6 +21,10 @@ static SDL_Window* g_AppWindow = NULL;
|
||||
|
||||
// Forward declarations of helper functions
|
||||
bool MainLoopStep();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
void MainLoopForEmscripten(void*) { MainLoopStep(); }
|
||||
#endif
|
||||
|
||||
// Main code
|
||||
int main(int, char**)
|
||||
@@ -88,6 +94,7 @@ int main(int, char**)
|
||||
// - 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.
|
||||
// - 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->AddFontFromFileTTF("c:\\Windows\\Fonts\\segoeui.ttf", 18.0f);
|
||||
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
||||
@@ -97,11 +104,20 @@ int main(int, char**)
|
||||
//IM_ASSERT(font != NULL);
|
||||
|
||||
// Main loop
|
||||
#ifndef __EMSCRIPTEN__
|
||||
// Desktop Build
|
||||
while (true)
|
||||
{
|
||||
if (!MainLoopStep())
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// Emscripten Build
|
||||
// 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_set_main_loop_arg(MainLoopForEmscripten, NULL, 0, true);
|
||||
#endif
|
||||
|
||||
// Cleanup
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
|
Reference in New Issue
Block a user