Is there any way to glEnable GL_SCISSOR_TEST inside an already enabled GL_SCISSOR_TEST? Like the following:
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(0, 0, 64, 64);
draw.rect();
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(32, 32, 48, 48);
draw.smallRect();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
I have tried the above and it seems to not work as expected and even by looking at the code it looks very illogical but I can't think of a way around this.
OpenGL state variables don't nest. This is essentially the same as doing
bool scissor_test_enabled;
scissor_test_enabled = true;
...
scissor_test_enabled = true;
...
scissor_test_enabled = true;
Scissor testing won't help you with your problem. You should look at stencil testing: Using the stencil buffer you can draw arbitrary shapes, having color and depth writes disabled, writing to the stencil buffer (getting a stencil buffer must be requested just like a depth buffer). Then enable stencil testing and draw your regular geometry with color and depth writes enabled.