use of net.minecraft.client.render.BufferBuilder in project RPG-Hud by KurodaAkira.
the class HudElement method drawTetragon.
/**
* Draws a tetragon on the screen
*
* @param posX1
* x position of the upper left corner
* @param posX2
* x position of the lower left corner
* @param posY1
* y position of the upper left corner
* @param posY2
* y position of the lower left corner
* @param width1
* width of the top edge
* @param width2
* width of the bottom edge
* @param height1
* height of the left edge
* @param height2
* height of the right edge
* @param color
* color of the tetragon (hexa format 0xAARRGGBB)
*/
public void drawTetragon(int posX1, int posX2, int posY1, int posY2, int width1, int width2, int height1, int height2, int color) {
if (color == -1)
return;
if (width1 < 0)
width1 = 0;
if (width2 < 0)
width2 = 0;
float f3;
if (color <= 0xFFFFFF && color >= 0)
f3 = 1.0F;
else
f3 = (color >> 24 & 255) / 255.0F;
float f = (color >> 16 & 255) / 255.0F;
float f1 = (color >> 8 & 255) / 255.0F;
float f2 = (color & 255) / 255.0F;
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.disableDepthTest();
BufferBuilder vertexbuffer = Tessellator.getInstance().getBuffer();
vertexbuffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
vertexbuffer.vertex(posX1, (double) posY1 + height1, 0.0D).color(f, f1, f2, f3).next();
vertexbuffer.vertex((double) posX2 + width2, (double) posY2 + height2, 0.0D).color(f, f1, f2, f3).next();
vertexbuffer.vertex((double) posX1 + width1, posY2, 0.0D).color(f, f1, f2, f3).next();
vertexbuffer.vertex(posX2, posY1, 0.0D).color(f, f1, f2, f3).next();
vertexbuffer.end();
BufferRenderer.draw(vertexbuffer);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
RenderSystem.enableDepthTest();
}
Aggregations