Search in sources :

Example 26 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 27 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)

Example 28 with Tessellator

use of net.minecraft.client.render.Tessellator in project BedrockIfy by juancarloscp52.

the class AbstractPackScreenMixin method renderHeaderAndBottom.

/**
 * Render top and bottom "dirt" bars when custom rotating background is enabled.
 */
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/pack/PackScreen;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", ordinal = 0))
private void renderHeaderAndBottom(CallbackInfo info) {
    if (!Bedrockify.getInstance().settings.isCubemapBackgroundEnabled())
        return;
    headerWidth = Objects.requireNonNull(client).getWindow().getScaledWidth();
    headerHeight = client.getWindow().getScaledHeight();
    headerBottom = headerHeight - 51;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.client.getTextureManager().bindTexture(DrawableHelper.BACKGROUND_TEXTURE);
    RenderSystem.enableDepthTest();
    RenderSystem.depthFunc(519);
    float tilingSize = 32.0F;
    // Top and bottom bars.
    bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
    bufferBuilder.vertex(this.headerLeft, this.headerTop, -100.0D).texture(0.0F, (float) this.headerTop / tilingSize).color(64, 64, 64, 255).next();
    bufferBuilder.vertex(this.headerLeft + this.headerWidth, this.headerTop, -100.0D).texture((float) this.headerWidth / tilingSize, (float) this.headerTop / tilingSize).color(64, 64, 64, 255).next();
    bufferBuilder.vertex(this.headerLeft + this.headerWidth, 0.0D, -100.0D).texture((float) this.headerWidth / tilingSize, 0.0F).color(64, 64, 64, 255).next();
    bufferBuilder.vertex(this.headerLeft, 0.0D, -100.0D).texture(0.0F, 0.0F).color(64, 64, 64, 255).next();
    bufferBuilder.vertex(this.headerLeft, this.headerHeight, -100.0D).texture(0.0F, (float) this.headerHeight / tilingSize).color(64, 64, 64, 255).next();
    bufferBuilder.vertex(this.headerLeft + this.headerWidth, this.headerHeight, -100.0D).texture((float) this.headerWidth / tilingSize, (float) this.headerHeight / tilingSize).color(64, 64, 64, 255).next();
    bufferBuilder.vertex(this.headerLeft + this.headerWidth, this.headerBottom, -100.0D).texture((float) this.headerWidth / tilingSize, (float) this.headerBottom / tilingSize).color(64, 64, 64, 255).next();
    bufferBuilder.vertex(this.headerLeft, this.headerBottom, -100.0D).texture(0.0F, (float) this.headerBottom / tilingSize).color(64, 64, 64, 255).next();
    tessellator.draw();
    RenderSystem.depthFunc(515);
    RenderSystem.disableDepthTest();
    RenderSystem.enableBlend();
    RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ZERO, GlStateManager.DstFactor.ONE);
    RenderSystem.disableAlphaTest();
    RenderSystem.shadeModel(7425);
    RenderSystem.disableTexture();
    // Top and bottom bar shadows.
    bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
    bufferBuilder.vertex(this.headerLeft, this.headerTop + 4, 0.0D).texture(0.0F, 1.0F).color(0, 0, 0, 0).next();
    bufferBuilder.vertex(this.headerWidth, this.headerTop + 4, 0.0D).texture(1.0F, 1.0F).color(0, 0, 0, 0).next();
    bufferBuilder.vertex(this.headerWidth, this.headerTop, 0.0D).texture(1.0F, 0.0F).color(0, 0, 0, 255).next();
    bufferBuilder.vertex(this.headerLeft, this.headerTop, 0.0D).texture(0.0F, 0.0F).color(0, 0, 0, 255).next();
    bufferBuilder.vertex(this.headerLeft, this.headerBottom, 0.0D).texture(0.0F, 1.0F).color(0, 0, 0, 255).next();
    bufferBuilder.vertex(this.headerWidth, this.headerBottom, 0.0D).texture(1.0F, 1.0F).color(0, 0, 0, 255).next();
    bufferBuilder.vertex(this.headerWidth, this.headerBottom - 4, 0.0D).texture(1.0F, 0.0F).color(0, 0, 0, 0).next();
    bufferBuilder.vertex(this.headerLeft, this.headerBottom - 4, 0.0D).texture(0.0F, 0.0F).color(0, 0, 0, 0).next();
    tessellator.draw();
    RenderSystem.enableTexture();
    RenderSystem.shadeModel(7424);
    RenderSystem.enableAlphaTest();
    RenderSystem.disableBlend();
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 29 with Tessellator

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

