Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- // Clear the stencil buffer
- GL11.glClearStencil(0);
- GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
- GL11.glEnable(GL11.GL_STENCIL_TEST);
- GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_REPLACE, GL11.GL_REPLACE);
- GL11.glStencilFunc(GL11.GL_ALWAYS, 1, -1); // 1 is written into the buffer when we draw
- int xMid = width / 2;
- int yMid = height / 2;
- int smallBoxSize = 10;
- drawRect(xMid - smallBoxSize, yMid - smallBoxSize, xMid + smallBoxSize, yMid + smallBoxSize, -1);
- // Something something makes the fucking thing work (except it's not working)
- GL11.glStencilFunc(GL11.GL_NOTEQUAL, 1, -1); // Only draw if not equal to 1
- GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
- drawRect(0, 0, width, height, 0xffff0000);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
Add Comment
Please, Sign In to add comment