Example usage for org.lwjgl.opengl GL11 glEnable

List of usage examples for org.lwjgl.opengl GL11 glEnable

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glEnable.

Prototype

public static void glEnable(@NativeType("GLenum") int target) 

Source Link

Document

Enables the specified OpenGL state.

Usage

From source file:com.builtbroken.atomic.content.effects.client.RenderRadOverlay.java

@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
    int width = event.resolution.getScaledWidth();
    int height = event.resolution.getScaledHeight();
    Minecraft mc = Minecraft.getMinecraft();

    if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
        //Start/* w  ww  .j av a2s . co  m*/
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, 0.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_BLEND);

        //Position TODO config TODO fire event
        int left = 5;
        int top = 5;

        //Get data
        final float rad_player = interpolate(ClientProxy.PREV_RAD_PLAYER, ClientProxy.RAD_PLAYER,
                event.partialTicks);
        final float rad_area = interpolate(ClientProxy.PREV_RAD_EXPOSURE, ClientProxy.RAD_EXPOSURE,
                event.partialTicks);
        final float rad_dead_min = ConfigRadiation.RADIATION_DEATH_POINT / (60 * 20); //Radiation needed to die in 1 min

        //Format
        String remDisplay = formatDisplay("PER:", rad_player, "rem");
        String radDisplay = formatDisplay("ENV: ", rad_area * 20, "rem/s");

        //Render
        Render2DHelper.renderTextWithShadow(remDisplay, left, top,
                interpolate(startColor, endColor, rad_player / ConfigRadiation.RADIATION_DEATH_POINT).getRGB());
        Render2DHelper.renderTextWithShadow(radDisplay, left, top + 10,
                interpolate(startColor, endColor, rad_area / rad_dead_min).getRGB());

        if (AtomicScience.runningAsDev) {
            Render2DHelper.renderTextWithShadow("" + ClientProxy.RAD_REMOVE_TIMER, left + 60, top,
                    endColor.getRGB());
        }

        //Set prev
        ClientProxy.PREV_RAD_PLAYER = rad_player;
        ClientProxy.PREV_RAD_EXPOSURE = rad_area;

        //End
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glPopMatrix();
    }
}

From source file:com.builtbroken.atomic.content.items.cell.RendererItemCell.java

protected void renderFluid(ItemRenderType type, ItemStack item) {
    final FluidStack fluidStack = ((ItemFluidCell) item.getItem()).getFluid(item);
    if (fluidStack != null) {
        final Fluid fluid = fluidStack.getFluid();

        if (fluid != null) {
            final IIcon maskIcon = ASItems.itemFluidCell.getIconFromDamage(-1);
            final IIcon subIcon = fluid.getFlowingIcon() != null ? fluid.getFlowingIcon() : fluid.getIcon();

            if (maskIcon != null && subIcon != null) {
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                GL11.glDisable(GL11.GL_CULL_FACE);
                Tessellator tessellator = Tessellator.instance;

                //Render mask TODO change mask verts to show fill %
                bindItemTexture(item.getItem());
                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, 1);
                generatedGeometry(maskIcon, type, 10, 0.001);
                tessellator.draw();/*from w  w w .  j  a  v  a 2s  .c o m*/

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, -1); //TODO don't think is needed for inventory
                generatedGeometry(maskIcon, type, -0.0635, -0.0635);
                tessellator.draw();

                //Render fluid
                bindFluidTexture(fluid);

                GL11.glDepthFunc(GL11.GL_EQUAL);
                GL11.glDepthMask(false);

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, 1);
                generatedGeometry(subIcon, type, 10, 0.001);
                tessellator.draw();

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, -1); //TODO don't think is needed for inventory
                generatedGeometry(subIcon, type, -0.0635, -0.0635);
                tessellator.draw();

                GL11.glDisable(GL11.GL_BLEND);
                GL11.glDepthMask(true);
                GL11.glDepthFunc(GL11.GL_LEQUAL);
                GL11.glEnable(GL11.GL_CULL_FACE);
                GL11.glColor4f(1, 1, 1, 1);
            }
        }
    }
}

From source file:com.builtbroken.atomic.content.items.cell.RendererItemCell.java

protected void preRender() {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
}

From source file:com.builtbroken.atomic.lib.Render2DHelper.java

/**
 * Draws a solid color rectangle with the specified coordinates and color. Args: x1, y1, x2, y2, color
 *//*from w w w .j  ava 2 s.co m*/
public static void drawRect(int x1, int y1, int x2, int y2, int color) {
    int j1;

    if (x1 < x2) {
        j1 = x1;
        x1 = x2;
        x2 = j1;
    }

    if (y1 < y2) {
        j1 = y1;
        y1 = y2;
        y2 = j1;
    }

    float f3 = (float) (color >> 24 & 255) / 255.0F;
    float f = (float) (color >> 16 & 255) / 255.0F;
    float f1 = (float) (color >> 8 & 255) / 255.0F;
    float f2 = (float) (color & 255) / 255.0F;
    Tessellator tessellator = Tessellator.instance;
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    GL11.glColor4f(f, f1, f2, f3);
    tessellator.startDrawingQuads();
    tessellator.addVertex((double) x1, (double) y2, 0.0D);
    tessellator.addVertex((double) x2, (double) y2, 0.0D);
    tessellator.addVertex((double) x2, (double) y1, 0.0D);
    tessellator.addVertex((double) x1, (double) y1, 0.0D);
    tessellator.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:com.builtbroken.atomic.lib.Render2DHelper.java

/**
 * Draws a rectangle with a vertical gradient between the specified colors.
 */// w  ww .j  a v  a  2 s.co m
public static void drawGradientRect(int p_73733_1_, int p_73733_2_, int p_73733_3_, int p_73733_4_,
        int p_73733_5_, int p_73733_6_) {
    float f = (float) (p_73733_5_ >> 24 & 255) / 255.0F;
    float f1 = (float) (p_73733_5_ >> 16 & 255) / 255.0F;
    float f2 = (float) (p_73733_5_ >> 8 & 255) / 255.0F;
    float f3 = (float) (p_73733_5_ & 255) / 255.0F;
    float f4 = (float) (p_73733_6_ >> 24 & 255) / 255.0F;
    float f5 = (float) (p_73733_6_ >> 16 & 255) / 255.0F;
    float f6 = (float) (p_73733_6_ >> 8 & 255) / 255.0F;
    float f7 = (float) (p_73733_6_ & 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.instance;
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA_F(f1, f2, f3, f);
    tessellator.addVertex((double) p_73733_3_, (double) p_73733_2_, (double) zLevel);
    tessellator.addVertex((double) p_73733_1_, (double) p_73733_2_, (double) zLevel);
    tessellator.setColorRGBA_F(f5, f6, f7, f4);
    tessellator.addVertex((double) p_73733_1_, (double) p_73733_4_, (double) zLevel);
    tessellator.addVertex((double) p_73733_3_, (double) p_73733_4_, (double) zLevel);
    tessellator.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.builtbroken.grappling.content.entity.RenderHook.java

@Override
public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
    GL11.glPushMatrix();/*from ww w  .j a v a  2s  . co m*/
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glDisable(GL11.GL_LIGHTING);

    final float scale = 0.0625f / 3;
    GL11.glScalef(scale, scale, scale);

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(getEntityTexture(entity));
    if (entity instanceof EntityHook) {
        final Hook hook = ((EntityHook) entity).hook;

        if (hook != null) {
            switch (hook.side) {
            //Bottom
            case 0:
                GL11.glRotatef(-90, 1, 0, 0);
                break;
            //Top
            case 1:
                GL11.glRotatef(90, 1, 0, 0);
                break;
            //North
            case 2:
                //Default rotation
                break;
            //South
            case 3:
                GL11.glRotatef(180, 0, 1, 0);
                break;
            case 4:
                GL11.glRotatef(90, 0, 1, 0);
                break;
            case 5:
                GL11.glRotatef(-90, 0, 1, 0);
                break;
            }
        }
    }
    MODEL.renderAll();

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.blast.entity.slime.RenderSlimeRain.java

/**
 * Queries whether should render the specified pass or not.
 *//*from ww w  .  j  a  v a 2s .  c om*/
protected int shouldRenderPass(EntitySlimeRain p_77032_1_, int p_77032_2_, float p_77032_3_) {
    if (p_77032_1_.isInvisible()) {
        return 0;
    } else if (p_77032_2_ == 0) {
        this.setRenderPassModel(this.scaleAmount);
        GL11.glEnable(GL11.GL_NORMALIZE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        return 1;
    } else {
        if (p_77032_2_ == 1) {
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }

        return -1;
    }
}

From source file:com.builtbroken.icbm.content.fragments.RenderFragment.java

public void doRenderFireBall(EntityFragment entity, double xx, double yy, double zz, float p_76986_8_,
        float p_76986_9_, float scale) {
    GL11.glPushMatrix();/*from www .j a v a 2 s  .  co m*/
    this.renderManager.renderEngine.bindTexture(TextureMap.locationItemsTexture);

    GL11.glTranslatef((float) xx, (float) yy, (float) zz);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glScalef(scale / 1.0F, scale / 1.0F, scale / 1.0F);

    IIcon iicon = Items.fire_charge.getIconFromDamage(0);
    Tessellator tessellator = Tessellator.instance;

    float minU = iicon.getMinU();
    float maxU = iicon.getMaxU();
    float minV = iicon.getMinV();
    float maxV = iicon.getMaxV();

    float f7 = 1.0F;
    float f8 = 0.5F;
    float f9 = 0.25F;

    GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    tessellator.addVertexWithUV((double) (0.0F - f8), (double) (0.0F - f9), 0.0D, (double) minU, (double) maxV);
    tessellator.addVertexWithUV((double) (f7 - f8), (double) (0.0F - f9), 0.0D, (double) maxU, (double) maxV);
    tessellator.addVertexWithUV((double) (f7 - f8), (double) (1.0F - f9), 0.0D, (double) maxU, (double) minV);
    tessellator.addVertexWithUV((double) (0.0F - f8), (double) (1.0F - f9), 0.0D, (double) minU, (double) minV);
    tessellator.draw();

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.fragments.RenderFragment.java

private void doRenderArrow(EntityFragment entity, double xx, double yy, double zz, float p_76986_8_,
        float p_76986_9_) {
    GL11.glPushMatrix();/*from   w ww. j  a v a 2  s  .c om*/
    GL11.glTranslatef((float) xx, (float) yy, (float) zz);
    GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * p_76986_9_ - 90.0F,
            0.0F, 1.0F, 0.0F);
    GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * p_76986_9_,
            0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;
    byte b0 = 0;
    float f2 = 0.0F;
    float f3 = 0.5F;
    float f4 = (float) (0 + b0 * 10) / 32.0F;
    float f5 = (float) (5 + b0 * 10) / 32.0F;
    float f6 = 0.0F;
    float f7 = 0.15625F;
    float f8 = (float) (5 + b0 * 10) / 32.0F;
    float f9 = (float) (10 + b0 * 10) / 32.0F;
    float f10 = 0.05625F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(f10, f10, f10);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9);
    tessellator.draw();
    GL11.glNormal3f(-f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, f10);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5);
        tessellator.draw();
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.rail.RenderMissileCart.java

/**
 * Renders the bounding box around the cart
 *
 * @param cart//  ww w  .j  a  va2s  .c o m
 * @param xx
 * @param yy
 * @param zz
 */
protected void drawBounds(EntityMissileCart cart, double xx, double yy, double zz) {
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_BLEND);

    float halfWidth = cart.width / 2.0F;
    float halfLength = cart.length / 2.0F;
    float yaw = (float) Math.abs(MathUtility.clampAngleTo180(cart.rotationYaw));
    if (yaw >= 45 && yaw <= 135) {
        halfWidth = cart.length / 2.0F;
        halfLength = cart.width / 2.0F;
    }

    AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(xx - halfWidth, yy, zz - halfLength,
            xx + halfWidth, yy + (double) cart.height, zz + halfLength);
    RenderGlobal.drawOutlinedBoundingBox(axisalignedbb, 16777215);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
}