Search in sources :

Example 21 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project NetherEx by LogicTechCorp.

the class RenderGhastQueenFireball method doRender.

@Override
public void doRender(EntityGhastQueenFireball fireball, double x, double y, double z, float entityYaw, float partialTicks) {
    GlStateManager.pushMatrix();
    bindEntityTexture(fireball);
    GlStateManager.translate((float) x, (float) y, (float) z);
    GlStateManager.enableRescaleNormal();
    GlStateManager.scale(2.0F, 2.0F, 2.0F);
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    GlStateManager.rotate(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate((float) (renderManager.options.thirdPersonView == 2 ? -1 : 1) * -renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    if (renderOutlines) {
        GlStateManager.enableColorMaterial();
        GlStateManager.enableOutlineMode(getTeamColor(fireball));
    }
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
    vertexbuffer.pos(-0.5D, -0.25D, 0.0D).tex(0.0D, 1.0D).normal(0.0F, 1.0F, 0.0F).endVertex();
    vertexbuffer.pos(0.5D, -0.25D, 0.0D).tex(1.0D, 1.0D).normal(0.0F, 1.0F, 0.0F).endVertex();
    vertexbuffer.pos(0.5D, 0.75D, 0.0D).tex(1.0D, 0.0D).normal(0.0F, 1.0F, 0.0F).endVertex();
    vertexbuffer.pos(-0.5D, 0.75D, 0.0D).tex(0.0D, 0.0D).normal(0.0F, 1.0F, 0.0F).endVertex();
    tessellator.draw();
    if (renderOutlines) {
        GlStateManager.disableOutlineMode();
        GlStateManager.disableColorMaterial();
    }
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
    super.doRender(fireball, x, y, z, entityYaw, partialTicks);
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 22 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project ImmersiveEngineering by BluSunrize.

the class EntityRenderChemthrowerShot method doRender.

@Override
public void doRender(Entity entity, double x, double y, double z, float f0, float f1) {
    FluidStack f = ((EntityChemthrowerShot) entity).getFluid();
    if (f == null) {
        f = ((EntityChemthrowerShot) entity).getFluidSynced();
        if (f == null)
            return;
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    GlStateManager.enableRescaleNormal();
    Tessellator tessellator = ClientUtils.tes();
    GlStateManager.disableCull();
    GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    TextureAtlasSprite sprite = ClientUtils.mc().getTextureMapBlocks().getAtlasSprite(f.getFluid().getStill(f).toString());
    if (sprite != null) {
        int colour = f.getFluid().getColor(f);
        float a = (colour >> 24 & 255) / 255f;
        float r = (colour >> 16 & 255) / 255f;
        float g = (colour >> 8 & 255) / 255f;
        float b = (colour & 255) / 255f;
        ClientUtils.bindAtlas();
        GlStateManager.scale(.25f, .25f, .25f);
        VertexBuffer worldrenderer = ClientUtils.tes().getBuffer();
        worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldrenderer.pos(-.25, -.25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(4)).color(r, g, b, a).endVertex();
        worldrenderer.pos(.25, -.25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(4)).color(r, g, b, a).endVertex();
        worldrenderer.pos(.25, .25, 0).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).color(r, g, b, a).endVertex();
        worldrenderer.pos(-.25, .25, 0).tex(sprite.getInterpolatedU(4), sprite.getInterpolatedV(0)).color(r, g, b, a).endVertex();
        tessellator.draw();
    }
    GlStateManager.enableCull();
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) FluidStack(net.minecraftforge.fluids.FluidStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EntityChemthrowerShot(blusunrize.immersiveengineering.common.entities.EntityChemthrowerShot)

Example 23 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project ImmersiveEngineering by BluSunrize.

the class EntityRenderRailgunShot method renderRailgunProjectile.

public static void renderRailgunProjectile(double x, double y, double z, double yaw, double pitch, int[][] colourMap) {
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    GlStateManager.enableRescaleNormal();
    Tessellator tes = ClientUtils.tes();
    VertexBuffer worldrenderer = ClientUtils.tes().getBuffer();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    GlStateManager.disableCull();
    GlStateManager.rotate((float) yaw, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate((float) pitch, 0.0F, 0.0F, 1.0F);
    GlStateManager.scale(.25f, .25f, .25f);
    if (colourMap.length == 1) {
        colourMap = new int[][] { colourMap[0], colourMap[0] };
    }
    float height = .1875f;
    float halfWidth = height / 2;
    float length = 2;
    int colWidth = colourMap[0].length;
    for (int i = 0; i < colourMap.length; i++) colWidth = Math.min(colWidth, colourMap[i].length);
    int colLength = colourMap.length;
    float widthStep = height / colWidth;
    float lengthStep = length / colLength;
    GlStateManager.translate(-length * .85f, 0, 0);
    worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    int colR;
    int colG;
    int colB;
    //Front&Back
    GlStateManager.color(1f, 1f, 1f, 1f);
    for (int i = 0; i < colWidth; i++) {
        colR = (colourMap[0][i] >> 16) & 255;
        colG = (colourMap[0][i] >> 8) & 255;
        colB = colourMap[0][i] & 255;
        worldrenderer.pos(0, height, -halfWidth + widthStep * i).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(0, 0, -halfWidth + widthStep * i).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(0, 0, -halfWidth + widthStep * (i + 1)).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(0, height, -halfWidth + widthStep * (i + 1)).color(colR, colG, colB, 255).endVertex();
        colR = colourMap[colLength - 1][i] >> 16 & 255;
        colG = colourMap[colLength - 1][i] >> 8 & 255;
        colB = colourMap[colLength - 1][i] & 255;
        worldrenderer.pos(length, 0, -halfWidth + widthStep * i).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(length, height, -halfWidth + widthStep * i).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(length, height, -halfWidth + widthStep * (i + 1)).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(length, 0, -halfWidth + widthStep * (i + 1)).color(colR, colG, colB, 255).endVertex();
    }
    //Sides
    for (int i = 0; i < colLength; i++) {
        colR = colourMap[i][0] >> 16 & 255;
        colG = colourMap[i][0] >> 8 & 255;
        colB = colourMap[i][0] & 255;
        worldrenderer.pos(lengthStep * i, 0, -halfWidth).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * i, height, -halfWidth).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * (i + 1), height, -halfWidth).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * (i + 1), 0, -halfWidth).color(colR, colG, colB, 255).endVertex();
        colR = colourMap[i][colWidth - 1] >> 16 & 255;
        colG = colourMap[i][colWidth - 1] >> 8 & 255;
        colB = colourMap[i][colWidth - 1] & 255;
        worldrenderer.pos(lengthStep * i, height, halfWidth).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * i, 0, halfWidth).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * (i + 1), 0, halfWidth).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * (i + 1), height, halfWidth).color(colR, colG, colB, 255).endVertex();
    }
    //Top&Bottom
    for (int i = 0; i < colLength; i++) for (int j = 0; j < colWidth; j++) {
        colR = colourMap[i][j] >> 16 & 255;
        colG = colourMap[i][j] >> 8 & 255;
        colB = colourMap[i][j] & 255;
        worldrenderer.pos(lengthStep * (i + 1), height, -halfWidth + widthStep * j).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * i, height, -halfWidth + widthStep * j).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * i, height, -halfWidth + widthStep * (j + 1)).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * (i + 1), height, -halfWidth + widthStep * (j + 1)).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * i, 0, -halfWidth + widthStep * j).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * (i + 1), 0, -halfWidth + widthStep * j).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * (i + 1), 0, -halfWidth + widthStep * (j + 1)).color(colR, colG, colB, 255).endVertex();
        worldrenderer.pos(lengthStep * i, 0, -halfWidth + widthStep * (j + 1)).color(colR, colG, colB, 255).endVertex();
    }
    tes.draw();
    GlStateManager.enableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.enableCull();
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 24 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project NetherEx by LogicTechCorp.

