Closed roig closed 3 months ago
For GL you can cheat a bit, since OpenGL doesn't care, only the sokol-gfx validation layer will complain if the pixel formats and sample counts of the pipeline objects used in a swapchain pass don't match. For the Metal and WebGPU backends, that information is more critical though.
Inside sg_begin_pass()
zero-initialized fields are replaced with the common defaults for the pixel formats and sample count (the same defaults used when creating pipeline objects), so you don't actually need to provide pixel formats and sample count if it matches the defaults that were already provided in the sg_setup() call:
So typically it should work to just provide an 'empty' (zero-initialized) sg_swapchain struct - except for width and height - in the sg_begin_pass() call.
You can also check how I'm doing it in the GLFW samples:
...for the GL backend, it doesn't actually matter whether the actual framebuffer is RGBA8 or something else, it just needs to be consistent for the sokol-gfx validation layer.
In general I think it's a good idea if you create a similar looking 'sdl_glue.h/.c' file, or at least create similar helper functions to return an sg_environment and sg_swapchain struct.
And just curiosity but, why all this information is needed now?
That same information was taken from the sg_desc.context
struct before, so it was already there, just a bit reshuffled.
Hello! I'm using sokol (OpenGL 3.3) and SDL2 for initializing the window and a GL3.3 context.
With the new change I don't know what exactly I should put in the new
sg_swapchain
struct. I'm not using D3D, metal etc..Using try and error I found that this works but it's because I have my pipeline configured with these color, depth and sample.
I'm supposed to call SDL_GL_GetAttribute with:
And make a gigantic switch for each combination for
color_format
?The same with for
depth_format
?For
sample_count
I'm not sure which one is the correct one:For the
gl.framebuffer
should be 0 always?And just curiosity but, why all this information is needed now?
Thanks.