Search in sources :

Example 21 with Tessellator

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

the class RenderUtils method drawFaceOutline.

public static void drawFaceOutline(BlockPos blockPos, QuadColor color, int width, Direction face) {
    Box box = new Box(blockPos);
    if (!getFrustum().isVisible(box)) {
        return;
    }
    setup3DRender(true);
    MatrixStack matrices = matrixFrom(box.minX, box.minY, box.minZ);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    // Outline
    RenderSystem.disableCull();
    RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
    RenderSystem.lineWidth(width);
    buffer.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
    Vertexer.vertexBoxLinesFace(matrices, buffer, Boxes.moveToZero(box), color, face);
    tessellator.draw();
    RenderSystem.enableCull();
    end3DRender();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) MatrixStack(net.minecraft.client.util.math.MatrixStack) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer) Box(net.minecraft.util.math.Box)

Example 22 with Tessellator

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

the class NahrFont method drawTexturedModalRect.

private final void drawTexturedModalRect(MatrixStack matrixStack, float x, float y, float u, float v, float width, float height, int color) {
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    float scale = 0.0039063F;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    float f = (color >> 24 & 0xFF) / 255.0F;
    float f1 = (color >> 16 & 0xFF) / 255.0F;
    float f2 = (color >> 8 & 0xFF) / 255.0F;
    float f3 = (color & 0xFF) / 255.0F;
    bufferBuilder.vertex(matrix4f, x + 0.0F, y + height, 0.0f).texture((u + 0.0F) * scale, (v + height) * scale).color(f1, f2, f3, f).next();
    bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0f).texture((u + width) * scale, (v + height) * scale).color(f1, f2, f3, f).next();
    bufferBuilder.vertex(matrix4f, x + width, y + 0.0F, 0.0f).texture((u + width) * scale, (v + 0.0F) * scale).color(f1, f2, f3, f).next();
    bufferBuilder.vertex(matrix4f, x + 0.0F, y + 0.0F, 0.0f).texture((u + 0.0F) * scale, (v + 0.0F) * scale).color(f1, f2, f3, f).next();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 23 with Tessellator

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

the class TextBox method drawSelectionHighlight.

