Provide weak default implementation for wgpuInstanceCreateSurface

This commit is contained in:
Sebastian Emanuel Dawid 2025-09-29 14:40:31 +02:00
parent b0b39d678e
commit 044774dcee
3 changed files with 19 additions and 2 deletions

View File

@ -73,8 +73,16 @@ int main(void)
exit(EXIT_FAILURE);
}
WGPUAdapter adapter;
WGPUSurface surface = glfwCreateWindowWGPUSurface(instance, window);
if (!surface)
{
fprintf(stderr, "Error: Failed to create WebGPU surface.\n");
wgpuInstanceRelease(instance);
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_FAILURE);
}
WGPUAdapter adapter;
WGPUDevice device;
WGPUQueue queue;
bool success = false;

View File

@ -367,7 +367,9 @@ typedef struct WGPUSurfaceDescriptor
WGPUStringView label;
} WGPUSurfaceDescriptor;
extern WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, const WGPUSurfaceDescriptor* descriptor) __attribute((weak));
#if !defined(_MSC_VER)
WGPUSurface __attribute__((weak)) wgpuInstanceCreateSurface(WGPUInstance instance, const WGPUSurfaceDescriptor* descriptor);
#endif
#include "platform.h"

View File

@ -29,6 +29,13 @@
#include <assert.h>
#include <stdlib.h>
#if !defined(_MSC_VER)
WGPUSurface __attribute__((weak)) wgpuInstanceCreateSurface(WGPUInstance instance, const WGPUSurfaceDescriptor* descriptor)
{
return NULL;
}
#endif
GLFWAPI WGPUSurface glfwCreateWindowWGPUSurface(WGPUInstance instance, GLFWwindow* handle)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL)