Java Code Examples for net.minecraft.client.renderer.Tessellator#getBuffer()

The following examples show how to use net.minecraft.client.renderer.Tessellator#getBuffer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Camera.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
public void render(float x, float y, float w, float h) {
    if (OpenGlHelper.isFramebufferEnabled()) {
        GlStateManager.pushMatrix();
        GlStateManager.enableTexture2D();
        GlStateManager.disableLighting();
        GlStateManager.disableAlpha();
        GlStateManager.disableBlend();
        GlStateManager.enableColorMaterial();

        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        frameBuffer.bindFramebufferTexture();

        final Tessellator tessellator = Tessellator.getInstance();
        final BufferBuilder bufferbuilder = tessellator.getBuffer();
        bufferbuilder.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos(x, h, 0).tex(0, 0).endVertex();
        bufferbuilder.pos(w, h, 0).tex(1, 0).endVertex();
        bufferbuilder.pos(w, y, 0).tex(1, 1).endVertex();
        bufferbuilder.pos(x, y, 0).tex(0, 1).endVertex();
        tessellator.draw();

        frameBuffer.unbindFramebufferTexture();

        GlStateManager.popMatrix();
    }
}
 
Example 2
Source File: RenderFallTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityFallTofu entity, double x, double y, double z, float entityYaw, float partialTicks) {

    IBlockState iblockstate = BlockLoader.tofuTerrain.getDefaultState();

    if (iblockstate.getRenderType() == EnumBlockRenderType.MODEL) {
        World world = entity.getWorldObj();

        if (iblockstate != world.getBlockState(new BlockPos(entity)) && iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferbuilder = tessellator.getBuffer();

            if (this.renderOutlines) {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }

            bufferbuilder.begin(7, DefaultVertexFormats.BLOCK);
            BlockPos blockpos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float) (x - (double) blockpos.getX() - 0.5D), (float) (y - (double) blockpos.getY()), (float) (z - (double) blockpos.getZ() - 0.5D));
            BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(iblockstate), iblockstate, blockpos, bufferbuilder, false);
            tessellator.draw();

            if (this.renderOutlines) {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }

            GlStateManager.enableLighting();
            GlStateManager.popMatrix();
            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }

}
 
Example 3
Source File: ModulePanetImage.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void renderBackground(GuiContainer gui, int x, int y, int mouseX,
		int mouseY, FontRenderer font) {
	super.renderBackground(gui, x, y, mouseX, mouseY, font);

	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder vertexbuffer = tessellator.getBuffer();
	GL11.glPushMatrix();
	GL11.glRotated(90, -1, 0, 0);
	//GL11.glTranslatef(xPosition, 100 + this.zLevel, yPosition);
	float newWidth = width/2f;

	RenderPlanetarySky.renderPlanetPubHelper(vertexbuffer, properties.getPlanetIcon(), (int)(x + this.offsetX + newWidth), (int)(y + this.offsetY + newWidth), (double)-0.1, newWidth, 1f, properties.getSolarTheta(), properties.hasAtmosphere(), properties.skyColor, properties.ringColor, properties.isGasGiant(), properties.hasRings());
	GL11.glPopMatrix();
}
 
Example 4
Source File: GuiInventoryButton.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void drawIcon(int x, int y, int textureX, int textureY, int width, int height)
{
	float f = 0.00390625F;
	float f1 = 0.00390625F;
	Tessellator tessellator = Tessellator.getInstance();
	VertexBuffer vertexbuffer = tessellator.getBuffer();
	vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
	vertexbuffer.pos((double)(x + 0), (double)(y + 16), (double)this.zLevel).tex((double)((float)(textureX + 0) * f), (double)((float)(textureY + height) * f1)).endVertex();
	vertexbuffer.pos((double)(x + 16), (double)(y + 16), (double)this.zLevel).tex((double)((float)(textureX + width) * f), (double)((float)(textureY + height) * f1)).endVertex();
	vertexbuffer.pos((double)(x + 16), (double)(y + 0), (double)this.zLevel).tex((double)((float)(textureX + width) * f), (double)((float)(textureY + 0) * f1)).endVertex();
	vertexbuffer.pos((double)(x + 0), (double)(y + 0), (double)this.zLevel).tex((double)((float)(textureX + 0) * f), (double)((float)(textureY + 0) * f1)).endVertex();
	tessellator.draw();
}
 
