diff --git a/README.md b/README.md index 818c5f0..95ac777 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ See [glfm.h](include/glfm.h) Use `cmake` to generate an Xcode project: ```Shell -cmake -D GLFM_BUILD_EXAMPLES=ON -B build/apple -G Xcode +cmake -D GLFM_BUILD_EXAMPLES=ON -B build/apple -G Xcode open build/apple/GLFM.xcodeproj ``` @@ -187,12 +187,16 @@ In Xcode, switch to the `glfm_touch` target and run on a simulator or a device. Use `emcmake` to set environmental variables for `cmake`, then build: ```Shell -emcmake cmake -D GLFM_BUILD_EXAMPLES=ON -B build/emscripten -cmake --build build/emscripten +emcmake cmake -D GLFM_BUILD_EXAMPLES=ON -B build/emscripten && cmake --build build/emscripten ``` Then run locally: ```Shell +emrun build/emscripten/examples +``` + +Or run a specific example: +```Shell emrun build/emscripten/examples/glfm_touch.html ``` diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6f37535..4a815e9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,10 +7,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") set(GLFM_APP_ORGANIZATION_IDENTIFIER "com.brackeen") set(GLFM_APP_VERSION "1.0") set(GLFM_APP_VERSION_ITERATION 1) -set(GLFM_APP_LIST "") +set(GLFM_APP_TARGET_NAME_LIST "") macro(add_target TARGET SRC_FILES) - list(APPEND GLFM_APP_LIST ${TARGET}) + list(APPEND GLFM_APP_TARGET_NAME_LIST ${TARGET}) set(GLFM_APP_TARGET_NAME ${TARGET}) set(GLFM_APP_SRC ${SRC_FILES}) include(GLFMAppTarget) @@ -34,3 +34,22 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") else() add_target(glfm_test_pattern "test_pattern.c;test_pattern_renderer.h;test_pattern_renderer_gles2.c") endif() + +# Write index.html for Emscripten examples +if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + file(COPY icons DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(READ index.html.in INDEX_HTML) + + foreach(GLFM_APP_TARGET_NAME ${GLFM_APP_TARGET_NAME_LIST}) + set(GLFM_APP_HTML " +
+ + +
${GLFM_APP_TARGET_NAME}
+
+
") + + string(REPLACE "" "${GLFM_APP_HTML}\n" INDEX_HTML "${INDEX_HTML}") + endforeach() + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/index.html "${INDEX_HTML}") +endif() diff --git a/examples/index.html.in b/examples/index.html.in new file mode 100644 index 0000000..45f8d79 --- /dev/null +++ b/examples/index.html.in @@ -0,0 +1,30 @@ + + + + + + + GLFM Examples + + + +

GLFM Examples

+ + + + +