content: package me.earth.earthhack.impl.util.render;
  
  import net.minecraft.client.Minecraft;
  import net.minecraft.client.renderer.OpenGlHelper;
  import net.minecraft.client.shader.Framebuffer;
  import org.lwjgl.opengl.EXTFramebufferObject;
  import org.lwjgl.opengl.EXTPackedDepthStencil;
  import org.lwjgl.opengl.GL11;
  
  public class OutlineUtil {
  
  
      public static void renderOne()
      {
          checkSetupFBO();
          GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
          GL11.glDisable(GL11.GL_ALPHA_TEST);
          GL11.glDisable(GL11.GL_TEXTURE_2D);
          GL11.glDisable(GL11.GL_LIGHTING);
          GL11.glEnable(GL11.GL_BLEND);
          GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
          GL11.glLineWidth(3);
          GL11.glEnable(GL11.GL_LINE_SMOOTH);
          GL11.glEnable(GL11.GL_STENCIL_TEST);
          GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
          GL11.glClearStencil(0xF);
          GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xF);
          GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_REPLACE, GL11.GL_REPLACE);
          GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
      }
  
      public static void renderTwo()
      {
          GL11.glStencilFunc(GL11.GL_NEVER, 0, 0xF);
          GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_REPLACE, GL11.GL_REPLACE);
          GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
      }
  
      public static void renderThree()
      {
          GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xF);
          GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
          GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
      }
  
      public static void renderFour()
      {
          GL11.glDepthMask(false);
          GL11.glDisable(GL11.GL_DEPTH_TEST);
          GL11.glEnable(GL11.GL_POLYGON_OFFSET_LINE);
          GL11.glPolygonOffset(1.0F, -2000000F);
          OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
      }
  
      public static void renderFive()
      {
          GL11.glPolygonOffset(1.0F, 2000000F);
          GL11.glDisable(GL11.GL_POLYGON_OFFSET_LINE);
          GL11.glEnable(GL11.GL_DEPTH_TEST);
          GL11.glDepthMask(true);
          GL11.glDisable(GL11.GL_STENCIL_TEST);
          GL11.glDisable(GL11.GL_LINE_SMOOTH);
          GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_DONT_CARE);
          GL11.glEnable(GL11.GL_BLEND);
          GL11.glEnable(GL11.GL_LIGHTING);
          GL11.glEnable(GL11.GL_TEXTURE_2D);
          GL11.glEnable(GL11.GL_ALPHA_TEST);
          GL11.glPopAttrib();
      }
  
      public static void checkSetupFBO()
      {
          Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer();
  
          if (fbo.depthBuffer > -1)
          {
              setupFBO(fbo);
              fbo.depthBuffer = -1;
          }
      }
  
      public static void setupFBO(Framebuffer fbo)
      {
          EXTFramebufferObject.glDeleteRenderbuffersEXT(fbo.depthBuffer);
          int stencil_depth_buffer_ID = EXTFramebufferObject.glGenRenderbuffersEXT();
          EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
          EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, EXTPackedDepthStencil.GL_DEPTH_STENCIL_EXT, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
          EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
          EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
      }
  }
  