Example 5
Source File: GuiScroll.java    From VersionChecker with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6)
{
    int f = (par5 >> 24 & 255);
    float f1 = (float)(par5 >> 16 & 255) / 255.0F;
    float f2 = (float)(par5 >> 8 & 255) / 255.0F;
    float f3 = (float)(par5 & 255) / 255.0F;
    int f4 = (par6 >> 24 & 255);
    float f5 = (float)(par6 >> 16 & 255) / 255.0F;
    float f6 = (float)(par6 >> 8 & 255) / 255.0F;
    float f7 = (float)(par6 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); //POSITION_TEX_COLOR?
    buffer.pos((double)par3, (double)par2, 0.0D).color(f1, f2, f3, f).endVertex();
    buffer.pos((double)par1, (double)par2, 0.0D).color(f1, f2, f3, f).endVertex();
    buffer.pos((double)par1, (double)par4, 0.0D).color(f5, f6, f7, f4).endVertex();
    buffer.pos((double)par3, (double)par4, 0.0D).color(f5, f6, f7, f4).endVertex();
    tessellator.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example 6
Source File: GuiElementBase.java    From WearableBackpacks with MIT License 5 votes vote down vote up
public static void drawRect(int x, int y, int width, int height) {
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder buffer = tessellator.getBuffer();
	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
	buffer.pos(x        , y         , 0).endVertex();
	buffer.pos(x        , y + height, 0).endVertex();
	buffer.pos(x + width, y + height, 0).endVertex();
	buffer.pos(x + width, y         , 0).endVertex();
	tessellator.draw();
}
 
Example 7
Source File: SurfaceHelper.java    From ForgeHax with MIT License 5 votes vote down vote up
protected static void drawScaledCustomSizeModalRect(
    double x,
    double y,
    float u,
    float v,
    double uWidth,
    double vHeight,
    double width,
    double height,
    double tileWidth,
    double tileHeight) {
  double f = 1.0F / tileWidth;
  double f1 = 1.0F / tileHeight;
  Tessellator tessellator = Tessellator.getInstance();
  BufferBuilder bufferbuilder = tessellator.getBuffer();
  bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
  bufferbuilder
      .pos(x, y + height, 0.0D)
      .tex(u * f, (v + (float) vHeight) * f1)
      .endVertex();
  bufferbuilder
      .pos(x + width, y + height, 0.0D)
      .tex((u + (float) uWidth) * f, (v + (float) vHeight) * f1)
      .endVertex();
  bufferbuilder
      .pos(x + width, y, 0.0D)
      .tex((u + (float) uWidth) * f, v * f1)
      .endVertex();
  bufferbuilder
      .pos(x, y, 0.0D)
      .tex(u * f, v * f1)
      .endVertex();
  tessellator.draw();
}
 
Example 8
Source File: GuiElementBase.java    From WearableBackpacks with MIT License 5 votes vote down vote up
public static void drawColoredRectARGB(int x, int y, int width, int height,
	                                   int colorTL, int colorTR, int colorBL, int colorBR) {
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder buffer = tessellator.getBuffer();
	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
	buffer.pos(x        , y         , 0).color(colorTL >> 16 & 0xFF, colorTL >> 8 & 0xFF, colorTL & 0xFF, colorTL >> 24 & 0xFF).endVertex();
	buffer.pos(x        , y + height, 0).color(colorBL >> 16 & 0xFF, colorBL >> 8 & 0xFF, colorBL & 0xFF, colorBL >> 24 & 0xFF).endVertex();
	buffer.pos(x + width, y + height, 0).color(colorBR >> 16 & 0xFF, colorBR >> 8 & 0xFF, colorBR & 0xFF, colorBR >> 24 & 0xFF).endVertex();
	buffer.pos(x + width, y         , 0).color(colorTR >> 16 & 0xFF, colorTR >> 8 & 0xFF, colorTR & 0xFF, colorTR >> 24 & 0xFF).endVertex();
	tessellator.draw();
}
 
Example 9
Source File: ItemBeaconFinder.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void renderScreen(ItemStack componentStack, List<ItemStack> modules,
		RenderGameOverlayEvent event, Gui gui) {
	
	int dimid = Minecraft.getMinecraft().world.provider.getDimension();
	
	if(DimensionManager.getInstance().isDimensionCreated(dimid)) {
		for(HashedBlockPosition pos : DimensionManager.getInstance().getDimensionProperties(dimid).getBeacons()) {
			
			GL11.glPushMatrix();
			
			double deltaX = Minecraft.getMinecraft().player.posX - pos.x;
			double deltaZ = Minecraft.getMinecraft().player.posZ - pos.z;
			
			double angle = MathHelper.wrapDegrees(MathHelper.atan2(deltaZ, deltaX)*180/Math.PI + 90 - Minecraft.getMinecraft().player.rotationYawHead);
			
			//GL11.glTranslatef(pos.x, pos.y, pos.z);
			GL11.glTranslated((event.getResolution().getScaledWidth_double()*angle/180f) + event.getResolution().getScaledWidth()/2,0,5);
			//GL11.glDepthMask(false);
			//GL11.glDisable(GL11.GL_TEXTURE_2D);
			Minecraft.getMinecraft().renderEngine.bindTexture(TextureResources.buttonDown[0]);
			
			GlStateManager.color(0.5f, 0.5f, 1, 1);
			
	        Tessellator tessellator = Tessellator.getInstance();
	        BufferBuilder vertexbuffer = tessellator.getBuffer();
	        
	        vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
	        RenderHelper.renderNorthFaceWithUV(vertexbuffer, -1000, -10, 0, 10, 20, 0, 1, 0, 1);
			tessellator.draw();
			
			//GL11.glDepthMask(true);
			//GL11.glEnable(GL11.GL_TEXTURE_2D);
			GlStateManager.color(1, 1, 1, 1);
			GL11.glPopMatrix();
			
		}
	}
}
 
Example 10
Source File: RenderUtil.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public static void drawLine(float x, float y, float x1, float y1, float thickness, int hex) {
    float red = (hex >> 16 & 0xFF) / 255.0F;
    float green = (hex >> 8 & 0xFF) / 255.0F;
    float blue = (hex & 0xFF) / 255.0F;
    float alpha = (hex >> 24 & 0xFF) / 255.0F;

    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.shadeModel(GL_SMOOTH);
    glLineWidth(thickness);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
    bufferbuilder.pos((double) x, (double) y, (double) 0).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos((double) x1, (double) y1, (double) 0).color(red, green, blue, alpha).endVertex();
    tessellator.draw();
    GlStateManager.shadeModel(GL_FLAT);
    glDisable(GL_LINE_SMOOTH);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
 
Example 11
Source File: ToroGuiUtils.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) {
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder worldrenderer = tessellator.getBuffer();
	worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
	worldrenderer.pos(x + 0, y + height, 0.0D).tex((textureX + 0) * TEXTURE_HEIGHT_SCALER, (textureY + height) * TEXTURE_WIDTH_SCALER)
			.endVertex();
	;
	worldrenderer.pos(x + width, y + height, 0.0D).tex((textureX + width) * TEXTURE_HEIGHT_SCALER, (textureY + height) * TEXTURE_WIDTH_SCALER)
			.endVertex();
	worldrenderer.pos(x + width, y + 0, 0.0D).tex((textureX + width) * TEXTURE_HEIGHT_SCALER, (textureY + 0) * TEXTURE_WIDTH_SCALER).endVertex();
	worldrenderer.pos(x + 0, y + 0, 0.0D).tex((textureX + 0) * TEXTURE_HEIGHT_SCALER, (textureY + 0) * TEXTURE_WIDTH_SCALER).endVertex();
	tessellator.draw();
}
 
Example 12
Source File: TESRBTank.java    From BetterChests with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(TileEntityBTank te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	FluidTank tank = te.getTank();
	FluidStack stack = tank.getFluid();
	if (stack != null) {

		float fillPercentage = ((float)stack.amount) / tank.getCapacity();
		boolean gaseous = stack.getFluid().isGaseous(stack);
		GlStateManager.pushMatrix();
		GL11.glEnable(GL11.GL_BLEND);

		ResourceLocation loc = stack.getFluid().getStill(stack);
		TextureAtlasSprite sprite = RenderHelper.getAtlasSprite(loc);
		RenderHelper.bindBlockTexture();

		float minY = !gaseous ? 0 : 1 - fillPercentage;
		float maxY = gaseous ? 1 : fillPercentage;

		float minU = sprite.getMinU();
		float maxU = sprite.getMaxU();
		float minV = sprite.getMinV();
		float maxV = sprite.getMaxV();
		float minVHorizontal = minV + (maxV - minV) * minY;
		float maxVHorizontal = minV + (maxV - minV) * maxY;

		GlStateManager.translate(x, y, z);

		GlStateManager.translate(0.5, 0.5, 0.5);
		GlStateManager.scale(12/16D, 12/16D, 12/16D);
		GlStateManager.translate(-0.5, -0.5, -0.5);

		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder builder = tessellator.getBuffer();

		//south
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(0, minY, 1).tex(minU, minVHorizontal).endVertex();
		builder.pos(1, minY, 1).tex(maxU, minVHorizontal).endVertex();
		builder.pos(1, maxY, 1).tex(maxU, maxVHorizontal).endVertex();
		builder.pos(0, maxY, 1).tex(minU, maxVHorizontal).endVertex();
		tessellator.draw();

		//north
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(1, minY, 0).tex(minU, minVHorizontal).endVertex();
		builder.pos(0, minY, 0).tex(maxU, minVHorizontal).endVertex();
		builder.pos(0, maxY, 0).tex(maxU, maxVHorizontal).endVertex();
		builder.pos(1, maxY, 0).tex(minU, maxVHorizontal).endVertex();
		tessellator.draw();

		//east
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(1, minY, 1).tex(minU, minVHorizontal).endVertex();
		builder.pos(1, minY, 0).tex(maxU, minVHorizontal).endVertex();
		builder.pos(1, maxY, 0).tex(maxU, maxVHorizontal).endVertex();
		builder.pos(1, maxY, 1).tex(minU, maxVHorizontal).endVertex();
		tessellator.draw();

		//west
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(0, minY, 0).tex(minU, minVHorizontal).endVertex();
		builder.pos(0, minY, 1).tex(maxU, minVHorizontal).endVertex();
		builder.pos(0, maxY, 1).tex(maxU, maxVHorizontal).endVertex();
		builder.pos(0, maxY, 0).tex(minU, maxVHorizontal).endVertex();
		tessellator.draw();

		//up
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(1, maxY, 0).tex(minU, minV).endVertex();
		builder.pos(0, maxY, 0).tex(maxU, minV).endVertex();
		builder.pos(0, maxY, 1).tex(maxU, maxV).endVertex();
		builder.pos(1, maxY, 1).tex(minU, maxV).endVertex();
		tessellator.draw();

		//down
		builder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
		builder.pos(0, minY, 0).tex(minU, minV).endVertex();
		builder.pos(1, minY, 0).tex(maxU, minV).endVertex();
		builder.pos(1, minY, 1).tex(maxU, maxV).endVertex();
		builder.pos(0, minY, 1).tex(minU, maxV).endVertex();
		tessellator.draw();

		GL11.glDisable(GL11.GL_BLEND);
		GlStateManager.popMatrix();
	}
}
 
Example 13
Source File: RenderFallingBlockEU.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void doRender(EntityFallingBlockEU entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    IBlockState state = entity.getBlockState();

    if (state != null && state.getRenderType() == EnumBlockRenderType.MODEL)
    {
        World world = entity.getEntityWorld();

        if (state != world.getBlockState(new BlockPos(entity)) && state.getRenderType() != EnumBlockRenderType.INVISIBLE)
        {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder buffer = tessellator.getBuffer();

            if (this.renderOutlines)
            {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }

            buffer.begin(7, DefaultVertexFormats.BLOCK);
            BlockPos pos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float)(x - pos.getX() - 0.5D), (float)(y - pos.getY()), (float)(z - pos.getZ() - 0.5D));
            BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            dispatcher.getBlockModelRenderer().renderModel(
                world, dispatcher.getModelForState(state), state, pos, buffer, false, MathHelper.getPositionRandom(entity.getOrigin()));
            tessellator.draw();

            if (this.renderOutlines)
            {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }

            GlStateManager.enableLighting();
            GlStateManager.popMatrix();

            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }
}
 
