-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Multi-window support" brain dump #229
Comments
A proof of concept implementation can be found here with the test file here which creates multiple windows, each using sokol gfx. This is by no means complete and should seen as a way to get the ball rolling / discussions started. It is currently only working on Windows with D3D11. Please refer to the comments (make a diff to master to see what changed) in the sokol_app.h + sokol_gfx.h. As I do not know the limitations/quirks of the non-Windows platforms supported by sokol app/gfx input and help is needed to take this further. |
Personally as a user I would far prefer |
For me this is very important since I wanted to use Sokol as a backend for a UI engine. It's not possible, until this is implemented. |
(For posterity, posting here as well) ImGui multiviewport integration:Demo: https://twitter.com/ikrimae/status/1252194400681127936
|
This is impressive. can't wait for multi-view + imgui support on the official repo |
Curious about the state of this, whether or not the plan includes multi-window iOS support? |
@kattkieru I just merged & updated my fork (https://github.com/ikrima/sokol) to the latest. It's mostly updated to be idiomatic with the rest of sokol Having that said, some caveats
But given some of the changes in sokol like user context data/etc, it's a bit more feasible to merge into main + add other platforms (cc: @floooh ) It still needs a decent cleanup pass tho since I usually just hack whatever my pressing need is |
Thanks for the headsup. I'll need to set aside a bit of time to play around and get familiar with your fork and my year-end vacation is coming up. It'll most likely slip into the next year. |
No rush! Only tagged you for your curiosity; fork isn't really in a good PR ready form + cleaning up some old outstanding bugs. Probably will be till next year before i fully sanitize it as well |
@ikrima Excellent timing, as I'm looking at this again for my christmas break. Thanks for posting! |
@ikrima @kattkieru I've opened a new pull-request that has a more complete multi-window implementation (using some of the previous work done here already): #437 Happy to hear thoughts/feedback! |
@stbachmann excellent. Don't have too much time right now to dive into it but from quick scan, the only thing that sticks out is updating the sokol imgui bits. There's a bug in the imgui shader bc it doesn't scale the vtx position according to the window clipspace (imgui emits in absolute window space in multiviewport mode). Here's the updated shader: @module _simgui
@vs vs
uniform vs_params {
vec4 disp_rect;
};
in vec2 position;
in vec2 texcoord0;
in vec4 color0;
out vec2 uv;
out vec4 color;
void main() {
gl_Position = vec4((((position-disp_rect.xy)/disp_rect.zw)-0.5)*vec2(2.0,-2.0), 0.5, 1.0);
uv = texcoord0;
color = color0;
}
@end
@fs fs
uniform sampler2D tex;
in vec2 uv;
in vec4 color;
out vec4 frag_color;
void main() {
frag_color = texture(tex, uv) * color;
}
@end
@program simgui vs fs |
@ikrima thanks, great pointer. I'll check out what you did on your branch to make this work. 👍 |
As mentioned before by @medvednikov this is necessary for V lang's (>21k stars) fantastic V UI library. Highly compelling. |
Is there any news about support for multiple contexts? Maybe some plans or forecasts |
So from my side, I abandonded the old multiwindow branch I had started because it became too gnarly (and also required too many changes in sokol_gfx.h). sokol_gfx.h at least will become more flexible to support multi-window scenarios when this is implemented: (since there will no longer be a special 'default frame buffer' but instead just one or multiple 'external swapchains', the entire context stuff in sokol-gfx will most likely be removed too after this change) This may be the foundation to do another approach with multi-window support in sokol_app.h, but I was also running into an unrelated problem on macOS with MTKView (there's a one-second timeout freeze when a window becomes fully obscured, this isn't noticeable when there's only a single window, but in an application with multiple windows it becomes a problem). |
Has anyone glued together the imgui multiviewports/docking branch & multiple windows with sokol-gfx and glfw per https://github.com/floooh/sokol-samples/blob/master/glfw/multiwindow-glfw.c ? |
Now that #904 is done, I wonder if this'll be implemented. Would be really rad. |
I agree, but the next big things on my mental roadmap are making resource bindings more flexible in sokol_gfx.h, and after that compute shader support. After that it might make sense to go back to sokol_app.h for a bit. |
What's needed to add "proper" multi-window support to sokol_gfx.h and sokol_app.h:
sokol_gfx.h:
Not strictly multi-window specific, but
sg_desc
needs a couple more parameters to describe the default framebuffer, this is only needed for validation whether a pipeline object is compatible with that pass:sg_setup_context() needs a
sg_contect_desc*
param which contains swap-chain / context-specific parameters (a subset of what's in sg_desc):...plus the color/depth pixel formats and sample count.
The callbacks are needed because each window has its own swap chain. The pixel formats and sample count are needed for pipeline validation.
Then, for each window call sg_setup_context(), and before the default render pass of that window, call sg_activate_context().
sokol_app.h:
This will be much more work:
The text was updated successfully, but these errors were encountered: