Skip to content

Commit

Permalink
Merge branch 'danielchasehooper-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Sep 23, 2023
2 parents 7277c7f + fe76ca5 commit 48987bc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## Updates

#### 23-Sep-2023

- sokol_gfx.h gl: Allow to inject an external GL framebuffer id into the sokol-gfx default
pass. See PR https://github.com/floooh/sokol/pull/899 and issue https://github.com/floooh/sokol/issues/892
for details. Many thanks to @danielchasehooper for the discussion and PR!

Further down the road I want to make the whole topic more flexible while at the same time
simplifying the sokol-gfx API, see here: https://github.com/floooh/sokol/issues/904

#### 22-Sep-2023

- sokol_gfx.h: Fixed a Metal validation error on Intel Macs when creating textures (Intel Macs
Expand Down
2 changes: 2 additions & 0 deletions bindgen/gen_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ def funcptr_result_c(field_type):
res_type = field_type[: field_type.index("(*)")].strip()
if res_type == "void":
return ""
elif is_prim_type(res_type):
return as_rust_prim_type(res_type)
elif util.is_const_void_ptr(res_type):
return " -> *const core::ffi::c_void"
elif util.is_void_ptr(res_type):
Expand Down
2 changes: 2 additions & 0 deletions bindgen/gen_zig.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ def funcptr_result_c(field_type):
res_type = field_type[:field_type.index('(*)')].strip()
if res_type == 'void':
return 'void'
elif is_prim_type(res_type):
return as_zig_prim_type(res_type)
elif util.is_const_void_ptr(res_type):
return '?*const anyopaque'
elif util.is_void_ptr(res_type):
Expand Down
15 changes: 15 additions & 0 deletions sokol_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -3245,13 +3245,20 @@ typedef struct sg_wgpu_context_desc {
void* user_data;
} sg_wgpu_context_desc;

typedef struct sg_gl_context_desc {
uint32_t (*default_framebuffer_cb)(void);
uint32_t (*default_framebuffer_userdata_cb)(void*);
void* user_data;
} sg_gl_context_desc;

typedef struct sg_context_desc {
sg_pixel_format color_format;
sg_pixel_format depth_format;
int sample_count;
sg_metal_context_desc metal;
sg_d3d11_context_desc d3d11;
sg_wgpu_context_desc wgpu;
sg_gl_context_desc gl;
} sg_context_desc;

/*
Expand Down Expand Up @@ -7036,6 +7043,8 @@ _SOKOL_PRIVATE void _sg_gl_reset_state_cache(void) {

_SOKOL_PRIVATE void _sg_gl_setup_backend(const sg_desc* desc) {
_SOKOL_UNUSED(desc);
SOKOL_ASSERT(desc->context.gl.default_framebuffer_cb == 0 || desc->context.gl.default_framebuffer_userdata_cb == 0);

// assumes that _sg.gl is already zero-initialized
_sg.gl.valid = true;

Expand Down Expand Up @@ -7724,6 +7733,12 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(_sg_pass_t* pass, const sg_pass_action* ac
#if defined(SOKOL_GLCORE33)
glDisable(GL_FRAMEBUFFER_SRGB);
#endif
if (_sg.desc.context.gl.default_framebuffer_userdata_cb) {
_sg.gl.cur_context->default_framebuffer = _sg.desc.context.gl.default_framebuffer_userdata_cb(_sg.desc.context.gl.user_data);
} else if (_sg.desc.context.gl.default_framebuffer_cb) {
_sg.gl.cur_context->default_framebuffer = _sg.desc.context.gl.default_framebuffer_cb();
}

glBindFramebuffer(GL_FRAMEBUFFER, _sg.gl.cur_context->default_framebuffer);
}
glViewport(0, 0, w, h);
Expand Down

0 comments on commit 48987bc

Please sign in to comment.