Example 14
Source File: WorldProviderTorikki.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
	EntityPlayer p = Minecraft.getMinecraft().player;
	if (p != null) {
		if (p.getEntityWorld().provider instanceof WorldProviderTorikki) {
			ResourceLocation img = new ResourceLocation(Wizardry.MODID, "textures/misc/torikki_sky.png");
			Minecraft.getMinecraft().renderEngine.bindTexture(img);
			GlStateManager.pushMatrix();
			GlStateManager.disableCull();
			GlStateManager.disableFog();
			GlStateManager.disableLighting();

			GlStateManager.depthMask(false);
			Tessellator tessellator = Tessellator.getInstance();
			BufferBuilder vertexbuffer = tessellator.getBuffer();

			for (int i = 0; i < 6; ++i) {
				GlStateManager.pushMatrix();

				Minecraft.getMinecraft().renderEngine.bindTexture(img);
				if (i == 3) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
				}
				if (i == 1) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
				}
				if (i == 2) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
					GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
				}
				if (i == 4) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
					GlStateManager.rotate(270.0F, 0.0F, 1.0F, 0.0F);
				}
				if (i == 5) {
					Minecraft.getMinecraft().renderEngine.bindTexture(img);
					GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F);
					GlStateManager.rotate(-270.0F, 0.0F, 1.0F, 0.0F);
				}

				vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
				vertexbuffer.pos(-100.0D, -100.0D, -100.0D).tex(0.0D, 0.0D).endVertex();
				vertexbuffer.pos(-100.0D, -100.0D, 100.0D).tex(0.0D, 1.0D).endVertex();
				vertexbuffer.pos(100.0D, -100.0D, 100.0D).tex(1.0D, 1.0D).endVertex();
				vertexbuffer.pos(100.0D, -100.0D, -100.0D).tex(1.0D, 0.0D).endVertex();
				tessellator.draw();
				GlStateManager.popMatrix();
			}

			GlStateManager.depthMask(true);
			GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
			GlStateManager.enableCull();
			GlStateManager.enableLighting();
			GlStateManager.disableAlpha();
			GlStateManager.enableFog();
			GlStateManager.disableBlend();
			GlStateManager.popMatrix();
		}
	}
}
 
