mirror of
https://github.com/glfw/glfw.git
synced 2025-12-20 22:22:04 +00:00
Compare commits
3 Commits
379e5d1617
...
9b29acbae0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b29acbae0 | ||
|
|
1471e07ceb | ||
|
|
044774dcee |
@ -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;
|
||||
|
||||
@ -6536,6 +6536,19 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window
|
||||
|
||||
#if defined(WEBGPU_H_)
|
||||
|
||||
/*! @brief Provide the address of the `wgpuInstanceCreateSurface` function to GLFW.
|
||||
*
|
||||
* This function passes the address provided for the `wgpuInstanceCreateSurface` function
|
||||
* to GLFW.
|
||||
*
|
||||
* @param[in] addr The address of the `wgpuInstanceCreateSurface` function.
|
||||
*
|
||||
* @since Added in version 3.5
|
||||
*
|
||||
* @ingroup webgpu
|
||||
*/
|
||||
GLFWAPI void glfwSetWGPUInstanceCreateSurfaceAddr(WGPUSurface (*addr)(WGPUInstance, const WGPUSurfaceDescriptor*));
|
||||
|
||||
/*! @brief Creates a WebGPU surface for the specified window.
|
||||
*
|
||||
* This function creates a WebGPU surface for the specified window.
|
||||
|
||||
@ -367,7 +367,8 @@ typedef struct WGPUSurfaceDescriptor
|
||||
WGPUStringView label;
|
||||
} WGPUSurfaceDescriptor;
|
||||
|
||||
extern WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, const WGPUSurfaceDescriptor* descriptor) __attribute((weak));
|
||||
typedef WGPUSurface (*PFN_wgpuInstanceCreateSurface)(WGPUInstance, const WGPUSurfaceDescriptor*);
|
||||
#define wgpuInstanceCreateSurface _glfw.wgpu.instanceCreateSurface
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
@ -914,6 +915,10 @@ struct _GLFWlibrary
|
||||
GLFWbool EXT_headless_surface;
|
||||
} vk;
|
||||
|
||||
struct {
|
||||
PFN_wgpuInstanceCreateSurface instanceCreateSurface;
|
||||
} wgpu;
|
||||
|
||||
struct {
|
||||
GLFWmonitorfun monitor;
|
||||
GLFWjoystickfun joystick;
|
||||
|
||||
@ -29,6 +29,12 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
GLFWAPI void glfwSetWGPUInstanceCreateSurfaceAddr(WGPUSurface (*addr)(WGPUInstance, const WGPUSurfaceDescriptor*))
|
||||
{
|
||||
_GLFW_REQUIRE_INIT()
|
||||
_glfw.wgpu.instanceCreateSurface = addr;
|
||||
}
|
||||
|
||||
GLFWAPI WGPUSurface glfwCreateWindowWGPUSurface(WGPUInstance instance, GLFWwindow* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL)
|
||||
@ -37,7 +43,7 @@ GLFWAPI WGPUSurface glfwCreateWindowWGPUSurface(WGPUInstance instance, GLFWwindo
|
||||
|
||||
assert(window != NULL);
|
||||
assert(instance != NULL);
|
||||
assert(&wgpuInstanceCreateSurface != NULL);
|
||||
assert(_glfw.wgpu.instanceCreateSurface != NULL);
|
||||
|
||||
if (window->context.client != GLFW_NO_API)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user