Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by Lucius Q. User

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.

  • 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 by Lucius Q. User

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.