Example 15
Source File: RenderInfestedLeaves.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileInfestedLeaves tile, double x, double y, double z, float partialTicks, int destroyStage)
{
    if(tile != null)
    {
        long seed = tile.getWorld().rand.nextLong();
        int color = tile.getColor();
        
        IBlockState leafBlock = tile.getLeafBlock();
        IBakedModel leafModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(leafBlock);
        
        if(leafModel == null)
        {
            leafModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(Blocks.LEAVES.getDefaultState());
        }
        
        List<BakedQuad> leafQuads = Lists.newArrayList();
        
        for(EnumFacing side : EnumFacing.VALUES)
        {
            if(leafBlock.shouldSideBeRendered(tile.getWorld(), tile.getPos(), side))
            {
                leafQuads.addAll(leafModel.getQuads(leafBlock, side, seed));
            }
        }
        
        Tessellator tessellator = Tessellator.getInstance();
        VertexBuffer buffer = tessellator.getBuffer();
        
        bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        
        GlStateManager.pushMatrix();
        GlStateManager.translate(x, y, z);
        RenderHelper.disableStandardItemLighting();
        
        buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
        
        for(BakedQuad quad : leafQuads)
        {
            LightUtil.renderQuadColor(buffer, quad, color);
        }
        
        tessellator.draw();
        
        RenderHelper.enableStandardItemLighting();
        GlStateManager.popMatrix();
    }
}
 
