Files
EVEngine/platform/webgpu/webplatform.h
T
西风逍遥游 8dd21d3ea3 feat(webgpu): integrate WebGPU backend support and enhance build configuration
- Added support for the WebGPU backend in the CMake configuration, enabling builds for Emscripten and native Dawn.
- Implemented conditional compilation for WebGPU-specific features, including shader management and file system handling.
- Updated the build process to exclude unnecessary modules and dependencies for WebGPU, optimizing the engine for browser environments.
- Enhanced the installation script to include WebGPU-related files and directories in the output.
- Refactored existing modules to accommodate WebGPU, ensuring compatibility and performance improvements across the engine.
- Introduced new compile options and configurations tailored for WebGPU builds, including handling of third-party libraries and assets.
2026-08-15 10:46:26 +08:00

69 lines
1.9 KiB
C++

#pragma once
#include <string>
namespace eve {
namespace webgpu_platform {
/**
* WebGPU platform services shared by the browser (Emscripten/WASM) and native
* Dawn builds. Mirrors the interface of platform/ios and platform/android so
* the engine code can call into it uniformly.
*
* On the browser the game directory is the preloaded VFS mount ("/game"),
* appdata is an IndexedDB-backed persistent dir ("/persist"), and the
* "executable" is the page itself. On native builds the helpers resolve to
* filesystem paths relative to the CWD.
*/
/**
* Root directory containing the game assets (main.nut / config.nut / data).
* Browser: "/game" (--preload-file). Native: "." unless EVENGINE_WEBGPU_GAME_DIR
* is set.
**/
std::string getGameDirectory();
/**
* Directory where files should be stored (saves / user data).
* Browser: "/persist" (IndexedDB). Native: "appdata" under the CWD.
**/
std::string getAppdataDirectory();
/**
* Home directory. Browser: the VFS root "/". Native: CWD.
**/
std::string getHomeDirectory();
/**
* Returns the full path to the "executable".
* Browser: the page URL. Native: argv[0]-style best effort.
**/
std::string getExecutablePath();
/**
* Opens the specified URL in a new browser tab / system default browser.
* Browser: window.open. Native: no-op returning false.
**/
bool openURL(const std::string &url);
/**
* Causes devices with vibration support to vibrate for about 0.5 seconds.
* Browser: navigator.vibrate. Native: no-op.
**/
void vibrate();
/**
* Returns whether another application is playing audio (browser: no-op).
**/
bool hasBackgroundMusic();
/**
* Flush pending browser-side work (device requests, message queue).
* On Emscripten this processes the browser message queue so requestDevice
* callbacks fire on the main thread when PROXY_TO_PTHREAD is disabled.
**/
void pumpEvents();
} // namespace webgpu_platform
} // namespace eve