SHARE
TWEET

GLUtils.java

TNT_Block Nov 15th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import net.minecraft.client.renderer.GlStateManager;
  2. import net.minecraft.client.renderer.Tessellator;
  3. import net.minecraft.client.renderer.VertexBuffer;
  4. import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
  5. import org.lwjgl.opengl.GL11;
  6.  
  7. public class GLUtils {
  8.  
  9.     public static void glColor(int color) {
  10.  
  11.         GlStateManager.color((float) (color >> 16 & 255) / 255F, (float) (color >> 8 & 255) / 255F, (float) (color & 255) / 255F, (float) (color >> 24 & 255) / 255F);
  12.     }
  13.  
  14.     public static void drawRect(float x, float y, float width, float height) {
  15.  
  16.         Tessellator tessellator = Tessellator.getInstance();
  17.         VertexBuffer vertexbuffer = tessellator.getBuffer();
  18.         GlStateManager.enableBlend();
  19.         GlStateManager.disableTexture2D();
  20.         GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
  21.         vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
  22.         vertexbuffer.pos(x, height, 0.0D).endVertex();
  23.         vertexbuffer.pos(width, height, 0.0D).endVertex();
  24.         vertexbuffer.pos(width, y, 0.0D).endVertex();
  25.         vertexbuffer.pos(x, y, 0.0D).endVertex();
  26.         tessellator.draw();
  27.         GlStateManager.enableTexture2D();
  28.         GlStateManager.disableBlend();
  29.     }
  30.  
  31.  
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top