net.minecraft.client.render.Tessellator Java Examples

The following examples show how to use net.minecraft.client.render.Tessellator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HallowedLoadingScreen.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public void renderDirtBackground(int i) {
	// Copied mostly from renderDirtBackground()
	RenderSystem.disableLighting();
	RenderSystem.disableFog();
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder builder = tessellator.getBuffer();
	minecraft.getTextureManager().bindTexture(backgroundTexture);
	int brightness = 130;
	RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
	builder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
	builder.vertex(0, height, 0).texture(0, height / 32.0F + i).color(brightness, brightness, brightness, 255).next();
	builder.vertex(width, height, 0).texture(width / 32.0F, height / 32.0F + i).color(brightness, brightness, brightness, 255).next();
	builder.vertex(width, 0, 0).texture(width / 32.0F, i).color(brightness, brightness, brightness, 255).next();
	builder.vertex(0, 0, 0).texture(0, i).color(brightness, brightness, brightness, 255).next();
	tessellator.draw();
}
 
Example #2
Source File: RenderUtilsLiving.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static void drawText(String str, double x, double y, double z, double scale) {
	glSetup(x, y, z);
	
	GL11.glScaled(-0.025*scale, -0.025*scale, 0.025*scale);
      
	int i = mc.textRenderer.getStringWidth(str) / 2;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(7, VertexFormats.POSITION_COLOR);
    float f = mc.options.getTextBackgroundOpacity(0.25F);
    bufferbuilder.vertex(-i - 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(-i - 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    tessellator.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
      
    mc.textRenderer.draw(str, -i, 0, 553648127);
    mc.textRenderer.draw(str, -i, 0, -1);
      
    glCleanup();
}
 
Example #3
Source File: RenderUtilsLiving.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static void drawText(String str, double x, double y, double z, double scale) {
	glSetup(x, y, z);
	
	GL11.glScaled(-0.025*scale, -0.025*scale, 0.025*scale);
      
	int i = mc.textRenderer.getWidth(str) / 2;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(7, VertexFormats.POSITION_COLOR);
    float f = mc.options.getTextBackgroundOpacity(0.25F);
    bufferbuilder.vertex(-i - 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(-i - 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    tessellator.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
      
    mc.textRenderer.draw(new MatrixStack(), str, -i, 0, 553648127);
    mc.textRenderer.draw(new MatrixStack(), str, -i, 0, -1);
      
    glCleanup();
}
 
Example #4
Source File: RenderUtilsLiving.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static void drawText(String str, double x, double y, double z, double scale) {
	glSetup(x, y, z);
	
	GL11.glScaled(-0.025*scale, -0.025*scale, 0.025*scale);
      
	int i = mc.textRenderer.getStringWidth(str) / 2;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBufferBuilder();
    bufferbuilder.begin(7, VertexFormats.POSITION_COLOR);
    float f = mc.options.getTextBackgroundOpacity(0.25F);
    bufferbuilder.vertex(-i - 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(-i - 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, 8, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    bufferbuilder.vertex(i + 1, -1, 0.0D).color(0.0F, 0.0F, 0.0F, f).next();
    tessellator.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
      
    mc.textRenderer.draw(str, -i, 0, 553648127);
    mc.textRenderer.draw(str, -i, 0, -1);
      
    glCleanup();
}
 
Example #5
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
public static void drawLine(double x1,double y1,double z1,double x2,double y2,double z2, float r, float g, float b, float t) {
	gl11Setup();
	GL11.glLineWidth(t);
       
	Vec3d ren = renderPos();
       
       Tessellator tessellator = Tessellator.getInstance();
       BufferBuilder buffer = tessellator.getBufferBuilder();
       buffer.begin(3, VertexFormats.POSITION_COLOR);
       buffer.vertex(x1 - ren.x, y1 - ren.y, z1 - ren.z).color(r, g, b, 0.0F).next();
       buffer.vertex(x1 - ren.x, y1 - ren.y, z1 - ren.z).color(r, g, b, 1.0F).next();
       buffer.vertex(x2 - ren.x, y2 - ren.y, z2 - ren.z).color(r, g, b, 1.0F).next();
       tessellator.draw();
       
	gl11Cleanup();
       
}
 
Example #6
Source File: WTextField.java    From LibGui with MIT License 6 votes vote down vote up
@Environment(EnvType.CLIENT)
private void invertedRect(int x, int y, int width, int height) {
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
	RenderSystem.color4f(0.0F, 0.0F, 255.0F, 255.0F);
	RenderSystem.disableTexture();
	RenderSystem.enableColorLogicOp();
	RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
	bufferBuilder_1.begin(GL11.GL_QUADS, VertexFormats.POSITION);
	bufferBuilder_1.vertex(x,       y+height, 0.0D).next();
	bufferBuilder_1.vertex(x+width, y+height, 0.0D).next();
	bufferBuilder_1.vertex(x+width, y,        0.0D).next();
	bufferBuilder_1.vertex(x,       y,        0.0D).next();
	tessellator_1.draw();
	RenderSystem.disableColorLogicOp();
	RenderSystem.enableTexture();
}
 
Example #7
Source File: ScreenDrawing.java    From LibGui with MIT License 6 votes vote down vote up
/**
 * Draws an untextured rectangle of the specified RGB color.
 */
public static void coloredRect(int left, int top, int width, int height, int color) {
	if (width <= 0) width = 1;
	if (height <= 0) height = 1;

	float a = (color >> 24 & 255) / 255.0F;
	float r = (color >> 16 & 255) / 255.0F;
	float g = (color >> 8 & 255) / 255.0F;
	float b = (color & 255) / 255.0F;
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder buffer = tessellator.getBuffer();
	RenderSystem.enableBlend();
	RenderSystem.disableTexture();
	RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
	buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR); //I thought GL_QUADS was deprecated but okay, sure.
	buffer.vertex(left,         top + height, 0.0D).color(r, g, b, a).next();
	buffer.vertex(left + width, top + height, 0.0D).color(r, g, b, a).next();
	buffer.vertex(left + width, top,          0.0D).color(r, g, b, a).next();
	buffer.vertex(left,         top,          0.0D).color(r, g, b, a).next();
	tessellator.draw();
	RenderSystem.enableTexture();
	RenderSystem.disableBlend();
}
 
Example #8
Source File: ScreenDrawing.java    From LibGui with MIT License 6 votes vote down vote up
/**
 * Draws a textured rectangle.
 *
 * @param x         the x coordinate of the box on-screen
 * @param y         the y coordinate of the box on-screen
 * @param width     the width of the box on-screen
 * @param height    the height of the box on-screen
 * @param texture   the Identifier for the texture
 * @param u1        the left edge of the texture
 * @param v1        the top edge of the texture
 * @param u2        the right edge of the texture
 * @param v2        the bottom edge of the texture
 * @param color     a color to tint the texture. This can be transparent! Use 0xFF_FFFFFF if you don't want a color tint
 * @param opacity   opacity of the drawn texture. (0f is fully opaque and 1f is fully visible)
 * @since 2.0.0
 */
public static void texturedRect(int x, int y, int width, int height, Identifier texture, float u1, float v1, float u2, float v2, int color, float opacity) {
	MinecraftClient.getInstance().getTextureManager().bindTexture(texture);

	//float scale = 0.00390625F;

	if (width <= 0) width = 1;
	if (height <= 0) height = 1;

	float r = (color >> 16 & 255) / 255.0F;
	float g = (color >> 8 & 255) / 255.0F;
	float b = (color & 255) / 255.0F;
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder buffer = tessellator.getBuffer();
	RenderSystem.enableBlend();
	//GlStateManager.disableTexture2D();
	RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
	buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE); //I thought GL_QUADS was deprecated but okay, sure.
	buffer.vertex(x,         y + height, 0).color(r, g, b, opacity).texture(u1, v2).next();
	buffer.vertex(x + width, y + height, 0).color(r, g, b, opacity).texture(u2, v2).next();
	buffer.vertex(x + width, y,          0).color(r, g, b, opacity).texture(u2, v1).next();
	buffer.vertex(x,         y,          0).color(r, g, b, opacity).texture(u1, v1).next();
	tessellator.draw();
	//GlStateManager.enableTexture2D();
	RenderSystem.disableBlend();
}
 
Example #9
Source File: ListWidget.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
protected void renderHoleBackground(int top, int bottom, int topAlpha,
	int bottomAlpha)
{
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder bufferBuilder = tessellator.getBuffer();
	client.getTextureManager()
		.bindTexture(DrawableHelper.BACKGROUND_TEXTURE);
	RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
	bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
	bufferBuilder.vertex(left, bottom, 0.0D).texture(0.0F, bottom / 32.0F)
		.color(64, 64, 64, bottomAlpha).next();
	bufferBuilder.vertex(left + width, bottom, 0.0D)
		.texture(width / 32.0F, bottom / 32.0F)
		.color(64, 64, 64, bottomAlpha).next();
	bufferBuilder.vertex(left + width, top, 0.0D)
		.texture(width / 32.0F, top / 32.0F).color(64, 64, 64, topAlpha)
		.next();
	bufferBuilder.vertex(left, top, 0.0D).texture(0.0F, top / 32.0F)
		.color(64, 64, 64, topAlpha).next();
	tessellator.draw();
}
 
Example #10
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void renderLines(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick)
{
    if (shape.a == 0.0) return;
    Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick);
    RenderSystem.lineWidth(shape.lineWidth);
    double dir = MathHelper.sign(shape.height);
    drawCylinderWireframe(tessellator, bufferBuilder,
            (float) (vc.x - cx - dir * renderEpsilon), (float) (vc.y - cy - dir * renderEpsilon), (float) (vc.z - cz - dir * renderEpsilon),
            (float) (shape.radius + renderEpsilon), (float) (shape.height + 2*dir*renderEpsilon), shape.axis,
            shape.subdivisions, shape.radius == 0,
            shape.r, shape.g, shape.b, shape.a);

}
 
Example #11
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void renderFaces(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick)
{
    if (shape.fa == 0.0) return;
    Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick);
    RenderSystem.lineWidth(1.0f);
    drawSphereFaces(tessellator, bufferBuilder,
            (float)(vc.x-cx), (float)(vc.y-cy), (float)(vc.z-cz),
            (float)(shape.radius+renderEpsilon), shape.subdivisions,
            shape.fr, shape.fg, shape.fb, shape.fa);
}
 
Example #12
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void renderFaces(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick)
{
    if (shape.fa == 0.0) return;
    Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick);
    RenderSystem.lineWidth(1.0f);
    double dir = MathHelper.sign(shape.height);
    drawCylinderFaces(tessellator, bufferBuilder,
            (float) (vc.x - cx - dir * renderEpsilon), (float) (vc.y - cy - dir * renderEpsilon), (float) (vc.z - cz - dir * renderEpsilon),
            (float) (shape.radius + renderEpsilon), (float) (shape.height + 2*dir*renderEpsilon), shape.axis,
            shape.subdivisions, shape.radius == 0,
            shape.fr, shape.fg, shape.fb, shape.fa);
}
 
Example #13
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void renderLines(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick)
{
    if (shape.a == 0.0) return;
    Vec3d vc = shape.relativiseRender(client.world, shape.center, partialTick);
    RenderSystem.lineWidth(shape.lineWidth);
    drawSphereWireframe(tessellator, bufferBuilder,
            (float)(vc.x-cx), (float)(vc.y-cy), (float)(vc.z-cz),
            (float)(shape.radius+renderEpsilon), shape.subdivisions,
            shape.r, shape.g, shape.b, shape.a);
}
 
Example #14
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void renderLines(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick)
{
    Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick);
    Vec3d v2 = shape.relativiseRender(client.world, shape.to, partialTick);
    RenderSystem.lineWidth(shape.lineWidth);
    drawLine(tessellator, bufferBuilder,
            (float)(v1.x-cx-renderEpsilon), (float)(v1.y-cy-renderEpsilon), (float)(v1.z-cz-renderEpsilon),
            (float)(v2.x-cx+renderEpsilon), (float)(v2.y-cy+renderEpsilon), (float)(v2.z-cz+renderEpsilon),
            shape.r, shape.g, shape.b, shape.a
    );
}
 
Example #15
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void renderFaces(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick)
{
    if (shape.fa == 0.0) return;
    Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick);
    Vec3d v2 = shape.relativiseRender(client.world, shape.to, partialTick);
    RenderSystem.lineWidth(1.0F);
    drawBoxFaces(tessellator, bufferBuilder,
            (float)(v1.x-cx-renderEpsilon), (float)(v1.y-cy-renderEpsilon), (float)(v1.z-cz-renderEpsilon),
            (float)(v2.x-cx+renderEpsilon), (float)(v2.y-cy+renderEpsilon), (float)(v2.z-cz+renderEpsilon),
            v1.x!=v2.x, v1.y!=v2.y, v1.z!=v2.z,
            shape.fr, shape.fg, shape.fb, shape.fa
    );
}
 
Example #16
Source File: SpaceRaceScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
private static void fillSolid(Matrix4f matrix, int x1, int y1, int x2, int y2, int color) {
    int j;
    if (x1 < x2) {
        j = x1;
        x1 = x2;
        x2 = j;
    }

    if (y1 < y2) {
        j = y1;
        y1 = y2;
        y2 = j;
    }

    float f = (float) (color >> 24 & 255) / 255.0F;
    float g = (float) (color >> 16 & 255) / 255.0F;
    float h = (float) (color >> 8 & 255) / 255.0F;
    float k = (float) (color & 255) / 255.0F;
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    RenderSystem.disableBlend();
    RenderSystem.disableTexture();
    RenderSystem.defaultBlendFunc();
    bufferBuilder.begin(7, VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(matrix, (float) x1, (float) y2, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(g, h, k, f).next();
    bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(g, h, k, f).next();
    bufferBuilder.end();
    BufferRenderer.draw(bufferBuilder);
    RenderSystem.enableTexture();
}
 
Example #17
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Override
public void renderLines(Tessellator tessellator, BufferBuilder bufferBuilder, double cx, double cy, double cz, float partialTick)
{
    if (shape.a == 0.0) return;
    Vec3d v1 = shape.relativiseRender(client.world, shape.from, partialTick);
    Vec3d v2 = shape.relativiseRender(client.world, shape.to, partialTick);
    RenderSystem.lineWidth(shape.lineWidth);
    drawBoxWireGLLines(tessellator, bufferBuilder,
            (float)(v1.x-cx-renderEpsilon), (float)(v1.y-cy-renderEpsilon), (float)(v1.z-cz-renderEpsilon),
            (float)(v2.x-cx+renderEpsilon), (float)(v2.y-cy+renderEpsilon), (float)(v2.z-cz+renderEpsilon),
            v1.x!=v2.x, v1.y!=v2.y, v1.z!=v2.z,
            shape.r, shape.g, shape.b, shape.a, shape.r, shape.g, shape.b
    );
}
 
Example #18
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
protected void fillGradient(int x1, int y1, int x2, int y2, int color1, int color2) {
	float float_1 = (float)(color1 >> 24 & 255) / 255.0F;
	float float_2 = (float)(color1 >> 16 & 255) / 255.0F;
	float float_3 = (float)(color1 >> 8 & 255) / 255.0F;
	float float_4 = (float)(color1 & 255) / 255.0F;
	float float_5 = (float)(color2 >> 24 & 255) / 255.0F;
	float float_6 = (float)(color2 >> 16 & 255) / 255.0F;
	float float_7 = (float)(color2 >> 8 & 255) / 255.0F;
	float float_8 = (float)(color2 & 255) / 255.0F;
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_ALPHA_TEST);
	GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
	GL11.glShadeModel(7425);
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
	bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR);
	bufferBuilder_1.vertex((double)x1, (double)y1, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x1, (double)y2, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x2, (double)y2, 0).color(float_6, float_7, float_8, float_5).next();
	bufferBuilder_1.vertex((double)x2, (double)y1, 0).color(float_6, float_7, float_8, float_5).next();
	tessellator_1.draw();
	GL11.glShadeModel(7424);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_ALPHA_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example #19
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void drawSphereFaces(Tessellator tessellator, BufferBuilder builder,
                                       float cx, float cy, float cz,
                                       float r, int subd,
                                       float red, float grn, float blu, float alpha)
{

    float step = (float)Math.PI / (subd/2);
    int num_steps180 = (int)(Math.PI / step)+1;
    int num_steps360 = (int)(2*Math.PI / step);
    for (int i = 0; i <= num_steps360; i++)
    {
        float theta = i * step;
        float thetaprime = theta+step;
        builder.begin(GL11.GL_QUAD_STRIP, VertexFormats.POSITION_COLOR);
        for (int j = 0; j <= num_steps180; j++)
        {
            float phi = j * step;
            float x = r * MathHelper.sin(phi) * MathHelper.cos(theta);
            float z = r * MathHelper.sin(phi) * MathHelper.sin(theta);
            float y = r * MathHelper.cos(phi);
            float xp = r * MathHelper.sin(phi) * MathHelper.cos(thetaprime);
            float zp = r * MathHelper.sin(phi) * MathHelper.sin(thetaprime);
            builder.vertex(x + cx, y + cy, z + cz).color(red, grn, blu, alpha).next();
            builder.vertex(xp + cx, y + cy, zp + cz).color(red, grn, blu, alpha).next();
        }
        tessellator.draw();
    }
}
 
Example #20
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawLine(double x1,double y1,double z1,double x2,double y2,double z2, float r, float g, float b, float t) {
	gl11Setup();
	GL11.glLineWidth(t);
       
       Tessellator tessellator = Tessellator.getInstance();
       BufferBuilder buffer = tessellator.getBuffer();
       buffer.begin(3, VertexFormats.POSITION_COLOR);
       buffer.vertex(x1, y1, z1).color(r, g, b, 0.0F).next();
       buffer.vertex(x1, y1, z1).color(r, g, b, 1.0F).next();
       buffer.vertex(x2, y2, z2).color(r, g, b, 1.0F).next();
       tessellator.draw();
       
	gl11Cleanup();
       
}
 
Example #21
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawFilledBox(Box box, float r, float g, float b, float a) {
gl11Setup();

      // Fill
      Tessellator tessellator = Tessellator.getInstance();
      BufferBuilder buffer = tessellator.getBuffer();
      buffer.begin(5, VertexFormats.POSITION_COLOR);
      WorldRenderer.drawBox(buffer,
      		box.x1, box.y1, box.z1,
      		box.x2, box.y2, box.z2, r, g, b, a/2f);
      tessellator.draw();
      
      // Outline
      buffer.begin(3, VertexFormats.POSITION_COLOR);
      buffer.vertex(box.x1, box.y1, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y1, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y1, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y1, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y1, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y2, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y2, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y2, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y2, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y2, box.z1).color(r, b, b, a/2f).next();
      buffer.vertex(box.x1, box.y1, box.z2).color(r, b, b, 0f).next();
      buffer.vertex(box.x1, box.y2, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y1, box.z2).color(r, b, b, 0f).next();
      buffer.vertex(box.x2, box.y2, box.z2).color(r, b, b, a/2f).next();
      buffer.vertex(box.x2, box.y1, box.z1).color(r, b, b, 0f).next();
      buffer.vertex(box.x2, box.y2, box.z1).color(r, b, b, a/2f).next();
      tessellator.draw();
      
      gl11Cleanup();
  }
 
Example #22
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
protected void fillGradient(MatrixStack matrix, int x1, int y1, int x2, int y2, int color1, int color2) {
	float float_1 = (float)(color1 >> 24 & 255) / 255.0F;
	float float_2 = (float)(color1 >> 16 & 255) / 255.0F;
	float float_3 = (float)(color1 >> 8 & 255) / 255.0F;
	float float_4 = (float)(color1 & 255) / 255.0F;
	float float_5 = (float)(color2 >> 24 & 255) / 255.0F;
	float float_6 = (float)(color2 >> 16 & 255) / 255.0F;
	float float_7 = (float)(color2 >> 8 & 255) / 255.0F;
	float float_8 = (float)(color2 & 255) / 255.0F;
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_ALPHA_TEST);
	GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
	GL11.glShadeModel(7425);
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
	bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR);
	bufferBuilder_1.vertex((double)x1, (double)y1, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x1, (double)y2, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x2, (double)y2, 0).color(float_6, float_7, float_8, float_5).next();
	bufferBuilder_1.vertex((double)x2, (double)y1, 0).color(float_6, float_7, float_8, float_5).next();
	tessellator_1.draw();
	GL11.glShadeModel(7424);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_ALPHA_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example #23
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawLine(double x1,double y1,double z1,double x2,double y2,double z2, float r, float g, float b, float t) {
	gl11Setup();
	GL11.glLineWidth(t);
       
       Tessellator tessellator = Tessellator.getInstance();
       BufferBuilder buffer = tessellator.getBuffer();
       buffer.begin(3, VertexFormats.POSITION_COLOR);
       buffer.vertex(x1, y1, z1).color(r, g, b, 0.0F).next();
       buffer.vertex(x1, y1, z1).color(r, g, b, 1.0F).next();
       buffer.vertex(x2, y2, z2).color(r, g, b, 1.0F).next();
       tessellator.draw();
       
	gl11Cleanup();
       
}
 
Example #24
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawFilledBox(Box box, float r, float g, float b, float a) {
gl11Setup();

      // Fill
      Tessellator tessellator = Tessellator.getInstance();
      BufferBuilder buffer = tessellator.getBuffer();
      buffer.begin(5, VertexFormats.POSITION_COLOR);
      WorldRenderer.drawBox(buffer,
      		box.minX, box.minY, box.minZ,
      		box.maxX, box.maxY, box.maxZ, r, g, b, a/2f);
      tessellator.draw();
      
      // Outline
      buffer.begin(3, VertexFormats.POSITION_COLOR);
      buffer.vertex(box.minX, box.minY, box.minZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.minX, box.minY, box.maxZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.maxX, box.minY, box.maxZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.maxX, box.minY, box.minZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.minX, box.minY, box.minZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.minX, box.maxY, box.minZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.maxX, box.maxY, box.minZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.maxX, box.maxY, box.maxZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.minX, box.maxY, box.maxZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.minX, box.maxY, box.minZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.minX, box.minY, box.maxZ).color(r, b, b, 0f).next();
      buffer.vertex(box.minX, box.maxY, box.maxZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.maxX, box.minY, box.maxZ).color(r, b, b, 0f).next();
      buffer.vertex(box.maxX, box.maxY, box.maxZ).color(r, b, b, a/2f).next();
      buffer.vertex(box.maxX, box.minY, box.minZ).color(r, b, b, 0f).next();
      buffer.vertex(box.maxX, box.maxY, box.minZ).color(r, b, b, a/2f).next();
      tessellator.draw();
      
      gl11Cleanup();
  }
 
Example #25
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
private void fillGradient(int x1, int y1, int x2, int y2, int color1, int color2) {
	float float_1 = (float)(color1 >> 24 & 255) / 255.0F;
	float float_2 = (float)(color1 >> 16 & 255) / 255.0F;
	float float_3 = (float)(color1 >> 8 & 255) / 255.0F;
	float float_4 = (float)(color1 & 255) / 255.0F;
	float float_5 = (float)(color2 >> 24 & 255) / 255.0F;
	float float_6 = (float)(color2 >> 16 & 255) / 255.0F;
	float float_7 = (float)(color2 >> 8 & 255) / 255.0F;
	float float_8 = (float)(color2 & 255) / 255.0F;
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_ALPHA_TEST);
	GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
	GL11.glShadeModel(7425);
	Tessellator tessellator_1 = Tessellator.getInstance();
	BufferBuilder bufferBuilder_1 = tessellator_1.getBufferBuilder();
	bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR);
	bufferBuilder_1.vertex((double)x1, (double)y1, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x1, (double)y2, 0).color(float_2, float_3, float_4, float_1).next();
	bufferBuilder_1.vertex((double)x2, (double)y2, 0).color(float_6, float_7, float_8, float_5).next();
	bufferBuilder_1.vertex((double)x2, (double)y1, 0).color(float_6, float_7, float_8, float_5).next();
	tessellator_1.draw();
	GL11.glShadeModel(7424);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_ALPHA_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example #26
Source File: RenderUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawFilledBox(Box box, float r, float g, float b, float a) {
gl11Setup();

Vec3d ren = renderPos();

      /* Fill */
      Tessellator tessellator = Tessellator.getInstance();
      BufferBuilder buffer = tessellator.getBufferBuilder();
      buffer.begin(5, VertexFormats.POSITION_COLOR);
      WorldRenderer.buildBox(buffer,
      		box.minX - ren.x, box.minY - ren.y, box.minZ - ren.z,
      		box.maxX - ren.x, box.maxY - ren.y, box.maxZ - ren.z, r, g, b, a/2f);
      tessellator.draw();
      
      /* Outline */
      WorldRenderer.drawBoxOutline(new Box(
      		box.minX - ren.x, box.minY - ren.y, box.minZ - ren.z,
      		box.maxX - ren.x, box.maxY - ren.y, box.maxZ - ren.z), r, g, b, a);

      gl11Cleanup();
  }
 
Example #27
Source File: RenderUtilImpl.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void drawRepeating(int x, int y, int u, int v, int width, int height, float repeatWidth, float repeatHeight, int texWidth, int texHeight) {
    GlStateManager.disableLighting();
    GlStateManager.disableFog();
    Tessellator tessellator_1 = Tessellator.getInstance();
    BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer();
    GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    bufferBuilder_1.begin(7, VertexFormats.POSITION_COLOR_TEXTURE);
    bufferBuilder_1.vertex(x, y + height, 0.0D).color(255, 255, 255, 255).texture(u / (float) texWidth, (v + repeatHeight) / (float) texHeight).next();
    bufferBuilder_1.vertex(x + width, y + height, 0.0D).color(255, 255, 255, 255).texture((u + repeatWidth) / (float) texWidth, (float) (v + repeatHeight) / (float) texHeight).next();
    bufferBuilder_1.vertex(x + width, y, 0.0D).color(255, 255, 255, 255).texture((u + repeatWidth) / (float) texWidth, v / (float) texHeight).next();
    bufferBuilder_1.vertex(x, y, 0.0D).color(255, 255, 255, 255).texture(u / (float) texWidth, v / (float) texHeight).next();
    tessellator_1.draw();
}
 
Example #28
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 4 votes vote down vote up
public void render(Camera camera, float partialTick)
{
    IWorld iWorld = this.client.world;
    DimensionType dimensionType = iWorld.getDimension().getType();
    if (shapes.get(dimensionType) == null || shapes.get(dimensionType).isEmpty()) return;
    long currentTime = client.world.getTime();
    RenderSystem.disableTexture();
    RenderSystem.enableDepthTest();
    RenderSystem.depthFunc(515);
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    //RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO);
    //RenderSystem.shadeModel(7425);
    RenderSystem.shadeModel(GL11.GL_FLAT);
    RenderSystem.enableAlphaTest();
    RenderSystem.alphaFunc(GL11.GL_GREATER, 0.003f);
    RenderSystem.disableCull();
    RenderSystem.disableLighting();
    RenderSystem.depthMask(false);
    //RenderSystem.polygonOffset(-3f, -3f);
    //RenderSystem.enablePolygonOffset();
    //Entity entity = this.client.gameRenderer.getCamera().getFocusedEntity();

    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();

    // render
    double cameraX = camera.getPos().x;
    double cameraY = camera.getPos().y;
    double cameraZ = camera.getPos().z;

    synchronized (shapes)
    {
        shapes.get(dimensionType).long2ObjectEntrySet().removeIf(
                entry -> entry.getValue().isExpired(currentTime)
        );
        shapes.get(dimensionType).values().forEach(
                s ->
                {
                    if ( s.shouldRender(dimensionType))
                        s.renderFaces(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
                }
        );
        //lines
        shapes.get(dimensionType).values().forEach(

                s -> {
                    if ( s.shouldRender(dimensionType))
                        s.renderLines(tessellator, bufferBuilder, cameraX, cameraY, cameraZ, partialTick);
                }
        );
    }
    RenderSystem.enableCull();
    RenderSystem.depthMask(true);
    RenderSystem.lineWidth(1.0F);
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.enableTexture();
    RenderSystem.shadeModel(7424);
}
 
Example #29
Source File: ListWidget.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
protected void renderList(MatrixStack matrixStack, int i, int j, int k,
	int l, float f)
{
	int m = getItemCount();
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder bufferBuilder = tessellator.getBuffer();
	
	for(int n = 0; n < m; ++n)
	{
		int o = j + n * itemHeight + headerHeight;
		int p = itemHeight - 4;
		if(o > bottom || o + p < top)
			updateItemPosition(n, i, o, f);
		
		if(renderSelection && isSelectedItem(n))
		{
			int q = left + width / 2 - getRowWidth() / 2;
			int r = left + width / 2 + getRowWidth() / 2;
			RenderSystem.disableTexture();
			float g = isFocused() ? 1.0F : 0.5F;
			RenderSystem.color4f(g, g, g, 1.0F);
			bufferBuilder.begin(7, VertexFormats.POSITION);
			bufferBuilder.vertex(q, o + p + 2, 0.0D).next();
			bufferBuilder.vertex(r, o + p + 2, 0.0D).next();
			bufferBuilder.vertex(r, o - 2, 0.0D).next();
			bufferBuilder.vertex(q, o - 2, 0.0D).next();
			tessellator.draw();
			RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F);
			bufferBuilder.begin(7, VertexFormats.POSITION);
			bufferBuilder.vertex(q + 1, o + p + 1, 0.0D).next();
			bufferBuilder.vertex(r - 1, o + p + 1, 0.0D).next();
			bufferBuilder.vertex(r - 1, o - 1, 0.0D).next();
			bufferBuilder.vertex(q + 1, o - 1, 0.0D).next();
			tessellator.draw();
			RenderSystem.enableTexture();
		}
		
		renderItem(matrixStack, n, i, o, p, k, l, f);
	}
	
}
 
Example #30
Source File: ShapesRenderer.java    From fabric-carpet with MIT License 4 votes vote down vote up
public static void drawLine(Tessellator tessellator, BufferBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2, float red1, float grn1, float blu1, float alpha) {
    builder.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR); // 3
    builder.vertex(x1, y1, z1).color(red1, grn1, blu1, alpha).next();
    builder.vertex(x2, y2, z2).color(red1, grn1, blu1, alpha).next();
    tessellator.draw();
}