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();
}
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();
}
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);
}
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();
}
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();
}
Aggregations