Hi, I'm writing a small UI library in IMGUI style, and I wonder how to reduce the number of draw calls. For example, if I draw a button, it will have a background and a text on top, so the code looks like:
bool button(char *text) { // .. drawRect(..); drawText(..); // .. }
So if I have a lot of buttons, the render commands will be rect, text, rect, text, .. The problem is that I have to change shaders between rects and text. I would like to be able to draw all rectangles at once first and then all the texts. How can I do that in an IMGUI style? In retained mode I think that we would just maintain the order of the commands and just hand that off to the GPU at once.