diff --git a/examples/example_emscripten_opengl3/.gitignore b/examples/example_emscripten_opengl3/.gitignore new file mode 100644 index 00000000..ed3df07e --- /dev/null +++ b/examples/example_emscripten_opengl3/.gitignore @@ -0,0 +1,2 @@ +# Ignore Web Instance +web/ diff --git a/examples/example_emscripten_opengl3/Makefile b/examples/example_emscripten_opengl3/Makefile index cde9ffa3..33bc9d46 100644 --- a/examples/example_emscripten_opengl3/Makefile +++ b/examples/example_emscripten_opengl3/Makefile @@ -15,7 +15,8 @@ CC = emcc CXX = em++ -EXE = example_emscripten_opengl3.html +WEB_DIR = web +EXE = $(WEB_DIR)/example_emscripten_opengl3.html IMGUI_DIR = ../.. SOURCES = main.cpp SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp @@ -78,8 +79,14 @@ LDFLAGS += --shell-file shell_minimal.html all: $(EXE) @echo Build complete for $(EXE) -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS) +$(WEB_DIR): + mkdir $@ + +serve: all + python3 -m http.server -d $(WEB_DIR) + +$(EXE): $(OBJS) $(WEB_DIR) + $(CXX) -o $@ $(OBJS) $(LIBS) $(LDFLAGS) clean: - rm -f $(EXE) $(OBJS) *.js *.wasm *.wasm.pre + rm -rf $(EXE) $(OBJS) *.js *.wasm *.wasm.pre $(WEB_DIR) diff --git a/examples/example_emscripten_opengl3/README.md b/examples/example_emscripten_opengl3/README.md index b6b8737d..3f0176b1 100644 --- a/examples/example_emscripten_opengl3/README.md +++ b/examples/example_emscripten_opengl3/README.md @@ -11,8 +11,8 @@ To run on a local machine: - Generally you may need a local webserver. Quoting [https://emscripten.org/docs/getting_started](https://emscripten.org/docs/getting_started/Tutorial.html#generating-html):
_"Unfortunately several browsers (including Chrome, Safari, and Internet Explorer) do not support file:// [XHR](https://emscripten.org/docs/site/glossary.html#term-xhr) requests, and can’t load extra files needed by the HTML (like a .wasm file, or packaged file data as mentioned lower down). For these browsers you’ll need to serve the files using a [local webserver](https://emscripten.org/docs/getting_started/FAQ.html#faq-local-webserver) and then open http://localhost:8000/hello.html."_ -- Emscripten SDK has a handy `emrun` command: `emrun example_emscripten_opengl3.html` which will spawn a temporary local webserver. See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details. -- Otherwise you may use Python builtin webserver: `python -m http.server` in Python 3 or `python -m SimpleHTTPServer` in Python 2. After doing that, you can visit http://localhost:8000/. +- Emscripten SDK has a handy `emrun` command: `emrun web/example_emscripten_opengl3.html --browser firefox` which will spawn a temporary local webserver (in Firefox). See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details. +- Otherwise you may use Python builtin webserver: `python -m http.server -d web` in Python 3 (or run shortcut `make serve`) or `cd web && python -m SimpleHTTPServer` in Python 2. After doing that, you can visit http://localhost:8000/. ## Obsolete features: