git clone https://github.com/google/dawn dawncmake -B build -DIMGUI_DAWN_DIR=dawncmake --build build The resulting binary will be found at one of the following locations:your_preferred_foldercmake -B build -DIMGUI_WGPU_DIR=your_preferred_folder (“full path” or “relative” starting from current directory)cmake --build build The resulting binary will be found at one of the following locations:emcmake cmake -G Ninja -B build-DIMGUI_EMSCRIPTEN_WEBGPU_FLAG="--use-port=path/to/emdawnwebgpu_package/emdawnwebgpu.port.py", see belowcmake --build buildIf you want to sync Emscripten with latest DAWN release it's necessary to download the port-emdawnwgpu-package (released daily by Google) here: https://github.com/google/dawn/releases Unpack it in your preferred folder and to replace the step 3 with:
emcmake cmake -DIMGUI_EMSCRIPTEN_WEBGPU_FLAG="--use-port=path/to/emdawnwebgpu_package/emdawnwebgpu.port.py" -G Ninja -B buildN.B. For the WASM code produced by Emscripten to work correctly, it will also be necessary to have the “corresponding” (or newer) version of Google Canary (nightly build for developers) that includes the latest changes
cmake -G Ninja -DIMGUI_DAWN_DIR=path_to_sdk_dir -B where_to_build_dirIMGUI_DAWN_DIR set IMGUI_IMPL_WEBGPU_BACKEND_DAWN compiler definecmake -G Ninja -DIMGUI_WGPU_DIR=path_to_sdk_dir -B where_to_build_dir
IMGUI_WGPU_DIR set IMGUI_IMPL_WEBGPU_BACKEND_WGPU compiler defineemcmake cmake -G Ninja -B where_to_build_dir--use-port=emdawnwebgpu flag to buildIMGUI_IMPL_WEBGPU_BACKEND_DAWN compiler define-sUSE_WEBGPU=1 flag to buildIMGUI_IMPL_WEBGPU_BACKEND_WGPU compiler define-sUSE_WEBGPU=1 deprecated flag even with EMS >= 4.0.10emcmake cmake -G Ninja -DIMGUI_EMSCRIPTEN_WEBGPU_FLAG="-sUSE_WEBGPU=1" -B where_to_build_dirIMGUI_IMPL_WEBGPU_BACKEND_WGPU compiler defineemcmake cmake -G Ninja -DIMGUI_EMSCRIPTEN_WEBGPU_FLAG="--use-port=path_to_emdawnwebgpu_pkg" -B where_to_build_dirIMGUI_IMPL_WEBGPU_BACKEND_DAWN compiler defineOnce the procedure for the specific builder is generated, the build command is always the same:
Build using CMake
cmake --build where_to_build_dirBuild explicitly:
cd where_to_build_dirninja-G Ninja to build with ninja builder-G "Unix Makefiles" to build with make builder-G "Visual Studio 17 2022" -A x64 to create a VS 2022 solution (.sln) file, Windows onlyExample:
cmake -G "Unix Makefiles" -DIMGUI_DAWN_DIR=path_to_sdk_dir -B where_to_build_dir*Syntax is case sensitive and the "" are necessary in case of spaces between words
where_to_build_dir for different CMake generationsThe default build type is Debug It is possible to use a different build type using:
-DCMAKE_BUILD_TYPE=Release-DCMAKE_BUILD_TYPE=MinSizeRel-DCMAKE_BUILD_TYPE=RelWithDebInfoExample:
cmake -G ninja -DIMGUI_WGPU_DIR=path_to_sdk_dir -DCMAKE_BUILD_TYPE=Release -B where_to_build_dir Includes and libraries, by default, are searched in system/compiler paths (environment variables): you can add the path to your development tools to the environment variables without having to modify the CMakeLists.txt file.
If you are using a package manager (vcpkg / conan / ... ) you need/can to specify it, adding to cmake command:
-DCMAKE_TOOLCHAIN_FILE=path/to/package_manager.cmakeExamples:
using vcpkg package manager it's necessary adding:
-DCMAKE_TOOLCHAIN_FILE=<vcpkg_root_dir>/scripts/buildsystems/vcpkg.cmakefull cmake command using vcpkg package manager:
cmake -G Ninja -DIMGUI_DAWN_DIR=path_to_sdk_dir -DCMAKE_TOOLCHAIN_FILE=<vcpkg_root_dir>/scripts/buildsystems/vcpkg.cmake -B where_to_build_dirYou need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions
Depending on your configuration, in Windows you may need to run emsdk/emsdk_env.bat in your console to access the Emscripten command-line tools.
You may also refer to our Continuous Integration setup for Emscripten setup.
Then build using make -f Makefile.emscripten while in the example_glfw_wgpu/ directory.
Requires recent Emscripten as WGPU is still a work-in-progress API.
To run on a local machine:
make serve will use Python3 to spawn a local webserver, you can then browse http://localhost:8000 to access your build.emrun command: emrun web/example_glfw_wgpu.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.python -m http.server -d web (this is what make serve uses).cd web && python -m SimpleHTTPServer.