Posted July 1, 20178 yr EDIT: I switched to using scissor test. I am trying to set up stencil buffer to cut everything that gets drawn outside of a specific rectangle in the gui. Instead, everything that is drawn after the stencil buffer is set up gets cut; Here is the stencil set up code: public static void setUpStencil(int left, int top, int right, int bottom) { if (left < right) { int i = left; left = right; right = i; } if (top < bottom) { int j = top; top = bottom; bottom = j; } Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); GL11.glEnable(GL11.GL_STENCIL_TEST); GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_REPLACE); GL11.glStencilMask(0xFF); GL11.glDepthMask(false); GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); vertexbuffer.pos(left, bottom, 0.0D).endVertex(); vertexbuffer.pos(right, bottom, 0.0D).endVertex(); vertexbuffer.pos(right, top, 0.0D).endVertex(); vertexbuffer.pos(left, top, 0.0D).endVertex(); tessellator.draw(); GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); GL11.glStencilMask(0x00); GL11.glDepthMask(true); } Here is the actual drawing code: drawDefaultBackground(); setUpStencil(20, 20, width - 20, height - 20); drawRect(0, 0, 50, 65); //Some drawRect calls here Edited July 1, 20178 yr by Lucius Q. User
July 1, 20178 yr You would have to reset the stencil buffer. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
July 1, 20178 yr Author Sorry, what? I have just set it up and it cuts everything drawn while it is active.
July 1, 20178 yr Make sure that you enabled (created) stencil buffer. By default, MC does not create one. Alternatively, because you're in 2D, use scissors. Edited July 1, 20178 yr by Elix_x Added link to stencil buffer creation with Forge Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
July 1, 20178 yr Author I did enable it. The problem is not that it is not cutting anything, but rather that it cuts too much. EDIT: The problem is as follows: drawRect(...)// <- gets drawn setUpStencil(...) drawRect(...) // <- gets cut entirely (should get cut only partially) disableStencil() drawRect(...) // <- gets drawn Edited July 1, 20178 yr by Lucius Q. User
July 2, 20178 yr When stencils don't work for me right away, i usually enable the color write and draw the stencil'ed region with colors, then i go into debug mode and play with it until i get it to work. Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.