Java Code Examples for net.minecraft.client.renderer.GlStateManager#glTexParameteri()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#glTexParameteri() . 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: GuiDownloadTofuTerrain.java    From TofuCraftReload with MIT License 5 votes vote down vote up
private void rotateAndBlurSkybox(float ticks) {
    mc.getTextureManager().bindTexture(panoramaBackground);
    GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GlStateManager.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.colorMask(true, true, true, false);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
    GlStateManager.disableAlpha();
    byte b0 = 3;

    for (int i = 0; i < b0; ++i) {
        float f = 1.0F / (i + 1);
        int j = width;
        int k = height;
        float f1 = (i - b0 / 2) / 256.0F;
        buffer.pos(j, k, 0.0D).tex(0.0F + f1, 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
        buffer.pos(j, 0.0D, 0.0D).tex(1.0F + f1, 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
        buffer.pos(0.0D, 0.0D, 0.0D).tex(1.0F + f1, 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
        buffer.pos(0.0D, k, 0.0D).tex(0.0F + f1, 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
    }

    tessellator.draw();
    GlStateManager.enableAlpha();
    GlStateManager.colorMask(true, true, true, true);
}
 
Example 2
Source File: TileEntityRendererEnergyBridge.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void renderBeamVertical(double x, double y, double z, double yMin, double yMax, double radius, double rot, double flowSpeed, boolean powered)
{
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder vertexBuffer = tessellator.getBuffer();
    double tx1 = 0.0d, tx2 = 0.0d;
    double tz1 = 0.0d, tz2 = 0.0d;
    double angle = 0.0d;

    double vScale = yMax - yMin;
    double v1 = -rot * flowSpeed;
    double v2 = (vScale * 2.0d) + v1;

    int r_i = (powered ? 160 : 255);
    int g_i = (powered ? 255 : 160);
    int b_i = (powered ? 230 : 160);
    int r_o = (powered ? 210 : 255);
    int g_o = (powered ? 255 : 160);
    int b_o = (powered ? 230 : 160);

    GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);

    this.bindTexture(TEXTURE);
    GlStateManager.disableFog();
    GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497);
    GlStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497);
    GlStateManager.disableLighting();
    GlStateManager.disableCull();
    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);

    // Beam (inner part)
    vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);

    for (int i = 0; i < 8; ++i)
    {
        tx1 = Math.sin(rot + angle) * radius;
        tz1 = Math.cos(rot + angle) * radius;
        angle += Math.PI / 4.0d;
        tx2 = Math.sin(rot + angle) * radius;
        tz2 = Math.cos(rot + angle) * radius;
        vertexBuffer.pos(tx1, yMin, tz1).tex(0.125, v1).color(r_i, g_i, b_i, 200).endVertex();
        vertexBuffer.pos(tx1, yMax, tz1).tex(0.125, v2).color(r_i, g_i, b_i, 200).endVertex();
        vertexBuffer.pos(tx2, yMax, tz2).tex(0.875, v2).color(r_i, g_i, b_i, 200).endVertex();
        vertexBuffer.pos(tx2, yMin, tz2).tex(0.875, v1).color(r_i, g_i, b_i, 200).endVertex();
    }

    tessellator.draw();

    // Glow (outer part)
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.depthMask(false);

    v1 = -rot * flowSpeed * 3.0d;
    v2 = (vScale * 2.0d) + v1;
    radius *= 2.0d;
    rot = Math.PI / 8.0d;
    vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);

    for (int i = 0; i < 8; ++i)
    {
        tx1 = Math.sin(rot + angle) * radius;
        tz1 = Math.cos(rot + angle) * radius;
        angle += Math.PI / 4.0d;
        tx2 = Math.sin(rot + angle) * radius;
        tz2 = Math.cos(rot + angle) * radius;
        vertexBuffer.pos(tx1, yMin, tz1).tex(0.125, v1).color(r_o, g_o, b_o, 80).endVertex();
        vertexBuffer.pos(tx1, yMax, tz1).tex(0.125, v2).color(r_o, g_o, b_o, 80).endVertex();
        vertexBuffer.pos(tx2, yMax, tz2).tex(0.875, v2).color(r_o, g_o, b_o, 80).endVertex();
        vertexBuffer.pos(tx2, yMin, tz2).tex(0.875, v1).color(r_o, g_o, b_o, 80).endVertex();
    }

    tessellator.draw();

    GlStateManager.enableLighting();
    GlStateManager.enableTexture2D();
    GlStateManager.depthMask(true);
    GlStateManager.enableFog();
    GlStateManager.popMatrix();
}