Example 16
Source File: StructureManager.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Will not draw the structure if it is not already baked. Resource reloading will re-bake if required.
 *
 * @param alpha    The transparency of the rendered structure.
 * @param location The ResourceLocation of the structure to look up.
 */
@SideOnly(Side.CLIENT)
public void draw(ResourceLocation location, float alpha) {
	HashMap<Integer, int[]> cache = vboCache.get(location);

	if (cache == null || cache.isEmpty()) {
		bake(location);
		return;
	}

	GlStateManager.pushMatrix();
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GlStateManager.enablePolygonOffset();
	GlStateManager.doPolygonOffset(1f, -0.05f);
	//	GlStateManager.disableDepth();

	int alphaFunc = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC);
	float alphaRef = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF);
	GlStateManager.alphaFunc(GL11.GL_ALWAYS, 1);

	Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

	Tessellator tes = Tessellator.getInstance();
	BufferBuilder buffer = tes.getBuffer();

	for (int layerID : cache.keySet()) {

		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
		buffer.addVertexData(cache.get(layerID));

		for (int i = 0; i < buffer.getVertexCount(); i++) {
			buffer.putColorRGBA(buffer.getColorIndex(i), 255, 255, 255, (int) (alpha * 255));
		}

		tes.draw();
	}

	GlStateManager.alphaFunc(alphaFunc, alphaRef);
	//	GlStateManager.enableDepth();
	GlStateManager.disablePolygonOffset();
	GlStateManager.color(1F, 1F, 1F, 1F);
	GlStateManager.popMatrix();
}
 
