@@ -3245,13 +3245,20 @@ typedef struct sg_wgpu_context_desc {
3245
3245
void* user_data;
3246
3246
} sg_wgpu_context_desc;
3247
3247
3248
+ typedef struct sg_gl_context_desc {
3249
+ uint32_t (*default_framebuffer_cb)(void);
3250
+ uint32_t (*default_framebuffer_userdata_cb)(void*);
3251
+ void* user_data;
3252
+ } sg_gl_context_desc;
3253
+
3248
3254
typedef struct sg_context_desc {
3249
3255
sg_pixel_format color_format;
3250
3256
sg_pixel_format depth_format;
3251
3257
int sample_count;
3252
3258
sg_metal_context_desc metal;
3253
3259
sg_d3d11_context_desc d3d11;
3254
3260
sg_wgpu_context_desc wgpu;
3261
+ sg_gl_context_desc gl;
3255
3262
} sg_context_desc;
3256
3263
3257
3264
/*
@@ -7036,6 +7043,8 @@ _SOKOL_PRIVATE void _sg_gl_reset_state_cache(void) {
7036
7043
7037
7044
_SOKOL_PRIVATE void _sg_gl_setup_backend(const sg_desc* desc) {
7038
7045
_SOKOL_UNUSED(desc);
7046
+ SOKOL_ASSERT(desc->context.gl.default_framebuffer_cb == 0 || desc->context.gl.default_framebuffer_userdata_cb == 0);
7047
+
7039
7048
// assumes that _sg.gl is already zero-initialized
7040
7049
_sg.gl.valid = true;
7041
7050
@@ -7724,6 +7733,12 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(_sg_pass_t* pass, const sg_pass_action* ac
7724
7733
#if defined(SOKOL_GLCORE33)
7725
7734
glDisable(GL_FRAMEBUFFER_SRGB);
7726
7735
#endif
7736
+ if (_sg.desc.context.gl.default_framebuffer_userdata_cb) {
7737
+ _sg.gl.cur_context->default_framebuffer = _sg.desc.context.gl.default_framebuffer_userdata_cb(_sg.desc.context.gl.user_data);
7738
+ } else if (_sg.desc.context.gl.default_framebuffer_cb) {
7739
+ _sg.gl.cur_context->default_framebuffer = _sg.desc.context.gl.default_framebuffer_cb();
7740
+ }
7741
+
7727
7742
glBindFramebuffer(GL_FRAMEBUFFER, _sg.gl.cur_context->default_framebuffer);
7728
7743
}
7729
7744
glViewport(0, 0, w, h);
0 commit comments