Search in sources :

Example 76 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project Wurst-MC-1.12-OF by Wurst-Imperium.

the class PasswordField method drawCursorVertical.

/**
 * Draws the current selection and a vertical line cursor in the text box.
 */
private void drawCursorVertical(int startX, int startY, int endX, int endY) {
    if (startX < endX) {
        int i = startX;
        startX = endX;
        endX = i;
    }
    if (startY < endY) {
        int j = startY;
        startY = endY;
        endY = j;
    }
    if (endX > xPosition + width)
        endX = xPosition + width;
    if (startX > xPosition + width)
        startX = xPosition + width;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();
    GlStateManager.color(0.0F, 0.0F, 255.0F, 255.0F);
    GlStateManager.disableTexture2D();
    GlStateManager.enableColorLogic();
    GlStateManager.colorLogicOp(GlStateManager.LogicOp.OR_REVERSE);
    bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
    bufferbuilder.pos(startX, endY, 0.0D).endVertex();
    bufferbuilder.pos(endX, endY, 0.0D).endVertex();
    bufferbuilder.pos(endX, startY, 0.0D).endVertex();
    bufferbuilder.pos(startX, startY, 0.0D).endVertex();
    tessellator.draw();
    GlStateManager.disableColorLogic();
    GlStateManager.enableTexture2D();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 77 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project Binnie by ForestryMC.

the class RenderUtil method drawTexture.

public static void drawTexture(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) {
    double uMin = textureSprite.getMinU();
    double uMax = textureSprite.getMaxU();
    double vMin = textureSprite.getMinV();
    double vMax = textureSprite.getMaxV();
    uMax = uMax - maskRight / 16.0 * (uMax - uMin);
    vMax = vMax - maskTop / 16.0 * (vMax - vMin);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
    bufferBuilder.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex();
    bufferBuilder.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex();
    bufferBuilder.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex();
    bufferBuilder.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex();
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 78 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project ChatTweaks by blay09.

the class GuiImagePreview method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    drawWorldBackground(0);
    if (textureId == -1 && loadBuffer != null) {
        textureWidth = loadBuffer.getWidth();
        textureHeight = loadBuffer.getHeight();
        textureId = TextureUtil.glGenTextures();
        TextureUtil.uploadTextureImage(textureId, loadBuffer);
        loadBuffer = null;
    }
    if (textureId == -1) {
        drawCenteredString(fontRenderer, I18n.format(ChatTweaks.MOD_ID + ":gui.imagePreview.loadingPreview"), width / 2, height / 2 - 20, 0xFFFFFFFF);
    } else {
        float renderWidth = textureWidth;
        float renderHeight = textureHeight;
        float factor;
        if (renderWidth > IMAGE_WIDTH) {
            factor = IMAGE_WIDTH / renderWidth;
            renderWidth *= factor;
            renderHeight *= factor;
        }
        if (renderHeight > IMAGE_HEIGHT) {
            factor = IMAGE_HEIGHT / renderHeight;
            renderWidth *= factor;
            renderHeight *= factor;
        }
        float renderX = width / 2 - renderWidth / 2;
        float renderY = height / 2 - renderHeight / 2 - 20;
        GlStateManager.bindTexture(textureId);
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder buffer = tessellator.getBuffer();
        buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        buffer.pos(renderX, renderY + renderHeight, zLevel).tex(0, 1).endVertex();
        buffer.pos(renderX + renderWidth, renderY + renderHeight, zLevel).tex(1, 1).endVertex();
        buffer.pos(renderX + renderWidth, renderY, zLevel).tex(1, 0).endVertex();
        buffer.pos(renderX, renderY, zLevel).tex(0, 0).endVertex();
        tessellator.draw();
    }
    super.drawScreen(mouseX, mouseY, partialTicks);
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 79 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project XNet by McJty.

the class RenderWorldLastEventHandler method renderHilightedBlock.

private static void renderHilightedBlock(RenderWorldLastEvent evt) {
    BlockPos c = XNet.instance.clientInfo.getHilightedBlock();
    if (c == null) {
        return;
    }
    Minecraft mc = Minecraft.getMinecraft();
    long time = System.currentTimeMillis();
    if (time > XNet.instance.clientInfo.getExpireHilight()) {
        XNet.instance.clientInfo.hilightBlock(null, -1);
        return;
    }
    if (((time / 500) & 1) == 0) {
        return;
    }
    EntityPlayerSP p = mc.player;
    double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * evt.getPartialTicks();
    double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * evt.getPartialTicks();
    double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * evt.getPartialTicks();
    GlStateManager.pushMatrix();
    GlStateManager.color(1.0f, 0, 0);
    GlStateManager.glLineWidth(3);
    GlStateManager.translate(-doubleX, -doubleY, -doubleZ);
    GlStateManager.disableDepth();
    GlStateManager.disableTexture2D();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    float mx = c.getX();
    float my = c.getY();
    float mz = c.getZ();
    buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
    mcjty.lib.gui.RenderHelper.renderHighLightedBlocksOutline(buffer, mx, my, mz, 1.0f, 0.0f, 0.0f, 1.0f);
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft)

Example 80 with BufferBuilder

use of net.minecraft.client.renderer.BufferBuilder in project RFToolsControl by McJty.

the class GfxOpLine method render.

@Override
public void render() {
    float 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;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder vertexbuffer = tessellator.getBuffer();
    GlStateManager.enableBlend();
    GlStateManager.disableTexture2D();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.color(f, f1, f2, f3);
    vertexbuffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
    vertexbuffer.pos(x1, y1, 0.0D).endVertex();
    vertexbuffer.pos(x2, y2, 0.0D).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Aggregations

BufferBuilder (net.minecraft.client.renderer.BufferBuilder)319 Tessellator (net.minecraft.client.renderer.Tessellator)251 BlockPos (net.minecraft.util.math.BlockPos)35 Vec3d (net.minecraft.util.math.Vec3d)27 ResourceLocation (net.minecraft.util.ResourceLocation)25 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)23 IBlockState (net.minecraft.block.state.IBlockState)21 EnumFacing (net.minecraft.util.EnumFacing)21 Minecraft (net.minecraft.client.Minecraft)14 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)11 ItemStack (net.minecraft.item.ItemStack)11 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)11 ArrayList (java.util.ArrayList)10 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)10 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)9 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)9 World (net.minecraft.world.World)8 Random (java.util.Random)7 FontRenderer (net.minecraft.client.gui.FontRenderer)7