the class ShaderEffectWrapper method drawFramebufferToMain.

public void drawFramebufferToMain(String framebuffer) {
    Framebuffer buffer = getFramebuffer(framebuffer);
    Shader blitshader = mc.gameRenderer.blitScreenShader;
    blitshader.addSampler("DiffuseSampler", buffer.getColorAttachment());
    double w = mc.getWindow().getFramebufferWidth();
    double h = mc.getWindow().getFramebufferHeight();
    float ws = (float) buffer.viewportWidth / (float) buffer.textureWidth;
    float hs = (float) buffer.viewportHeight / (float) buffer.textureHeight;
    RenderSystem.enableBlend();
    RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ZERO, GlStateManager.DstFactor.ONE);
    GlStateManager._colorMask(true, true, true, false);
    GlStateManager._disableDepthTest();
    GlStateManager._depthMask(false);
    GlStateManager._viewport(0, 0, (int) w, (int) h);
    blitshader.bind();
    Tessellator tessellator = RenderSystem.renderThreadTesselator();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
    bufferBuilder.vertex(0, h, 0).texture(0f, 0f).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(w, h, 0).texture(ws, 0f).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(w, 0, 0).texture(ws, hs).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(0, 0, 0).texture(0f, hs).color(255, 255, 255, 255).next();
    bufferBuilder.end();
    BufferRenderer.postDraw(bufferBuilder);
    blitshader.unbind();
    GlStateManager._depthMask(true);
    GlStateManager._colorMask(true, true, true, true);
    RenderSystem.disableBlend();
}
Also used : Framebuffer(net.minecraft.client.gl.Framebuffer) Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) Shader(net.minecraft.client.render.Shader)

Example 30 with Tessellator

use of net.minecraft.client.render.Tessellator in project fabric by FabricMC.

the class ItemRenderContext method renderModel.

public void renderModel(FabricBakedModel model, int color, ItemStack stack, VanillaQuadHandler vanillaHandler) {
    this.color = color;
    if (stack.isEmpty() && enchantmentStack != null) {
        enchantment = true;
        this.itemStack = enchantmentStack;
        enchantmentStack = null;
    } else {
        enchantment = false;
        this.itemStack = stack;
    }
    this.vanillaHandler = vanillaHandler;
    Tessellator tessellator = Tessellator.getInstance();
    bufferBuilder = tessellator.getBufferBuilder();
    fabricBuffer = (AccessBufferBuilder) this.bufferBuilder;
    bufferBuilder.begin(7, VertexFormats.POSITION_COLOR_UV_NORMAL);
    model.emitItemQuads(stack, randomSupplier, this);
    tessellator.draw();
    if (smoothShading) {
        GlStateManager.shadeModel(GL11.GL_FLAT);
        smoothShading = false;
    }
    bufferBuilder = null;
    fabricBuffer = null;
    tessellator = null;
    this.itemStack = null;
    this.vanillaHandler = null;
}
Also used : Tessellator(net.minecraft.client.render.Tessellator)

Aggregations

Tessellator (net.minecraft.client.render.Tessellator)47 BufferBuilder (net.minecraft.client.render.BufferBuilder)43 GameRenderer (net.minecraft.client.render.GameRenderer)31 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