the class RenderUtil method drawTexturedModalRect.

public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
    vertexbuffer.pos((double) (x + 0), (double) (y + height), 0.0D).tex((double) ((float) (textureX + 0) * 0.00390625F), (double) ((float) (textureY + height) * 0.00390625F)).endVertex();
    vertexbuffer.pos((double) (x + width), (double) (y + height), 0.0D).tex((double) ((float) (textureX + width) * 0.00390625F), (double) ((float) (textureY + height) * 0.00390625F)).endVertex();
    vertexbuffer.pos((double) (x + width), (double) (y + 0), 0.0D).tex((double) ((float) (textureX + width) * 0.00390625F), (double) ((float) (textureY + 0) * 0.00390625F)).endVertex();
    vertexbuffer.pos((double) (x + 0), (double) (y + 0), 0.0D).tex((double) ((float) (textureX + 0) * 0.00390625F), (double) ((float) (textureY + 0) * 0.00390625F)).endVertex();
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 25 with VertexBuffer

use of net.minecraft.client.renderer.VertexBuffer in project RecurrentComplex by Ivorforce.

the class GuiTexturedButton method drawTexture.

public void drawTexture(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 + height), (double) this.zLevel).tex((double) ((float) (textureX + 0) / textureWidth), (double) ((float) (textureY + height) / textureHeight)).endVertex();
    vertexbuffer.pos((double) (x + width), (double) (y + height), (double) this.zLevel).tex((double) ((float) (textureX + width) / textureWidth), (double) ((float) (textureY + height) / textureHeight)).endVertex();
    vertexbuffer.pos((double) (x + width), (double) (y + 0), (double) this.zLevel).tex((double) ((float) (textureX + width) / textureWidth), (double) ((float) (textureY + 0) / textureHeight)).endVertex();
    vertexbuffer.pos((double) (x + 0), (double) (y + 0), (double) this.zLevel).tex((double) ((float) (textureX + 0) / textureWidth), (double) ((float) (textureY + 0) / textureHeight)).endVertex();
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Aggregations

VertexBuffer (net.minecraft.client.renderer.VertexBuffer)52 Tessellator (net.minecraft.client.renderer.Tessellator)50 BlockPos (net.minecraft.util.math.BlockPos)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)5 EnumFacing (net.minecraft.util.EnumFacing)5 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)3 Minecraft (net.minecraft.client.Minecraft)3 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)3 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 Entity (net.minecraft.entity.Entity)3 Vec3i (net.minecraft.util.math.Vec3i)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 FontRenderer (net.minecraft.client.gui.FontRenderer)2 RenderManager (net.minecraft.client.renderer.entity.RenderManager)2 Vec3d (net.minecraft.util.math.Vec3d)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 NotNull (org.jetbrains.annotations.NotNull)2 IImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable)1