edubart/sokol_gp

Region calculation

Closed this issue · 1 comments

Hello,

If I set the projection sgp_project(-ratio, ratio, 1.0f, -1.0f);. Rendering many entities yield a lot of draw calls. I think because the region calculation in sgp_draw_filled_rects, and sgp_draw_textured_rects has a problem causing the overlap calculation to yield false positives.

Shouldn't sgp_region region = {1.0f, 1.0f, -1.0f, -1.0f};
be something like sgp_region region = {FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX};? So the min, max calculations work correctly?

Edit:
If the shapes are drawn outside the -1.0-1.0 range.

Thanks

You are correct, thanks for noticing that and reporting, I've fixed that. This is not really a bug, but a missing opportunity to batch primitives when they are out of screen bounds.

Ideally primitives completely out of screen, viewport and scissor bounds should not even be dispatched to the GPU.
In the fix I've also added an optimization to skip draws when they are not visible in the screen. But for viewport and scissor regions I've not done that yet, maybe in the future.