Browse Source

Examples: Emscripten: Add 'make serve' helper, move output to web/ folder. (#3705)

pull/3721/head
Horki 4 years ago
committed by ocornut
parent
commit
0f14dd9781
  1. 2
      examples/example_emscripten_opengl3/.gitignore
  2. 15
      examples/example_emscripten_opengl3/Makefile
  3. 4
      examples/example_emscripten_opengl3/README.md

2
examples/example_emscripten_opengl3/.gitignore

@ -0,0 +1,2 @@
# Ignore Web Instance
web/

15
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)

4
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):<br>
_"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:

Loading…
Cancel
Save