You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the OpenGL build of our app, each document window has its own CAOpenGLLayer. I've looked into using sg_contexts in order make sg_begin_default_pass render to the correct CAOpenGLLayer framebuffer1. Unfortunately sg_contexts affect resource pooling, which I do not want. All documents share the same glyph buffer and other resources for common visual elements, and I don't want those resources to be destroyed when one document is closed2. I do not want changing the default pass's framebuffer to affect anything to do with resource lifetimes.
Also I haven't seen any documentation guaranteeing that the framebuffer that is bound in drawInCGLContext:pixelFormat:forLayerTime:displayTime:/CGLSetCurrentContext is always the same. So even if resources weren't a concern with sg_context, it seems possible that the framebuffer bound during sg_setup_context might later not be the same framebuffer when sg_begin_default_pass is called ↩
I have all CAOpenGLLayers use the same CGLContextObj for this reason. ↩
I don't love callbacks since they're harder to read than straight-line code. I think there could be a nicer API along the lines of
sg_begin_pass(sg_default_pass(&(sg_default_pass_desc){
.gl.framebuffer = fbo,
.width = width,
.height = height
}), &pass_action)
This would allow writing functions that accept a pass as a parameter and that pass could target either an offscreen buffer or the framebuffer; all without affecting the receiving function's implementation. This would also improve Using Sokol_gfx with multiple CAMetalLayers #885. ↩
The text was updated successfully, but these errors were encountered:
In the OpenGL build of our app, each document window has its own
CAOpenGLLayer
. I've looked into usingsg_context
s in order makesg_begin_default_pass
render to the correct CAOpenGLLayer framebuffer1. Unfortunately sg_contexts affect resource pooling, which I do not want. All documents share the same glyph buffer and other resources for common visual elements, and I don't want those resources to be destroyed when one document is closed2. I do not want changing the default pass's framebuffer to affect anything to do with resource lifetimes.I propose adding:
That way you can return the desired framebuffer via that callback, and would match the apis of the other graphics backends3.
Related to #885
Footnotes
Also I haven't seen any documentation guaranteeing that the framebuffer that is bound in
drawInCGLContext:pixelFormat:forLayerTime:displayTime:
/CGLSetCurrentContext
is always the same. So even if resources weren't a concern with sg_context, it seems possible that the framebuffer bound during sg_setup_context might later not be the same framebuffer when sg_begin_default_pass is called ↩I have all CAOpenGLLayers use the same CGLContextObj for this reason. ↩
I don't love callbacks since they're harder to read than straight-line code. I think there could be a nicer API along the lines of
sg_begin_pass(sg_default_pass(&(sg_default_pass_desc){
.gl.framebuffer = fbo,
.width = width,
.height = height
}), &pass_action)
This would allow writing functions that accept a pass as a parameter and that pass could target either an offscreen buffer or the framebuffer; all without affecting the receiving function's implementation. This would also improve Using Sokol_gfx with multiple CAMetalLayers #885. ↩
The text was updated successfully, but these errors were encountered: