floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.82k stars 475 forks source link

sokol_imgui.h, sokol_nuklear.h: add an image/sampler pair resource type. #860

Closed floooh closed 1 year ago

floooh commented 1 year ago

The separate image/sampler update in sokol_gfx.h led to a regression for user images in sokol_imgui.h and sokol_nuklear.h: since the respective image handles may only be 32 bits, it's not possible to stash an sg_image handle and sg_sampler handle in there.

Solution is to create an 'image/sample pair object' both in sokol_imgui.h and sokol_nuklear.h, which can then be referenced with a 32-bit handle, for instance in sokol_imgui.h:

simgui_image simgui_make_image(sg_image img, sg_sampler smp);
void simgui_destroy_image(simgui_image);
void* simgui_imtextureid(simgui_image img);
floooh commented 1 year ago

Fixed.