Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ScissorTest
- {
- private static final int max = 100;
- private static ScissorTest[] objects = new ScissorTest[max];
- private static int lastObject = -1;
- private int index;
- private Body body;
- public ScissorTest(int x, int y, int width, int height)
- {
- lastObject++;
- if (lastObject < max)
- {
- index = lastObject;
- objects[index] = this;
- body = new Body(x, y, width, height);
- resume();
- }
- else
- {
- new Exception("\nScissor count limit reached: " + max).printStackTrace();
- System.exit(1);
- }
- }
- private void resume()
- {
- GL11.glScissor(body.x, body.y, body.width, body.height);
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
- }
- public void destroy()
- {
- if (index < lastObject)
- {
- new Exception("\nThere are scissors below this one").printStackTrace();
- System.exit(1);
- }
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- objects[index] = null;
- lastObject--;
- if (lastObject > -1)
- objects[lastObject].resume(); // Resuming previous scissor
- }
- protected void finalize()
- {
- destroy();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement