Search in sources :

Example 16 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project KiwiClient by TangyKiwi.

the class ColorUtil method fillGradient.

public static void fillGradient(MatrixStack matrixStack, int xStart, int yStart, int xEnd, int yEnd, int colorStart, int colorEnd) {
    RenderSystem.disableTexture();
    RenderSystem.enableBlend();
    // RenderSystem.disableAlphaTest();
    RenderSystem.defaultBlendFunc();
    // RenderSystem.shadeModel(7425);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
    float f = (float) (colorStart >> 24 & 255) / 255.0F;
    float g = (float) (colorStart >> 16 & 255) / 255.0F;
    float h = (float) (colorStart >> 8 & 255) / 255.0F;
    float i = (float) (colorStart & 255) / 255.0F;
    float j = (float) (colorEnd >> 24 & 255) / 255.0F;
    float k = (float) (colorEnd >> 16 & 255) / 255.0F;
    float l = (float) (colorEnd >> 8 & 255) / 255.0F;
    float m = (float) (colorEnd & 255) / 255.0F;
    bufferBuilder.vertex(matrixStack.peek().getPositionMatrix(), (float) xEnd, (float) yStart, (float) 0).color(g, h, i, f).next();
    bufferBuilder.vertex(matrixStack.peek().getPositionMatrix(), (float) xStart, (float) yStart, (float) 0).color(g, h, i, f).next();
    bufferBuilder.vertex(matrixStack.peek().getPositionMatrix(), (float) xStart, (float) yEnd, (float) 0).color(k, l, m, j).next();
    bufferBuilder.vertex(matrixStack.peek().getPositionMatrix(), (float) xEnd, (float) yEnd, (float) 0).color(k, l, m, j).next();
    tessellator.draw();
    // RenderSystem.shadeModel(7424);
    RenderSystem.disableBlend();
    // RenderSystem.enableAlphaTest();
    RenderSystem.enableTexture();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 17 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project ImmersivePortalsMod by qouteall.

the class MyRenderHelper method myDrawFrameBuffer.

/**
 * {@link GlFramebuffer#draw(int, int)}
 */
public static void myDrawFrameBuffer(GlFramebuffer textureProvider, boolean doEnableAlphaTest, boolean doEnableModifyAlpha) {
    Helper.checkGlError();
    Validate.isTrue(GLX.isUsingFBOs());
    if (doEnableModifyAlpha) {
        GlStateManager.colorMask(true, true, true, true);
    } else {
        GlStateManager.colorMask(true, true, true, false);
    }
    GlStateManager.disableDepthTest();
    GlStateManager.depthMask(false);
    GlStateManager.matrixMode(5889);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0.0D, (double) textureProvider.viewWidth, (double) textureProvider.viewHeight, 0.0D, 1000.0D, 3000.0D);
    GlStateManager.matrixMode(5888);
    GlStateManager.loadIdentity();
    GlStateManager.translatef(0.0F, 0.0F, -2000.0F);
    GlStateManager.viewport(0, 0, textureProvider.viewWidth, textureProvider.viewHeight);
    GlStateManager.enableTexture();
    GlStateManager.disableLighting();
    if (doEnableAlphaTest) {
        GlStateManager.enableAlphaTest();
    } else {
        GlStateManager.disableAlphaTest();
    }
    GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    textureProvider.beginRead();
    float float_1 = (float) textureProvider.viewWidth;
    float float_2 = (float) textureProvider.viewHeight;
    float float_3 = (float) textureProvider.viewWidth / (float) textureProvider.texWidth;
    float float_4 = (float) textureProvider.viewHeight / (float) textureProvider.texHeight;
    Tessellator tessellator_1 = Tessellator.getInstance();
    BufferBuilder bufferBuilder_1 = tessellator_1.getBufferBuilder();
    bufferBuilder_1.begin(7, VertexFormats.POSITION_UV_COLOR);
    bufferBuilder_1.vertex(0.0D, (double) float_2, 0.0D).texture(0.0D, 0.0D).color(255, 255, 255, 255).next();
    bufferBuilder_1.vertex((double) float_1, (double) float_2, 0.0D).texture((double) float_3, 0.0D).color(255, 255, 255, 255).next();
    bufferBuilder_1.vertex((double) float_1, 0.0D, 0.0D).texture((double) float_3, (double) float_4).color(255, 255, 255, 255).next();
    bufferBuilder_1.vertex(0.0D, 0.0D, 0.0D).texture(0.0D, (double) float_4).color(255, 255, 255, 255).next();
    tessellator_1.draw();
    textureProvider.endRead();
    GlStateManager.depthMask(true);
    GlStateManager.colorMask(true, true, true, true);
    Helper.checkGlError();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 18 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawFilledBox.

public static void drawFilledBox(MatrixStack matrixStack, Box bb, int color, boolean draw) {
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    Color color1 = ColorUtils.getColor(color);
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    if (draw)
        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, /*QUADS*/
        VertexFormats.POSITION_COLOR);
    float minX = (float) bb.minX;
    float minY = (float) bb.minY;
    float minZ = (float) bb.minZ;
    float maxX = (float) bb.maxX;
    float maxY = (float) bb.maxY;
    float maxZ = (float) bb.maxZ;
    bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    if (draw) {
        bufferBuilder.end();
        BufferRenderer.draw(bufferBuilder);
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 19 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method fill.

public static void fill(MatrixStack matrixStack, double x1, double y1, double x2, double y2, int color) {
    Matrix4f matrix = matrixStack.peek().getPositionMatrix();
    double 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.enableBlend();
    RenderSystem.disableTexture();
    RenderSystem.defaultBlendFunc();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, 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();
    RenderSystem.disableBlend();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 20 with BufferBuilder

use of net.minecraft.client.render.BufferBuilder in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method renderOutline.

// you can call renderOutlineIntern multiple times to save performance
public static void renderOutline(Vec3d start, Vec3d dimensions, Color color, MatrixStack stack) {
    RenderSystem.defaultBlendFunc();
    RenderSystem.enableBlend();
    BufferBuilder buffer = renderPrepare(color);
    renderOutlineIntern(start, dimensions, stack, buffer);
    buffer.end();
    BufferRenderer.draw(buffer);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    RenderSystem.disableBlend();
}
Also used : BufferBuilder(net.minecraft.client.render.BufferBuilder)

Aggregations

BufferBuilder (net.minecraft.client.render.BufferBuilder)76 GameRenderer (net.minecraft.client.render.GameRenderer)46 Tessellator (net.minecraft.client.render.Tessellator)44 Matrix4f (net.minecraft.util.math.Matrix4f)18 MatrixStack (net.minecraft.client.util.math.MatrixStack)14 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)9 Color (java.awt.Color)9 RenderLayer (net.minecraft.client.render.RenderLayer)5 Vec3d (net.minecraft.util.math.Vec3d)5 BlockState (net.minecraft.block.BlockState)4 BlockEntity (net.minecraft.block.entity.BlockEntity)4 ChunkOcclusionDataBuilder (net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder)4 FluidState (net.minecraft.fluid.FluidState)4 BlockPos (net.minecraft.util.math.BlockPos)4 Random (java.util.Random)3 BlockRenderManager (net.minecraft.client.render.block.BlockRenderManager)3 ChunkRendererRegion (net.minecraft.client.render.chunk.ChunkRendererRegion)3 Inject (org.spongepowered.asm.mixin.injection.Inject)3 Mirror (com.qouteall.immersive_portals.portal.Mirror)2 HashSet (java.util.HashSet)2