Example 17
Source File: TESRBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderFullnessBar(float fullness, double x, double y, double z, EnumFacing side, EnumFacing barrelFront)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);

    if (side == EnumFacing.UP || side == EnumFacing.DOWN)
    {
        GlStateManager.rotate(LABEL_ROT_SIDE_Y[barrelFront.getIndex()], 0, 1, 0);
        GlStateManager.rotate(90f * side.getYOffset(), 1, 0, 0);
    }
    else
    {
        GlStateManager.rotate(LABEL_ROT_SIDE_Y[side.getIndex()], 0, 1, 0);
    }

    GlStateManager.translate(-0.3, -0.43, -0.001);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    GlStateManager.disableLighting();
    GlStateManager.disableTexture2D();

    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();

    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);

    int r_b = 0x03;
    int g_b = 0x03;
    int b_b = 0x20;

    buffer.pos(  0,    0, 0).color(r_b, g_b, b_b, 255).endVertex();
    buffer.pos(  0, 0.08, 0).color(r_b, g_b, b_b, 255).endVertex();
    buffer.pos(0.6, 0.08, 0).color(r_b, g_b, b_b, 255).endVertex();
    buffer.pos(0.6,    0, 0).color(r_b, g_b, b_b, 255).endVertex();

    int r_f = 0x20;
    int g_f = 0x90;
    int b_f = 0xF0;
    float e = fullness * 0.57f;

    buffer.pos(0.585    , 0.065, -0.001).color(r_f, g_f, b_f, 255).endVertex();
    buffer.pos(0.585    , 0.015, -0.001).color(r_f, g_f, b_f, 255).endVertex();
    buffer.pos(0.585 - e, 0.015, -0.001).color(r_f, g_f, b_f, 255).endVertex();
    buffer.pos(0.585 - e, 0.065, -0.001).color(r_f, g_f, b_f, 255).endVertex();

    tessellator.draw();

    GlStateManager.enableTexture2D();
    GlStateManager.enableLighting();

    GlStateManager.popMatrix();
}
 
Example 18
Source File: SmallVesselHighlightHandler.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public static void drawFace(AxisAlignedBB aabb, float[] color, EnumFacing facing)
{
	//TODO: Add UV coords for other faces
	Tessellator tessellator = Tessellator.getInstance();
	VertexBuffer buffer = tessellator.getBuffer();
	if(facing == EnumFacing.UP)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
		buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).tex(0, 1).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).tex(0, 0).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).tex(1, 0).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).tex(1, 1).color(color[0], color[1], color[2], color[3]).endVertex();

		tessellator.draw();
	}
	else if(facing == EnumFacing.DOWN)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.minX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
	else if(facing == EnumFacing.WEST)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.minX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
	else if(facing == EnumFacing.EAST)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
	else if(facing == EnumFacing.NORTH)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.minX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
	else if(facing == EnumFacing.SOUTH)
	{
		buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
		buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).color(color[0], color[1], color[2], color[3]).endVertex();
		tessellator.draw();
	}
}
 
