aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2024-01-31 19:48:05 +0100
committerAndre Weissflog <floooh@gmail.com>2024-01-31 19:48:05 +0100
commit0c460b3d70ddcb590f64a70fbe3aa603bdd18813 (patch)
tree171873e063915ab920e8809b52ecacceda841179
parent0fae329ae9a27d9e76479b285a78afe1e1a228a6 (diff)
sokol_glue.h: add new helper function sapp_sgswapchain()
-rw-r--r--sokol_glue.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/sokol_glue.h b/sokol_glue.h
index 7216f6a1..01dbcb51 100644
--- a/sokol_glue.h
+++ b/sokol_glue.h
@@ -95,6 +95,7 @@ extern "C" {
#if defined(SOKOL_GFX_INCLUDED) && defined(SOKOL_APP_INCLUDED)
SOKOL_GLUE_API_DECL sg_context_desc sapp_sgcontext(void);
+SOKOL_GLUE_API_DECL sg_swapchain sapp_sgswapchain(void);
#endif
#ifdef __cplusplus
@@ -119,18 +120,31 @@ SOKOL_API_IMPL sg_context_desc sapp_sgcontext(void) {
desc.depth_format = (sg_pixel_format) sapp_depth_format();
desc.sample_count = sapp_sample_count();
desc.metal.device = sapp_metal_get_device();
- desc.metal.renderpass_descriptor_cb = sapp_metal_get_renderpass_descriptor;
- desc.metal.drawable_cb = sapp_metal_get_drawable;
desc.d3d11.device = sapp_d3d11_get_device();
desc.d3d11.device_context = sapp_d3d11_get_device_context();
- desc.d3d11.render_target_view_cb = sapp_d3d11_get_render_target_view;
- desc.d3d11.depth_stencil_view_cb = sapp_d3d11_get_depth_stencil_view;
desc.wgpu.device = sapp_wgpu_get_device();
- desc.wgpu.render_view_cb = sapp_wgpu_get_render_view;
- desc.wgpu.resolve_view_cb = sapp_wgpu_get_resolve_view;
- desc.wgpu.depth_stencil_view_cb = sapp_wgpu_get_depth_stencil_view;
return desc;
}
+
+SOKOL_API_IMPL sg_swapchain sapp_sgswapchain(void) {
+ sg_swapchain swapchain;
+ memset(&swapchain, 0, sizeof(swapchain));
+ swapchain.width = sapp_width();
+ swapchain.height = sapp_height();
+ swapchain.sample_count = sapp_sample_count();
+ swapchain.color_format = (sg_pixel_format)sapp_color_format();
+ swapchain.depth_format = (sg_pixel_format)sapp_depth_format();
+ swapchain.metal.render_pass_descriptor = sapp_metal_get_renderpass_descriptor();
+ swapchain.metal.drawable = sapp_metal_get_drawable();
+ swapchain.d3d11.render_target_view = sapp_d3d11_get_render_target_view();
+ swapchain.d3d11.depth_stencil_view = sapp_d3d11_get_depth_stencil_view();
+ swapchain.wgpu.render_view = sapp_wgpu_get_render_view();
+ swapchain.wgpu.resolve_view = sapp_wgpu_get_resolve_view();
+ swapchain.wgpu.depth_stencil_view = sapp_wgpu_get_depth_stencil_view();
+ // FIXME!
+ // swapchain.gl.framebuffer = sapp_gl_get_framebuffer();
+ return swapchain;
+}
#endif
#endif /* SOKOL_GLUE_IMPL */