In some situations, sokol_imgui.h doesn't seem to properly bind its font texture when sgl_draw() is called before simgui_render(). Need to investigate.
"it seems to me that simgui_render binds its pipeline properly, so I'm guessing there's leaked state from sgl_draw that I might need to restore? As a test, I'm calling only drawTriangle from sgl-sapp.c, which works. If I don't call drawTriangle (but do invoke sgl_draw()) then simgui_render works."
...this might also be a hole in the sokol-gfx validation layer(?).
Potential fix: https://github.com/floooh/sokol/commit/51f4c084c6ba117e12d612c6ab625c0fb1877aeb
Waiting for feedback...
This fixes the issue in my test program, thanks so much!!
Update - it looks like it's not completely fixed - if I tweak the drawTriangle routine thus:
c
static void draw_triangle(void) {
sgl_defaults();
static float wut = 0.f;
sgl_scale(1.f + wut, 1.f, 1.f);
wut += 0.015f;
sgl_begin_triangles();
sgl_v2f_c3b(0.0f, 0.5f, 255, 0, 0);
sgl_v2f_c3b(-0.5f, -0.5f, 0, 0, 255);
sgl_v2f_c3b(0.5f, -0.5f, 0, 255, 0);
sgl_end();
}
The triangle becomes clipped as it passes the center of the window. Pretty sure it's a hidpi thing - as a hack/test I hacked the SGL_COMMAND_VIEWPORT to adjust the viewport there, and the triangle appears in the middle of the screen rather than upper left-ish.
...next issue might be the leaked scissor-rect from simgui_render(), when this exits, the scissor rect will be set to whatever the last one was during UI rendering, until the next begin-pass call.
I'll set the scissor-rect to "fullscreen" on exiting simgui_render(), so that there's at least a guaranteed state.
PS: reading your description of the issue it might still be some other unrelated thing... I'll try to look into this today.
Potential fix (set viewport and scissor to 'fullscreen' in simgui_render() entry and exit): https://github.com/floooh/sokol/commit/1dde6a20860e86c96572bb65d8145f1d0360f132
(even if it doesn't fix the specific issue it's the right thing to do IMHO)
I think everything is working properly now. My objects clip to the screen as expected, and are also the expected size. Thanks again!
Ok great :) Closing the issue again, for now ;)