diff --git a/backends/imgui_impl_wgpu.h b/backends/imgui_impl_wgpu.h index 7ab3dd31f..522234545 100644 --- a/backends/imgui_impl_wgpu.h +++ b/backends/imgui_impl_wgpu.h @@ -33,12 +33,21 @@ // Setup Emscripten default if not specified. #if defined(__EMSCRIPTEN__) && !defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) && !defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) #include + +#ifdef __EMSCRIPTEN_MAJOR__ +#if (__EMSCRIPTEN_MAJOR__ >= 4) && (__EMSCRIPTEN_MINOR__ >= 0) && (__EMSCRIPTEN_TINY__ >= 10) +#define IMGUI_IMPL_WEBGPU_BACKEND_DAWN +#else +#define IMGUI_IMPL_WEBGPU_BACKEND_WGPU +#endif +#else #if (__EMSCRIPTEN_major__ >= 4) && (__EMSCRIPTEN_minor__ >= 0) && (__EMSCRIPTEN_tiny__ >= 10) #define IMGUI_IMPL_WEBGPU_BACKEND_DAWN #else #define IMGUI_IMPL_WEBGPU_BACKEND_WGPU #endif #endif +#endif #include #if defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) && !defined(__EMSCRIPTEN__) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 46c23c68d..19a9e720c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -259,6 +259,7 @@ Other Changes: selects `VkSwapchainCreateInfoKHR`'s `compositeAlpha` value based on `cap.supportedCompositeAlpha`, which seems to be required on some Android devices. (#8784) [@FelixStach] + - WebGPU: fixes for Emscripten 5.0.0 (note: our examples currently don't build with 5.0.1). - Win32: handle `WM_IME_CHAR`/`WM_IME_COMPOSITION` to support Unicode inputs on MBCS (non-Unicode) Windows. (#9099, #3653, #5961) [@ulhc, @ocornut, @Othereum] - Win32: minor optimization not submitting gamepad input if packet number has not diff --git a/examples/example_glfw_wgpu/main.cpp b/examples/example_glfw_wgpu/main.cpp index 7c293a51c..1a6373c8a 100644 --- a/examples/example_glfw_wgpu/main.cpp +++ b/examples/example_glfw_wgpu/main.cpp @@ -40,8 +40,8 @@ static int wgpu_surface_width = 1280; static int wgpu_surface_height = 800; // Forward declarations -static bool InitWGPU(GLFWwindow* window); -static WGPUSurface CreateWGPUSurface(const WGPUInstance& instance, GLFWwindow* window); +static bool InitWGPU(GLFWwindow* window); +WGPUSurface CreateWGPUSurface(const WGPUInstance& instance, GLFWwindow* window); static void glfw_error_callback(int error, const char* description) { @@ -408,7 +408,7 @@ static WGPUDevice RequestDevice(WGPUAdapter& adapter) #endif // __EMSCRIPTEN__ #endif // IMGUI_IMPL_WEBGPU_BACKEND_WGPU -static bool InitWGPU(GLFWwindow* window) +bool InitWGPU(GLFWwindow* window) { WGPUTextureFormat preferred_fmt = WGPUTextureFormat_Undefined; // acquired from SurfaceCapabilities diff --git a/examples/example_sdl3_wgpu/main.cpp b/examples/example_sdl3_wgpu/main.cpp index adf4524a5..c02a5be9c 100644 --- a/examples/example_sdl3_wgpu/main.cpp +++ b/examples/example_sdl3_wgpu/main.cpp @@ -40,8 +40,8 @@ static int wgpu_surface_width = 1280; static int wgpu_surface_height = 800; // Forward declarations -static bool InitWGPU(SDL_Window* window); -static WGPUSurface CreateWGPUSurface(const WGPUInstance& instance, SDL_Window* window); +static bool InitWGPU(SDL_Window* window); +WGPUSurface CreateWGPUSurface(const WGPUInstance& instance, SDL_Window* window); static void ResizeSurface(int width, int height) {