Example 19
Source File: UnicornTrailRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void render(RenderWorldLastEvent event) {
	World world = Minecraft.getMinecraft().world;
	EntityPlayer player = Minecraft.getMinecraft().player;
	if (player == null || world == null) return;

	GlStateManager.pushMatrix();

	double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks();
	double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks();
	double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks();

	GlStateManager.translate(-interpPosX, -interpPosY + 0.1, -interpPosZ);

	GlStateManager.disableCull();
	GlStateManager.depthMask(false);
	GlStateManager.enableBlend();
	GlStateManager.disableTexture2D();
	GlStateManager.shadeModel(GL11.GL_SMOOTH);
	GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE);
	GlStateManager.enableColorMaterial();
	GlStateManager.disableLighting();

	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder vb = tessellator.getBuffer();

	Set<EntityUnicorn> corns = new HashSet<>(positions.keySet());
	for (EntityUnicorn corn : corns) {
		if (corn.world.provider.getDimension() != world.provider.getDimension()) continue;

		List<Point> points = new ArrayList<>(positions.getOrDefault(corn, new ArrayList<>()));
		boolean q = false;

		vb.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_COLOR);
		for (Point pos : points) {
			if (pos == null) continue;

			float sub = (world.getTotalWorldTime() - pos.time);
			Color color = Color.getHSBColor(sub % 360.0f / 360.0f, 1f, 1f);

			int alpha;
			if (sub < 500) {
				alpha = (int) (MathHelper.clamp(Math.log(sub + 1) / 2.0, 0, 1) * 80.0);
			} else {
				alpha = (int) (MathHelper.clamp(1 - (Math.log(sub) / 2.0), 0, 1) * 80.0);
			}

			pos(vb, pos.origin.subtract(pos.normal.scale(1.5))).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
			pos(vb, pos.origin.add(pos.normal.scale(1.5))).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
			q = !q;
		}

		tessellator.draw();
	}

	GlStateManager.enableCull();
	GlStateManager.depthMask(true);
	GlStateManager.disableBlend();
	GlStateManager.enableTexture2D();
	GlStateManager.shadeModel(GL11.GL_FLAT);
	GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);

	GlStateManager.popMatrix();
}
 
Example 20
Source File: RenderFukumame.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityFukumame entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    this.bindEntityTexture(entity);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();
    GlStateManager.translate((float)x, (float)y, (float)z);
    GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks - 90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();

    GlStateManager.enableRescaleNormal();

    GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(0.05625F, 0.05625F, 0.05625F);
    GlStateManager.translate(-4.0F, 0.0F, 0.0F);

    if (this.renderOutlines)
    {
        GlStateManager.enableColorMaterial();
        GlStateManager.enableOutlineMode(this.getTeamColor(entity));
    }

    GlStateManager.glNormal3f(0.05625F, 0.0F, 0.0F);
    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
    bufferbuilder.pos(-7.0D, -2.0D, -2.0D).tex(0.0D, 0.15625D).endVertex();
    bufferbuilder.pos(-7.0D, -2.0D, 2.0D).tex(0.15625D, 0.15625D).endVertex();
    bufferbuilder.pos(-7.0D, 2.0D, 2.0D).tex(0.15625D, 0.3125D).endVertex();
    bufferbuilder.pos(-7.0D, 2.0D, -2.0D).tex(0.0D, 0.3125D).endVertex();
    tessellator.draw();
    GlStateManager.glNormal3f(-0.05625F, 0.0F, 0.0F);
    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
    bufferbuilder.pos(-7.0D, 2.0D, -2.0D).tex(0.0D, 0.15625D).endVertex();
    bufferbuilder.pos(-7.0D, 2.0D, 2.0D).tex(0.15625D, 0.15625D).endVertex();
    bufferbuilder.pos(-7.0D, -2.0D, 2.0D).tex(0.15625D, 0.3125D).endVertex();
    bufferbuilder.pos(-7.0D, -2.0D, -2.0D).tex(0.0D, 0.3125D).endVertex();
    tessellator.draw();

    for (int j = 0; j < 4; ++j)
    {
        GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.glNormal3f(0.0F, 0.0F, 0.05625F);
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos(-8.0D, -2.0D, 0.0D).tex(0.0D, 0.0D).endVertex();
        bufferbuilder.pos(8.0D, -2.0D, 0.0D).tex(0.5D, 0.0D).endVertex();
        bufferbuilder.pos(8.0D, 2.0D, 0.0D).tex(0.5D, 0.15625D).endVertex();
        bufferbuilder.pos(-8.0D, 2.0D, 0.0D).tex(0.0D, 0.15625D).endVertex();
        tessellator.draw();
    }

    if (this.renderOutlines)
    {
        GlStateManager.disableOutlineMode();
        GlStateManager.disableColorMaterial();
    }

    GlStateManager.disableRescaleNormal();
    GlStateManager.enableLighting();
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}