Guest User

Stencil not working

a guest
Apr 18th, 2022
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1.         GlStateManager.pushMatrix();
  2.         GlStateManager.pushAttrib();
  3.        
  4.         // Clear the stencil buffer
  5.         GL11.glClearStencil(0);
  6.         GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
  7.        
  8.         GL11.glEnable(GL11.GL_STENCIL_TEST);
  9.         GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_REPLACE, GL11.GL_REPLACE);
  10.         GL11.glStencilFunc(GL11.GL_ALWAYS, 1, -1); // 1 is written into the buffer when we draw
  11.         int xMid = width / 2;
  12.         int yMid = height / 2;
  13.         int smallBoxSize = 10;
  14.         drawRect(xMid - smallBoxSize, yMid - smallBoxSize, xMid + smallBoxSize, yMid + smallBoxSize, -1);
  15.            
  16.         // Something something makes the fucking thing work (except it's not working)
  17.         GL11.glStencilFunc(GL11.GL_NOTEQUAL, 1, -1); // Only draw if not equal to 1
  18.         GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
  19.         drawRect(0, 0, width, height, 0xffff0000);
  20.        
  21.         GlStateManager.popAttrib();
  22.         GlStateManager.popMatrix();
Add Comment
Please, Sign In to add comment