private void drawChar(final float x, final char ch, final VertexBuffer buffer) { if (Character.isWhitespace(ch) || Character.isISOControl(ch)) { return; } final int index = getCharIndex(ch); final int column = index % COLUMNS; final int row = index / COLUMNS; final float u = column * U_STEP; final float v = row * V_STEP; buffer.pos(x, getCharHeight(), 0).tex(u, v + V_SIZE).endVertex(); buffer.pos(x + getCharWidth(), getCharHeight(), 0).tex(u + U_SIZE, v + V_SIZE).endVertex(); buffer.pos(x + getCharWidth(), 0, 0).tex(u + U_SIZE, v).endVertex(); buffer.pos(x, 0, 0).tex(u, v).endVertex(); }
/** * Draw a full one-by-one, untextured quad. * * @param x the x position of the quad. * @param y the y position of the quad. * @param w the width of the quad. * @param h the height of the quad. */ @SideOnly(Side.CLIENT) public static void drawUntexturedQuad(final float x, final float y, final float w, final float h) { final Tessellator tessellator = Tessellator.getInstance(); final VertexBuffer buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); buffer.pos(x, y + h, 0).endVertex(); buffer.pos(x + w, y + h, 0).endVertex(); buffer.pos(x + w, y, 0).endVertex(); buffer.pos(x, y, 0).endVertex(); tessellator.draw(); }
/** * Draws a textured rectangle at the stored z-value. Args: x, y, u, v, width, height */ public void drawTexturedModalRect(Tessellator tessellator, int x, int y, int width, int height, int zLevel) { tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos((double) (x), (double) (y + height), (double) zLevel).tex(0F, 1F).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) zLevel).tex(1F, 1F).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y), (double) zLevel).tex(1F, 0F).endVertex(); tessellator.getBuffer().pos((double) (x), (double) (y), (double) zLevel).tex(0F, 0F).endVertex(); tessellator.draw(); }
public void drawTexturedModalRect(int x, int y, int width, int height, int tex_x, int tex_y, int tex_width, int tex_height) { Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos((double) (x + 0), (double) (y + height), (double) this.zLevel).tex((double) ((float) (tex_x + 0)), (double) ((float) (tex_y + tex_height))).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) this.zLevel).tex((double) ((float) (tex_x + tex_width)), (double) ((float) (tex_y + tex_height))).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y + 0), (double) this.zLevel).tex((double) ((float) (tex_x + tex_width)), (double) ((float) (tex_y + 0))).endVertex(); tessellator.getBuffer().pos((double) (x + 0), (double) (y + 0), (double) this.zLevel).tex((double) ((float) (tex_x + 0)), (double) ((float) (tex_y + 0))).endVertex(); tessellator.draw(); }
public void drawTexturedModalRect(int x, int y, int width, int height, int tex_x, int tex_y, int tex_width, int tex_height) { Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos((double) (x + 0), (double) (y + height), (double) this.zLevel).tex((double) ((float) (tex_x + 0)), (double) ((float) (tex_y + tex_height))).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) this.zLevel).tex((double) ((float) (tex_x + tex_width)), (double) ((float) (tex_y + tex_height))).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y + 0), (double) this.zLevel).tex((double) ((float) (tex_x + tex_width)), (double) ((float) (tex_y + 0))).endVertex(); tessellator.getBuffer().pos((double) (x + 0), (double) (y + 0), (double) this.zLevel).tex((double) ((float) (tex_x + 0)), (double) ((float) (tex_y + 0))).endVertex(); tessellator.draw(); } }
public static void renderTexturedQuad(float par1, float par2, float par3, float par4) { Tessellator par0Tessellator = Tessellator.getInstance(); VertexBuffer renderer = par0Tessellator.getBuffer(); renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM); renderer.pos(0, 0, 0).tex((double) par1, (double) par4).normal(0, 0, 1).endVertex(); renderer.pos(1, 0, 0).tex((double) par3, (double) par4).normal(0, 0, 1).endVertex(); renderer.pos(1, 1, 0).tex((double) par3, (double) par2).normal(0, 0, 1).endVertex(); renderer.pos(0, 1, 0).tex((double) par1, (double) par2).normal(0, 0, 1).endVertex(); par0Tessellator.draw(); }
public void drawTexturedModalRect(int x, int y, int width, int height, int tex_x, int tex_y, int tex_width, int tex_height) { Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos((double) (x), (double) (y + height), (double) this.zLevel).tex((double) ((float) (tex_x)), (double) ((float) (tex_y + tex_height))).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) this.zLevel).tex((double) ((float) (tex_x + tex_width)), (double) ((float) (tex_y + tex_height))).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y), (double) this.zLevel).tex((double) ((float) (tex_x + tex_width)), (double) ((float) (tex_y))).endVertex(); tessellator.getBuffer().pos((double) (x), (double) (y), (double) this.zLevel).tex((double) ((float) (tex_x)), (double) ((float) (tex_y))).endVertex(); tessellator.draw(); }
public static void renderTexturedQuad(int x, int y, float z, int width, int height) { Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos((double) (x), (double) (y + height), (double) z).tex(0D, 1D).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) z).tex(1D, 1D).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y), (double) z).tex(1D, 0D).endVertex(); tessellator.getBuffer().pos((double) (x), (double) (y), (double) z).tex(0D, 0D).endVertex(); tessellator.draw(); } }
/** * Draws a horizontal line of the specified height. * * @param height the height of the line to draw. */ @SideOnly(Side.CLIENT) private static void drawLine(final int height) { GlStateManager.depthMask(false); GlStateManager.disableTexture2D(); final Tessellator tessellator = Tessellator.getInstance(); final VertexBuffer buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); buffer.pos(-0.5f, height + 0.5f, 0).endVertex(); buffer.pos(71.5f, height + 0.5f, 0).endVertex(); buffer.pos(71.5f, -0.5f, 0).endVertex(); buffer.pos(-0.5f, -0.5f, 0).endVertex(); tessellator.draw(); GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); }
private void setupRender(int xBase, int yBase, int uBase, int vBase) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); minecraft.getTextureManager().bindTexture(Gui.statIcons); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer wr = tessellator.getBuffer(); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); wr.pos((double) (xBase), (double) (yBase + 18), zLevel).tex((double) ((float) (uBase) * 0.0078125F), (double) ((float) (vBase + 18) * 0.0078125F)).endVertex(); wr.pos((double) (xBase + 18), (double) (yBase + 18), zLevel).tex((double) ((float) (uBase + 18) * 0.0078125F), (double) ((float) (vBase + 18) * 0.0078125F)).endVertex(); wr.pos((double) (xBase + 18), (double) (yBase), zLevel).tex((double) ((float) (uBase + 18) * 0.0078125F), (double) ((float) (vBase) * 0.0078125F)).endVertex(); wr.pos((double) (xBase), (double) (yBase), zLevel).tex((double) ((float) (uBase) * 0.0078125F), (double) ((float) (vBase) * 0.0078125F)).endVertex(); wr.finishDrawing(); } }
@Override @SideOnly(Side.CLIENT) public void render() { Minecraft.getMinecraft().getTextureManager().bindTexture(location); final Tessellator t = Tessellator.getInstance(); final VertexBuffer b = t.getBuffer(); b.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); b.pos(0, 16, 0).tex(0, 1).endVertex(); b.pos(16, 16, 0).tex(1, 1).endVertex(); b.pos(16, 0, 0).tex(1, 0).endVertex(); b.pos(0, 0, 0).tex(0, 0).endVertex(); t.draw(); } }
/** * Draws a textured rectangle at the stored z-value. Args: x, y, u, v, width, height */ public void drawTexturedModalRect(int x, int y, int width, int height, int tex_x, int tex_y, int tex_width, int tex_height) { Tessellator tessellator = Tessellator.getInstance(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); tessellator.getBuffer().pos((double) (x), (double) (y + height), (double) this.zLevel).tex((double) ((float) (tex_x)), (double) ((float) (tex_y + tex_height))).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y + height), (double) this.zLevel).tex((double) ((float) (tex_x + tex_width)), (double) ((float) (tex_y + tex_height))).endVertex(); tessellator.getBuffer().pos((double) (x + width), (double) (y), (double) this.zLevel).tex((double) ((float) (tex_x + tex_width)), (double) ((float) (tex_y))).endVertex(); tessellator.getBuffer().pos((double) (x), (double) (y), (double) this.zLevel).tex((double) ((float) (tex_x)), (double) ((float) (tex_y))).endVertex(); tessellator.draw(); }
/** * Draw an arbitrarily sized quad with the specified texture coordinates. * * @param x the x position of the quad. * @param y the y position of the quad. * @param w the width of the quad. * @param h the height of the quad. * @param u0 lower u texture coordinate. * @param v0 lower v texture coordinate. * @param u1 upper u texture coordinate. * @param v1 upper v texture coordinate. */ @SideOnly(Side.CLIENT) public static void drawQuad(final float x, final float y, final float w, final float h, final float u0, final float v0, final float u1, final float v1) { final Tessellator tessellator = Tessellator.getInstance(); final VertexBuffer buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(x, y + h, 0).tex(u0, v1).endVertex(); buffer.pos(x + w, y + h, 0).tex(u1, v1).endVertex(); buffer.pos(x + w, y, 0).tex(u1, v0).endVertex(); buffer.pos(x, y, 0).tex(u0, v0).endVertex(); tessellator.draw(); }
public static void drawRect2(int x1, int y1, int x2, int y2, int colour) { int j1; if (x1 < x2) { j1 = x1; x1 = x2; x2 = j1; } if (y1 < y2) { j1 = y1; y1 = y2; y2 = j1; } float f = (float)(colour >> 24 & 255) / 255.0F; float f1 = (float)(colour >> 16 & 255) / 255.0F; float f2 = (float)(colour >> 8 & 255) / 255.0F; float f3 = (float)(colour & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); GlStateManager.color(f1, f2, f3, f); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); tessellator.getBuffer().pos((double) x1, (double) y2, 0).endVertex(); tessellator.getBuffer().pos((double) x2, (double) y2, 0).endVertex(); tessellator.getBuffer().pos((double) x2, (double) y1, 0).endVertex(); tessellator.getBuffer().pos((double) x1, (double) y1, 0).endVertex(); tessellator.draw(); }
@Override public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { if (visible) { mc.getTextureManager().bindTexture(image); GlStateManager.color(1, 1, 1, 1); hovered = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height; final int x0 = xPosition; final int x1 = xPosition + width; final int y0 = yPosition + verticalImageOffset; final int y1 = yPosition + verticalImageOffset + ((imageHeightOverride > 0) ? imageHeightOverride : height); final double u0 = 0; final double u1 = u0 + 1; final double v0 = (hoverOverride || getHoverState(hovered) == 2) ? 0.5 : 0; final double v1 = v0 + 0.5; final Tessellator t = Tessellator.getInstance(); final VertexBuffer b = t.getBuffer(); b.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); b.pos(x0, y1, zLevel).tex(u0, v1).endVertex(); b.pos(x1, y1, zLevel).tex(u1, v1).endVertex(); b.pos(x1, y0, zLevel).tex(u1, v0).endVertex(); b.pos(x0, y0, zLevel).tex(u0, v0).endVertex(); t.draw(); } } }
protected void drawRectangle(double x, double y, double width, double height, int color) { GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); float a = (float) (color >> 24 & 0xFF) / 255.0F; float r = (float) (color >> 16 & 0xFF) / 255.0F; float g = (float) (color >> 8 & 0xFF) / 255.0F; float b = (float) (color & 0xFF) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexBuffer = tessellator.getBuffer(); vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); vertexBuffer.pos(x, y + height, 0.0).color(r, g, b, a).endVertex(); vertexBuffer.pos(x + width, y + height, 0.0).color(r, g, b, a).endVertex(); vertexBuffer.pos(x + width, y, 0.0).color(r, g, b, a).endVertex(); vertexBuffer.pos(x, y, 0.0).color(r, g, b, a).endVertex(); tessellator.draw(); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); }
protected void drawTexturedRectangle(double x, double y, double width, double height, int color) { GlStateManager.enableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); float a = (float) (color >> 24 & 0xFF) / 255.0F; float r = (float) (color >> 16 & 0xFF) / 255.0F; float g = (float) (color >> 8 & 0xFF) / 255.0F; float b = (float) (color & 0xFF) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexBuffer = tessellator.getBuffer(); vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); vertexBuffer.pos(x, y + height, 0.0).tex(0.0F, 1.0F).color(r, g, b, a).endVertex(); vertexBuffer.pos(x + width, y + height, 0.0).tex(1.0F, 1.0F).color(r, g, b, a).endVertex(); vertexBuffer.pos(x + width, y, 0.0).tex(1.0F, 0.0F).color(r, g, b, a).endVertex(); vertexBuffer.pos(x, y, 0.0).tex(0.0F, 0.0F).color(r, g, b, a).endVertex(); tessellator.draw(); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.disableTexture2D(); }
tess.getBuffer().pos(-8, 136, -.01).tex(0, 1).endVertex(); tess.getBuffer().pos(136, 136, -.01).tex(1, 1).endVertex(); tess.getBuffer().pos(136, -8, -.01).tex(1, 0).endVertex(); tess.getBuffer().pos(-8, -8, -.01).tex(0, 0).endVertex(); tess.draw(); tess.getBuffer().pos(8, 120, -0.015).tex(0, 1).endVertex(); tess.getBuffer().pos(120, 120, -0.015).tex(1, 1).endVertex(); tess.getBuffer().pos(120, 8, -0.015).tex(1, 0).endVertex(); tess.getBuffer().pos(8, 8, -0.015).tex(0, 0).endVertex(); tess.draw();
@SuppressWarnings("ConstantConditions") void renderFluidPlane(ResourceLocation fluid, float x, float y, float z, float size) { GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); RenderHelper.disableStandardItemLighting(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vb = tessellator.getBuffer(); TextureAtlasSprite sprite = MINECRAFT.getTextureMapBlocks().getTextureExtry(fluid.toString()); if (sprite != null) { MINECRAFT.renderEngine.bindTexture(LOCATION_BLOCKS_TEXTURE); double uMin = (double) sprite.getMinU(); double uMax = (double) sprite.getMaxU(); double vMin = (double) sprite.getMinV(); double vMax = (double) sprite.getMaxV(); vb.begin(7, POSITION_TEX); vb.pos(size / 2f, 0, size / 2f).tex(uMax, vMax).endVertex(); vb.pos(size / 2f, 0, -size / 2f).tex(uMax, vMin).endVertex(); vb.pos(-size / 2f, 0, -size / 2f).tex(uMin, vMin).endVertex(); vb.pos(-size / 2f, 0, size / 2f).tex(uMin, vMax).endVertex(); tessellator.draw(); } GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.disableBlend(); RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); }