Skip to content

Commit

Permalink
Update to new IDL. Complete header file.
Browse files Browse the repository at this point in the history
  • Loading branch information
juj committed May 28, 2021
1 parent 893b6ed commit 4e31389
Show file tree
Hide file tree
Showing 9 changed files with 2,496 additions and 468 deletions.
10 changes: 5 additions & 5 deletions clear_screen/clear_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ EM_BOOL raf(double time, void *userData)
colorAttachment.view = wgpu_texture_create_view(wgpu_swap_chain_get_current_texture(swapChain), 0);

double hue = time * 0.00005;
colorAttachment.loadColor[0] = hue2color(hue + 1.0 / 3.0);
colorAttachment.loadColor[1] = hue2color(hue);
colorAttachment.loadColor[2] = hue2color(hue - 1.0 / 3.0);
colorAttachment.loadColor[3] = 1.0;
colorAttachment.loadColor.r = hue2color(hue + 1.0 / 3.0);
colorAttachment.loadColor.g = hue2color(hue);
colorAttachment.loadColor.b = hue2color(hue - 1.0 / 3.0);
colorAttachment.loadColor.a = 1.0;

WGpuRenderPassDescriptor passDesc = {};
passDesc.numColorAttachments = 1;
Expand All @@ -50,7 +50,7 @@ void ObtainedWebGpuDevice(WGpuDevice result, void *userData)
WGpuSwapChainDescriptor swapChainDesc = WGPU_SWAP_CHAIN_DESCRIPTOR_DEFAULT_INITIALIZER;
swapChainDesc.device = device;
swapChainDesc.format = wgpu_canvas_context_get_swap_chain_preferred_format(canvasContext, adapter);
swapChain = wgpu_canvascontext_configure_swap_chain(canvasContext, &swapChainDesc);
swapChain = wgpu_canvas_context_configure_swap_chain(canvasContext, &swapChainDesc);

emscripten_request_animation_frame_loop(raf, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions hello_triangle/hello_triangle_minimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ EM_BOOL raf(double time, void *userData)

WGpuRenderPassColorAttachment colorAttachment = {};
colorAttachment.view = wgpu_texture_create_view(wgpu_swap_chain_get_current_texture(swapChain), 0);
colorAttachment.loadColor[3] = 1.0;
colorAttachment.loadColor.a = 1.0;

WGpuRenderPassDescriptor passDesc = {};
passDesc.numColorAttachments = 1;
Expand Down Expand Up @@ -43,7 +43,7 @@ void ObtainedWebGpuDevice(WGpuDevice result, void *userData)
swapChainDesc.device = device;
swapChainDesc.format = wgpu_canvas_context_get_swap_chain_preferred_format(canvasContext, adapter);

swapChain = wgpu_canvascontext_configure_swap_chain(canvasContext, &swapChainDesc);
swapChain = wgpu_canvas_context_configure_swap_chain(canvasContext, &swapChainDesc);

const char *vertexShader =
"const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>("
Expand Down
4 changes: 2 additions & 2 deletions hello_triangle/hello_triangle_verbose.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ EM_BOOL raf(double time, void *userData)
assert(swapChainTexture == swapChainTexture2);

colorAttachment.view = wgpu_texture_create_view(swapChainTexture, 0);
colorAttachment.loadColor[3] = 1.0;
colorAttachment.loadColor.a = 1.0;
assert(wgpu_is_texture_view(colorAttachment.view));

WGpuRenderPassDescriptor passDesc = {};
Expand Down Expand Up @@ -75,7 +75,7 @@ void ObtainedWebGpuDevice(WGpuDevice result, void *userData)
swapChainDesc.format = wgpu_canvas_context_get_swap_chain_preferred_format(canvasContext, adapter);
emscripten_mini_stdio_printf("Preferred swap chain format: %s\n", wgpu_enum_to_string(swapChainDesc.format));

swapChain = wgpu_canvascontext_configure_swap_chain(canvasContext, &swapChainDesc);
swapChain = wgpu_canvas_context_configure_swap_chain(canvasContext, &swapChainDesc);
assert(wgpu_is_swap_chain(swapChain));

const char *vertexShader =
Expand Down
3 changes: 2 additions & 1 deletion lib/lib_webgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const WGpuDeviceDescriptor WGPU_DEVICE_DESCRIPTOR_DEFAULT_INITIALIZER = {
};

const WGpuSwapChainDescriptor WGPU_SWAP_CHAIN_DESCRIPTOR_DEFAULT_INITIALIZER = {
.usage = WGPU_TEXTURE_USAGE_RENDER_ATTACHMENT
.usage = WGPU_TEXTURE_USAGE_RENDER_ATTACHMENT,
.compositingAlphaMode = WGPU_CANVAS_COMPOSITING_ALPHA_MODE_OPAQUE
};

const WGpuColorTargetState WGPU_COLOR_TARGET_STATE_DEFAULT_INITIALIZER = {
Expand Down
Loading

0 comments on commit 4e31389

Please sign in to comment.