private void drawSelectionHighlight(int x1, int y1, int x2, int y2) {
    int j;
    if (x1 < x2) {
        j = x1;
        x1 = x2;
        x2 = j;
    }
    if (y1 < y2) {
        j = y1;
        y1 = y2;
        y2 = j;
    }
    if (x2 > this.x + this.width) {
        x2 = this.x + this.width;
    }
    if (x1 > this.x + this.width) {
        x1 = this.x + this.width;
    }
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    RenderSystem.setShader(GameRenderer::getPositionShader);
    RenderSystem.setShaderColor(0.0F, 0.0F, 1.0F, 1.0F);
    RenderSystem.disableTexture();
    RenderSystem.enableColorLogicOp();
    RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
    bufferBuilder.vertex((double) x1, (double) y2, 0.0D).next();
    bufferBuilder.vertex((double) x2, (double) y2, 0.0D).next();
    bufferBuilder.vertex((double) x2, (double) y1, 0.0D).next();
    bufferBuilder.vertex((double) x1, (double) y1, 0.0D).next();
    tessellator.draw();
    RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
    RenderSystem.disableColorLogicOp();
    RenderSystem.enableTexture();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 24 with Tessellator

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

the class MyRenderHelper method renderScreenTriangle.

static void renderScreenTriangle() {
    GlStateManager.matrixMode(GL_MODELVIEW);
    GlStateManager.pushMatrix();
    GlStateManager.loadIdentity();
    GlStateManager.matrixMode(GL_PROJECTION);
    GlStateManager.pushMatrix();
    GlStateManager.loadIdentity();
    GlStateManager.disableAlphaTest();
    GlStateManager.disableTexture();
    GlStateManager.shadeModel(GL_SMOOTH);
    GL20.glUseProgram(0);
    GL11.glDisable(GL_CLIP_PLANE0);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBufferBuilder();
    bufferbuilder.begin(GL_TRIANGLES, VertexFormats.POSITION_COLOR);
    bufferbuilder.vertex(1, -1, 0).color(255, 255, 255, 255).next();
    bufferbuilder.vertex(1, 1, 0).color(255, 255, 255, 255).next();
    bufferbuilder.vertex(-1, 1, 0).color(255, 255, 255, 255).next();
    bufferbuilder.vertex(-1, 1, 0).color(255, 255, 255, 255).next();
    bufferbuilder.vertex(-1, -1, 0).color(255, 255, 255, 255).next();
    bufferbuilder.vertex(1, -1, 0).color(255, 255, 255, 255).next();
    tessellator.draw();
    GlStateManager.matrixMode(GL_MODELVIEW);
    GlStateManager.popMatrix();
    GlStateManager.matrixMode(GL_PROJECTION);
    GlStateManager.popMatrix();
    GlStateManager.enableAlphaTest();
    GlStateManager.enableTexture();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 25 with Tessellator

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

the class ViewAreaRenderer method drawPortalViewTriangle.

public static void drawPortalViewTriangle(Portal portal) {
    MinecraftClient.getInstance().getProfiler().push("render_view_triangle");
    DimensionRenderHelper helper = CGlobal.clientWorldLoader.getDimensionRenderHelper(portal.dimensionTo);
    Vec3d fogColor = helper.getFogColor();
    // important
    GlStateManager.enableCull();
    // In OpenGL, if you forget to set one rendering state and the result will be abnormal
    // this design is bug-prone (DirectX is better in this aspect)
    GuiLighting.disable();
    GlStateManager.color4f(1, 1, 1, 1);
    GlStateManager.disableFog();
    GlStateManager.disableAlphaTest();
    GlStateManager.disableTexture();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.disableBlend();
    GlStateManager.disableLighting();
    GL11.glDisable(GL_CLIP_PLANE0);
    if (OFInterface.isShaders.getAsBoolean()) {
        fogColor = Vec3d.ZERO;
    }
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBufferBuilder();
    buildPortalViewAreaTrianglesBuffer(fogColor, portal, bufferbuilder, PortalRenderer.mc.gameRenderer.getCamera().getPos(), MyRenderHelper.partialTicks, portal instanceof Mirror ? 0 : 0.45F);
    tessellator.draw();
    GlStateManager.enableCull();
    GlStateManager.enableAlphaTest();
    GlStateManager.enableTexture();
    GlStateManager.enableLighting();
    MinecraftClient.getInstance().getProfiler().pop();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) Mirror(com.qouteall.immersive_portals.portal.Mirror) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

Tessellator (net.minecraft.client.render.Tessellator)45 BufferBuilder (net.minecraft.client.render.BufferBuilder)41 GameRenderer (net.minecraft.client.render.GameRenderer)29 MatrixStack (net.minecraft.client.util.math.MatrixStack)12 Color (java.awt.Color)4 Inject (org.spongepowered.asm.mixin.injection.Inject)4 Matrix4f (net.minecraft.util.math.Matrix4f)3 Framebuffer (net.minecraft.client.gl.Framebuffer)2 Shader (net.minecraft.client.render.Shader)2 Box (net.minecraft.util.math.Box)2 Vec3d (net.minecraft.util.math.Vec3d)2 Mirror (com.qouteall.immersive_portals.portal.Mirror)1 Random (java.util.Random)1 BlockBase (net.minecraft.block.BlockBase)1 TextRenderer (net.minecraft.client.font.TextRenderer)1 VertexBuffer (net.minecraft.client.gl.VertexBuffer)1 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)1 NbtCompound (net.minecraft.nbt.NbtCompound)1 StationTessellator (net.modificationstation.stationapi.api.client.render.StationTessellator)1