content: package me.earth.earthhack.impl.util.render;
  
  import me.earth.earthhack.api.util.interfaces.Globals;
  import me.earth.earthhack.impl.core.ducks.render.IShaderGroup;
  import me.earth.earthhack.impl.util.math.StopWatch;
  import me.earth.earthhack.impl.util.render.framebuffer.TextureFramebuffer;
  import net.minecraft.client.Minecraft;
  import net.minecraft.client.gui.Gui;
  import net.minecraft.client.gui.ScaledResolution;
  import net.minecraft.client.network.NetworkPlayerInfo;
  import net.minecraft.client.renderer.BufferBuilder;
  import net.minecraft.client.renderer.GlStateManager;
  import net.minecraft.client.renderer.OpenGlHelper;
  import net.minecraft.client.renderer.Tessellator;
  import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
  import net.minecraft.client.shader.Framebuffer;
  import net.minecraft.client.shader.ShaderGroup;
  import net.minecraft.entity.Entity;
  import net.minecraft.entity.item.EntityEnderCrystal;
  import net.minecraft.entity.item.EntityItem;
  import net.minecraft.entity.player.EntityPlayer;
  import net.minecraft.entity.player.EnumPlayerModelParts;
  import net.minecraft.util.ResourceLocation;
  import net.minecraft.util.math.AxisAlignedBB;
  import net.minecraft.util.math.Vec3d;
  import org.lwjgl.BufferUtils;
  import org.lwjgl.opengl.Display;
  import org.lwjgl.opengl.GL11;
  import org.lwjgl.util.glu.GLU;
  
  import java.awt.*;
  import java.nio.FloatBuffer;
  import java.nio.IntBuffer;
  
  public class Render2DUtil implements Globals {
      protected static ShaderGroup blurShader;
      protected static float zLevel;
      protected static Framebuffer buffer;
      protected static int lastScale;
      protected static int lastScaleWidth;
      protected static int lastScaleHeight;
      protected static final ResourceLocation shader = new ResourceLocation("earthhack:shaders/blur.json");
      protected static final StopWatch timer = new StopWatch();
  
  
      public static Vec3d to2D(double x, double y, double z) {
          final FloatBuffer screenCoords = BufferUtils.createFloatBuffer(3);
          final IntBuffer viewport = BufferUtils.createIntBuffer(16);
          final FloatBuffer modelView = BufferUtils.createFloatBuffer(16);
          final FloatBuffer projection = BufferUtils.createFloatBuffer(16);
  
          GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelView);
          GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
          GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
  
          boolean result = GLU.gluProject((float) x, (float) y, (float) z, modelView, projection, viewport, screenCoords);
          if (result) {
              return new Vec3d(screenCoords.get(0), Display.getHeight() - screenCoords.get(1), screenCoords.get(2));
          }
          return null;
      }
  
      public static void initFboAndShader() {
          try {
              if (buffer != null) {
                  buffer.deleteFramebuffer();
              }
              blurShader = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), shader);
              blurShader.createBindFramebuffers(mc.displayWidth, mc.displayHeight);
              buffer = ((IShaderGroup) blurShader).getListFramebuffers().get(0);
              // buffer.enableStencil();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  
      public static void setShaderConfigs(float intensity, float blurWidth, float blurHeight) {
          ((IShaderGroup) blurShader).getListShaders().get(0).getShaderManager().getShaderUniform("Radius").set(intensity);
          ((IShaderGroup) blurShader).getListShaders().get(1).getShaderManager().getShaderUniform("Radius").set(intensity);
  
          ((IShaderGroup) blurShader).getListShaders().get(0).getShaderManager().getShaderUniform("BlurDir").set(blurWidth, blurHeight);
          ((IShaderGroup) blurShader).getListShaders().get(1).getShaderManager().getShaderUniform("BlurDir").set(blurHeight, blurWidth);
      }
  
      public static void drawBlurryRect(float x, float y, float x1, float y1, int intensity, int size) {
          drawRect(
                  (int) x,
                  (int) y,
                  (int) x1,
                  (int) y1, new Color(50, 50, 50, 50).getRGB());
          blurArea(
                  (int) x,
                  (int) y,
                  (int) x1 - (int) x,
                  (int) y1 - (int) y,
                  intensity, size, size);
      }
  
  
      public static void drawRect(float startX, float startY, float endX, float endY, int color) {
          float alpha = (float) (color >> 24 & 255) / 255.0F;
          float red = (float) (color >> 16 & 255) / 255.0F;
          float green = (float) (color >> 8 & 255) / 255.0F;
          float blue = (float) (color & 255) / 255.0F;
          final Tessellator tessellator = Tessellator.getInstance();
          final BufferBuilder bufferbuilder = tessellator.getBuffer();
          GlStateManager.enableBlend();
          GlStateManager.disableTexture2D();
          GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
          bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
          bufferbuilder.pos(startX, endY, 0.0D).color(red, green, blue, alpha).endVertex();
          bufferbuilder.pos(endX, endY, 0.0D).color(red, green, blue, alpha).endVertex();
          bufferbuilder.pos(endX, startY, 0.0D).color(red, green, blue, alpha).endVertex();
          bufferbuilder.pos(startX, startY, 0.0D).color(red, green, blue, alpha).endVertex();
          tessellator.draw();
          GlStateManager.enableTexture2D();
          GlStateManager.disableBlend();
      }
  
  
      public static void drawRectLegacy(float startX, float startY, float endX, float endY, int color) {
          float alpha = (float) (color >> 24 & 255) / 255.0F;
          float red = (float) (color >> 16 & 255) / 255.0F;
          float green = (float) (color >> 8 & 255) / 255.0F;
          float blue = (float) (color & 255) / 255.0F;
          final Tessellator tessellator = Tessellator.getInstance();
          final BufferBuilder bufferbuilder = tessellator.getBuffer();
          GlStateManager.enableBlend();
          GlStateManager.disableTexture2D();
          GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
          bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
          bufferbuilder.pos(startX, endY, 0.0D).color(red, green, blue, alpha).endVertex();
          bufferbuilder.pos(endX, endY, 0.0D).color(red, green, blue, alpha).endVertex();
          bufferbuilder.pos(endX, startY, 0.0D).color(red, green, blue, alpha).endVertex();
          bufferbuilder.pos(startX, startY, 0.0D).color(red, green, blue, alpha).endVertex();
          tessellator.draw();
          GlStateManager.enableTexture2D();
          GlStateManager.disableBlend();
      }
  
      public static void drawUnfilledCircle(float x, float y, float radius, int color, float width) {
          float alpha = (float) (color >> 24 & 255) / 255.0F;
          float red = (float) (color >> 16 & 255) / 255.0F;
          float green = (float) (color >> 8 & 255) / 255.0F;
          float blue = (float) (color & 255) / 255.0F;
          GlStateManager.pushMatrix();
          GlStateManager.enableBlend();
          GlStateManager.disableTexture2D();
          GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
          GL11.glColor4f(red, green, blue, alpha);
          GL11.glLineWidth(width);
          GL11.glBegin(GL11.GL_LINE_LOOP);
          for (int i = 0; i <= 360; ++i) {
              GL11.glVertex2d(x + Math.sin((double) i * 3.141526 / 180.0) * (double) radius, y + Math.cos((double) i * 3.141526 / 180.0) * (double) radius);
          }
          GL11.glEnd();
          GlStateManager.resetColor();
          GlStateManager.enableTexture2D();
          GlStateManager.disableBlend();
          GlStateManager.popMatrix();
      }
  
      public static void drawCircle(float x, float y, float radius, int color) {
          float alpha = (float) (color >> 24 & 255) / 255.0F;
          float red = (float) (color >> 16 & 255) / 255.0F;
          float green = (float) (color >> 8 & 255) / 255.0F;
          float blue = (float) (color & 255) / 255.0F;
          GlStateManager.pushMatrix();
          GlStateManager.enableBlend();
          GlStateManager.disableTexture2D();
          GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
          GL11.glColor4f(red, green, blue, alpha);
          GL11.glBegin(GL11.GL_POLYGON);
          for (int i = 0; i <= 360; ++i) {
              GL11.glVertex2d(x + Math.sin((double) i * 3.141526 / 180.0) * (double) radius, y + Math.cos((double) i * 3.141526 / 180.0) * (double) radius);
          }
          GL11.glEnd();
          GlStateManager.resetColor();
          GlStateManager.enableTexture2D();
          GlStateManager.disableBlend();
          GlStateManager.popMatrix();
      }
  
      public static void drawBorderedRect(float x, float y, float x2, float y2, float lineSize, int color, int borderColor) {
          drawRect(x, y, x2, y2, color);
          drawRect(x, y, x + lineSize, y2, borderColor);
          drawRect(x2 - lineSize, y, x2, y2, borderColor);
          drawRect(x, y2 - lineSize, x2, y2, borderColor);
          drawRect(x, y, x2, y + lineSize, borderColor);
      }
  
      public static void drawTexturedRect(int x, int y, int textureX, int textureY, int width, int height, int zLevel) {
          Tessellator tessellator = Tessellator.getInstance();
          BufferBuilder BufferBuilder = tessellator.getBuffer();
          BufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
          BufferBuilder.pos(x, y + height, zLevel).tex((float) (textureX) * 0.00390625F, (float) (textureY + height) * 0.00390625F).endVertex();
          BufferBuilder.pos(x + width, y + height, zLevel).tex((float) (textureX + width) * 0.00390625F, (float) (textureY + height) * 0.00390625F).endVertex();
          BufferBuilder.pos(x + width, y, zLevel).tex((float) (textureX + width) * 0.00390625F, (float) (textureY) * 0.00390625F).endVertex();
          BufferBuilder.pos(x, y, zLevel).tex((float) (textureX) * 0.00390625F, (float) (textureY) * 0.00390625F).endVertex();
          tessellator.draw();
      }
  
      public static void drawCompleteImage(float posX, float posY, float width, float height) {
          GL11.glPushMatrix();
          GL11.glTranslatef(posX, posY, 0.0F);
          GL11.glBegin(7);
          GL11.glTexCoord2f(0.0F, 0.0F);
          GL11.glVertex3f(0.0F, 0.0F, 0.0F);
          GL11.glTexCoord2f(0.0F, 1.0F);
          GL11.glVertex3f(0.0F, height, 0.0F);
          GL11.glTexCoord2f(1.0F, 1.0F);
          GL11.glVertex3f(width, height, 0.0F);
          GL11.glTexCoord2f(1.0F, 0.0F);
          GL11.glVertex3f(width, 0.0F, 0.0F);
          GL11.glEnd();
          GL11.glPopMatrix();
      }
  
      public static void drawCheckMark(float x, float y, int width, int color) {
          float f = (color >> 24 & 255) / 255.0f;
          float f1 = (color >> 16 & 255) / 255.0f;
          float f2 = (color >> 8 & 255) / 255.0f;
          float f3 = (color & 255) / 255.0f;
          GL11.glPushMatrix();
          GL11.glEnable(GL11.GL_BLEND);
          GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
          GL11.glDisable(3553);
          GL11.glEnable(2848);
          GL11.glBlendFunc(770, 771);
          GL11.glLineWidth(3f);
          GL11.glBegin(3);
          GL11.glColor4f(0, 0, 0, 1.f);
          GL11.glVertex2d(x + width - 6.25, y + 2.75f);
          GL11.glVertex2d(x + width - 11.5, y + 10.25f);
          GL11.glVertex2d(x + width - 13.75f, y + 7.75f);
          GL11.glEnd();
          GL11.glLineWidth(1.5f);
          GL11.glBegin(3);
          GL11.glColor4f(f1, f2, f3, f);
          GL11.glVertex2d(x + width - 6.5, y + 3);
          GL11.glVertex2d(x + width - 11.5, y + 10);
          GL11.glVertex2d(x + width - 13.5, y + 8);
          GL11.glEnd();
          GL11.glEnable(3553);
          GL11.glDisable(GL11.GL_BLEND);
          GL11.glPopMatrix();
          GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      }
  
      public static void drawLine(float x, float y, float x1, float y1, float lineWidth, int color) {
          float alpha = (float) (color >> 24 & 255) / 255.0F;
          float red = (float) (color >> 16 & 255) / 255.0F;
          float green = (float) (color >> 8 & 255) / 255.0F;
          float blue = (float) (color & 255) / 255.0F;
          GlStateManager.pushMatrix();
          GlStateManager.enableBlend();
          GlStateManager.disableTexture2D();
          GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
          GlStateManager.glLineWidth(lineWidth);
          GL11.glColor4f(red, green, blue, alpha);
          GL11.glBegin(GL11.GL_LINES);
          GL11.glVertex2f(x, y);
          GL11.glVertex2f(x1, y1);
          GL11.glEnd();
          GlStateManager.resetColor();
          GlStateManager.enableTexture2D();
          GlStateManager.disableBlend();
          GlStateManager.popMatrix();
      }
  
      public static void drawCheckeredBackground(float x, float y, float x2, float y2) {
          drawRect(x, y, x2, y2, 0xFFFFFFFF);
  
          for (boolean offset = false; y < y2; y++) {
              for (float x1 = x + ((offset = !offset) ? 1 : 0); x1 < x2; x1 += 2) {
                  if (x1 > x2 - 1)
                      continue;
                  drawRect(x1, y, x1 + 1, y + 1, 0xFF808080);
              }
          }
      }
  
      public static void drawGradientRect(float left, float top, float right, float bottom, boolean sideways, int startColor, int endColor) {
          float f = (float) (startColor >> 24 & 255) / 255.0F;
          float f1 = (float) (startColor >> 16 & 255) / 255.0F;
          float f2 = (float) (startColor >> 8 & 255) / 255.0F;
          float f3 = (float) (startColor & 255) / 255.0F;
          float f4 = (float) (endColor >> 24 & 255) / 255.0F;
          float f5 = (float) (endColor >> 16 & 255) / 255.0F;
          float f6 = (float) (endColor >> 8 & 255) / 255.0F;
          float f7 = (float) (endColor & 255) / 255.0F;
          GlStateManager.disableTexture2D();
          GlStateManager.enableBlend();
          GlStateManager.disableAlpha();
          GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
          GlStateManager.shadeModel(7425);
          Tessellator tessellator = Tessellator.getInstance();
          BufferBuilder bufferbuilder = tessellator.getBuffer();
          bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
          if (sideways) {
              bufferbuilder.pos(left, top, zLevel).color(f1, f2, f3, f).endVertex();
              bufferbuilder.pos(left, bottom, zLevel).color(f1, f2, f3, f).endVertex();
              bufferbuilder.pos(right, bottom, zLevel).color(f5, f6, f7, f4).endVertex();
              bufferbuilder.pos(right, top, zLevel).color(f5, f6, f7, f4).endVertex();
          } else {
              bufferbuilder.pos(right, top, zLevel).color(f1, f2, f3, f).endVertex();
              bufferbuilder.pos(left, top, zLevel).color(f1, f2, f3, f).endVertex();
              bufferbuilder.pos(left, bottom, zLevel).color(f5, f6, f7, f4).endVertex();
              bufferbuilder.pos(right, bottom, zLevel).color(f5, f6, f7, f4).endVertex();
          }
          tessellator.draw();
          GlStateManager.shadeModel(7424);
          GlStateManager.disableBlend();
          GlStateManager.enableAlpha();
          GlStateManager.enableTexture2D();
      }
  
      public static void blurArea(int x, int y, int width, int height, float intensity, float blurWidth, float blurHeight) {
          ScaledResolution scale = new ScaledResolution(Minecraft.getMinecraft());
          int factor = scale.getScaleFactor();
          int factor2 = scale.getScaledWidth();
          int factor3 = scale.getScaledHeight();
          if (lastScale != factor || lastScaleWidth != factor2 || lastScaleHeight != factor3 || buffer == null
                  || blurShader == null) {
              initFboAndShader();
          }
          lastScale = factor;
          lastScaleWidth = factor2;
          lastScaleHeight = factor3;
  
          if (OpenGlHelper.isFramebufferEnabled()) {
  
              if (timer.passed(1000)) {
                  buffer.framebufferClear();
                  timer.reset();
              }
  
              GL11.glScissor(x * factor, (mc.displayHeight - (y * factor) - height * factor), width * factor,
                      (height) * factor);
              GL11.glEnable(GL11.GL_SCISSOR_TEST);
              setShaderConfigs(intensity, blurWidth, blurHeight);
              buffer.bindFramebuffer(true);
              blurShader.render(mc.getRenderPartialTicks());
  
              mc.getFramebuffer().bindFramebuffer(true);
  
              GL11.glDisable(GL11.GL_SCISSOR_TEST);
  
              GlStateManager.enableBlend();
              GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO,
                      GL11.GL_ONE);
              buffer.framebufferRenderExt(mc.displayWidth, mc.displayHeight, false);
              GlStateManager.disableBlend();
              GL11.glScalef(factor, factor, 0);
  
          }
      }
  
      public static float[] getOnScreen2DHitBox(Entity e, int width, int height) {
          float x = -1;
          float y = -1;
          float w = width + 1;
          float h = height + 1;
  
          final Vec3d pos = Interpolation.interpolateEntity(e);
  
          AxisAlignedBB bb = e.getEntityBoundingBox();
  
          if (e instanceof EntityEnderCrystal) {
              bb = new AxisAlignedBB(bb.minX + 0.3f, bb.minY + 0.2f, bb.minZ + 0.3f, bb.maxX - 0.3f, bb.maxY, bb.maxZ - 0.3f);
          }
  
          if (e instanceof EntityItem) {
              bb = new AxisAlignedBB(bb.minX, bb.minY + 0.7f, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
          }
  
          bb = bb.expand(0.15f, 0.1f, 0.15f);
  
          final Vec3d[] corners = {
                  new Vec3d(bb.minX - bb.maxX + e.width / 2, 0, bb.minZ - bb.maxZ + e.width / 2),
                  new Vec3d(bb.maxX - bb.minX - e.width / 2, 0, bb.minZ - bb.maxZ + e.width / 2),
                  new Vec3d(bb.minX - bb.maxX + e.width / 2, 0, bb.maxZ - bb.minZ - e.width / 2),
                  new Vec3d(bb.maxX - bb.minX - e.width / 2, 0, bb.maxZ - bb.minZ - e.width / 2),
  
                  new Vec3d(bb.minX - bb.maxX + e.width / 2, bb.maxY - bb.minY, bb.minZ - bb.maxZ + e.width / 2),
                  new Vec3d(bb.maxX - bb.minX - e.width / 2, bb.maxY - bb.minY, bb.minZ - bb.maxZ + e.width / 2),
                  new Vec3d(bb.minX - bb.maxX + e.width / 2, bb.maxY - bb.minY, bb.maxZ - bb.minZ - e.width / 2),
                  new Vec3d(bb.maxX - bb.minX - e.width / 2, bb.maxY - bb.minY, bb.maxZ - bb.minZ - e.width / 2)
          };
  
          for (Vec3d vec : corners) {
              final GLUProjection.Projection projection = GLUProjection.getInstance().project(pos.x + vec.x /*- Minecraft.getMinecraft().getRenderManager().viewerPosX*/, pos.y + vec.y /*- Minecraft.getMinecraft().getRenderManager().viewerPosY*/, pos.z + vec.z /*- Minecraft.getMinecraft().getRenderManager().viewerPosZ*/, GLUProjection.ClampMode.ORTHOGONAL, true);
  
              x = Math.max(x, (float) projection.getX());
              y = Math.max(y, (float) projection.getY());
  
              w = Math.min(w, (float) projection.getX());
              h = Math.min(h, (float) projection.getY());
          }
  
          if (x != -1 && y != -1 && w != width + 1 && h != height + 1) {
              return new float[]{x, y, w, h};
          }
  
          return null;
      }
  
      public static float[] getHitBoxCenter(Entity entity, int width, int height) {
          float[] hitbox = getOnScreen2DHitBox(entity, width, height);
          if (hitbox != null) {
              float midX = hitbox[2] + (hitbox[0] - hitbox[2]) / 2;
              float midY = hitbox[3] + (hitbox[1] - hitbox[3]) / 2;
              return new float[]{midX, midY};
          }
          return null;
      }
  
      public static void drawOutlineRect(float x, float y, float w, float h, float lineWidth, int c) {
          drawRect(x, y, x - lineWidth, h, c);
          drawRect(w + lineWidth, y, w, h, c);
          drawRect(x, y, w, y - lineWidth, c);
          drawRect(x, h + lineWidth, w, h, c);
      }
  
      public static void drawPlayerFace(NetworkPlayerInfo info, int x, int y, int width, int height) {
          GlStateManager.pushAttrib();
          GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
          GlStateManager.enableAlpha();
          GlStateManager.enableBlend();
          GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
  
          EntityPlayer entityplayer = mc.world.getPlayerEntityByUUID(info.getGameProfile().getId());
          mc.getTextureManager().bindTexture(info.getLocationSkin());
  
          Gui.drawScaledCustomSizeModalRect(x, y, 8.0F, 8, 8, 8, width, height, 64.0F, 64.0F);
  
          if (entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.HAT)) {
              Gui.drawScaledCustomSizeModalRect(x, y, 40.0F, 8, 8, 8, 8, 8, 64.0F, 64.0F);
          }
          GlStateManager.popAttrib();
      }
  
      public static void drawFramebuffer(TextureFramebuffer framebuffer, int width, int height, boolean blend) {
          if (OpenGlHelper.isFramebufferEnabled()) {
              GlStateManager.colorMask(true, true, true, false);
              GlStateManager.disableDepth();
              GlStateManager.depthMask(false);
              GlStateManager.matrixMode(5889);
              GlStateManager.loadIdentity();
              GlStateManager.ortho(0.0D, width, height, 0.0D, 1000.0D, 3000.0D);
              GlStateManager.matrixMode(5888);
              GlStateManager.loadIdentity();
              GlStateManager.translate(0.0F, 0.0F, -2000.0F);
              GlStateManager.viewport(0, 0, width, height);
              GlStateManager.enableTexture2D();
              GlStateManager.disableLighting();
              GlStateManager.disableAlpha();
  
              if (blend) {
                  GlStateManager.disableBlend();
                  GlStateManager.enableColorMaterial();
              }
  
              GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
              GlStateManager.bindTexture(framebuffer.getTexture());
              // bindFramebufferTexture();
              float f = (float) width;
              float f1 = (float) height;
              float f2 = 1;
              float f3 = 1;
              Tessellator tessellator = Tessellator.getInstance();
              BufferBuilder bufferbuilder = tessellator.getBuffer();
              bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
              bufferbuilder.pos(0.0D, f1, 0.0D).tex(0.0D, 0.0D).color(255, 255, 255, 255).endVertex();
              bufferbuilder.pos(f, f1, 0.0D).tex(f2, 0.0D).color(255, 255, 255, 255).endVertex();
              bufferbuilder.pos(f, 0.0D, 0.0D).tex(f2, f3).color(255, 255, 255, 255).endVertex();
              bufferbuilder.pos(0.0D, 0.0D, 0.0D).tex(0.0D, f3).color(255, 255, 255, 255).endVertex();
              tessellator.draw();
              GlStateManager.bindTexture(0);
              // this.unbindFramebufferTexture();
              GlStateManager.depthMask(true);
              GlStateManager.colorMask(true, true, true, true);
          }
      }
  
  }
  