edubart/sokol_gp

Duplicated API sgp_draw_textured_rects and sgp_draw_filled_rects ?

pocomane opened this issue · 2 comments

Initially I thought that the filled_rect API should just draw a solid color rectangle, while the textured_rect one should fill it with an image. But I discovered that filled_rect respects the sgp_set_image too! In fact the code of sgp_draw_textured_rects and sgp_draw_filled_rects seems quite similar.

Is this the wanted behavior or I am missing something? I am on linux and I compiled with SOKOL_GLCORE33.

Seems like you are correct, the API could be simplified and this documented, or keep the filled APIs but make it automatically reset image on channel 0 (probably the best to keep compatibility).

I didn't notice this because I usually set/reset image on channel 0 properly, and I think everyone does the same (and should). I have to improve this later, thanks for notifying.

Also in the first Sokol GP versions the code of both functions was very different, while optimizing they became similar, now it's clear that they could be combined.

I have simplified this in ac0f4fe, first sgp_draw_textured_rects was removed because it was redundant with sgp_draw_filled_rects, then sgp_draw_textured_rects_ex was renamed to sgp_draw_textured_rects.

This is a breaking change and may break your code when updating in case you used any of sgp_draw_textured_* APIs.