mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Updated Working for Web (HTML5) (markdown)
@ -219,3 +219,25 @@ if __name__ == '__main__':
|
||||
Finally, access your game in the browser using:
|
||||
|
||||
localhost:8080/project_name.html
|
||||
|
||||
### Building with CLion/CMake/Emscripten for Web
|
||||
|
||||
Use the following **CMake options** (find them under **CLion > Preferences > Build,Execution,Deployment > CMake**)
|
||||
|
||||
```
|
||||
-DCMAKE_TOOLCHAIN_FILE=<YOUR PATH HERE>/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
|
||||
-DPLATFORM=Web
|
||||
```
|
||||
|
||||
Do not use the **-S, -H, -B** options mentioned in the wiki because they get in the way. **-B build** in particular was preventing **CLion** from finding the generated files (because it was creating an additional build directory inside CLion's own directory).
|
||||
|
||||
Included this snippet at the top of `CMakeLists.txt`, with no changes whatsoever:
|
||||
|
||||
```
|
||||
if (EMSCRIPTEN)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html") # This line is used to set your executable to build with the emscripten html template so taht you can directly open it.
|
||||
endif ()
|
||||
```
|
||||
|
||||
_This was tested under both **macOS Catalina 10.15.7** and **Windows 10** with **CLion 2020.2** and **Emscripten 2.0.13**_
|
||||
Reference in New Issue
Block a user