gpu: add SwapChain.configure
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
f05fdf4414
commit
258db701a7
2 changed files with 22 additions and 1 deletions
|
|
@ -484,6 +484,17 @@ const swap_chain_vtable = SwapChain.VTable{
|
|||
c.wgpuSwapChainRelease(@ptrCast(c.WGPUSwapChain, ptr));
|
||||
}
|
||||
}).release,
|
||||
.configure = (struct {
|
||||
pub fn configure(ptr: *anyopaque, format: TextureFormat, allowed_usage: TextureUsage, width: u32, height: u32) void {
|
||||
c.wgpuSwapChainConfigure(
|
||||
@ptrCast(c.WGPUSwapChain, ptr),
|
||||
@enumToInt(format),
|
||||
@enumToInt(allowed_usage),
|
||||
width,
|
||||
height,
|
||||
);
|
||||
}
|
||||
}).configure,
|
||||
};
|
||||
|
||||
test "syntax" {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ vtable: *const VTable,
|
|||
pub const VTable = struct {
|
||||
reference: fn (ptr: *anyopaque) void,
|
||||
release: fn (ptr: *anyopaque) void,
|
||||
configure: fn (ptr: *anyopaque, format: TextureFormat, allowed_usage: TextureUsage, width: u32, height: u32) void,
|
||||
// TODO:
|
||||
// WGPU_EXPORT void wgpuSwapChainConfigure(WGPUSwapChain swapChain, WGPUTextureFormat format, WGPUTextureUsageFlags allowedUsage, uint32_t width, uint32_t height);
|
||||
// WGPU_EXPORT WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain);
|
||||
// WGPU_EXPORT void wgpuSwapChainPresent(WGPUSwapChain swapChain);
|
||||
};
|
||||
|
|
@ -27,6 +27,16 @@ pub inline fn release(swap_chain: SwapChain) void {
|
|||
swap_chain.vtable.release(swap_chain.ptr);
|
||||
}
|
||||
|
||||
pub inline fn configure(
|
||||
swap_chain: SwapChain,
|
||||
format: TextureFormat,
|
||||
allowed_usage: TextureUsage,
|
||||
width: u32,
|
||||
height: u32,
|
||||
) void {
|
||||
swap_chain.vtable.configure(swap_chain.ptr, format, allowed_usage, width, height);
|
||||
}
|
||||
|
||||
pub const Descriptor = struct {
|
||||
label: ?[]const u8 = null,
|
||||
usage: TextureUsage,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue