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:cn.lambdalib.cgui.gui.component.ProgressBar.java

License:MIT License

public ProgressBar() {
    super("ProgressBar");
    listen(FrameEvent.class, (wi, e) -> {
        if (illustrating) {
            progress = 0.5 * (1 + Math.sin(GameTimer.getAbsTime() / 1000.0));
        }//  w w  w .j a  va2  s  .c om

        {
            double disp = MathUtils.clampd(0, 1, progress);

            double x, y, u = 0, v = 0, w, h, tw, th;
            double width = wi.transform.width, height = wi.transform.height;
            switch (dir) {
            case RIGHT:
                w = width * disp;
                h = height;
                x = y = 0;

                u = 0;
                v = 0;
                tw = disp;
                th = 1;
                break;
            case LEFT:
                w = width * disp;
                h = height;
                x = width - w;
                y = 0;

                u = (1 - disp);
                v = 0;
                tw = disp;
                th = 1;
                break;
            case UP:
                w = width;
                h = height * disp;
                x = 0;
                y = height * (1 - disp);

                u = 0;
                v = (1 - disp);
                tw = 1;
                th = disp;
                break;
            case DOWN:
                w = width;
                h = height * disp;
                x = y = 0;
                u = 0;
                v = 0;
                tw = 1;
                th = disp;
                break;
            default:
                throw new RuntimeException("niconiconi, WTF??");
            }
            if (texture != null && !texture.getResourcePath().equals("<null>")) {
                RenderUtils.loadTexture(texture);
            } else {
                GL11.glDisable(GL11.GL_TEXTURE_2D);
            }
            color.bind();
            HudUtils.rawRect(x, y, u, v, w, h, tw, th);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        }
    });
}

From source file:cn.lambdalib.template.client.render.entity.RenderCrossedProjectile.java

License:MIT License

@Override
public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9) {
    Motion3D motion = new Motion3D(entity);
    Tessellator t = Tessellator.instance;

    GL11.glPushMatrix();//from   w  w w .j av  a  2  s.c o  m
    {
        Vec3 v1 = newV3(0, HEIGHT, 0), v2 = newV3(0, -HEIGHT, 0), v3 = newV3(LENGTH, -HEIGHT, 0),
                v4 = newV3(LENGTH, HEIGHT, 0), v5 = newV3(0, 0, -HEIGHT), v6 = newV3(0, 0, HEIGHT),
                v7 = newV3(LENGTH, 0, HEIGHT), v8 = newV3(LENGTH, 0, -HEIGHT);

        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        if (renderTexture) {
            bindTexture(TEXTURE_PATH);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glColor3f(colorR, colorG, colorB);
        }
        if (ignoreLight) {
            GL11.glDisable(GL11.GL_LIGHTING);
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
        }

        GL11.glTranslatef((float) par2, (float) par4, (float) par6);

        GL11.glRotatef(90 + entity.rotationYaw, 0.0F, -1.0F, 0.0F); // ?
        GL11.glRotatef(-entity.rotationPitch, 0.0F, 0.0F, 1.0F); // 

        if (this.playerViewOptm) {
            boolean firstPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView == 0;
            if (firstPerson) {
                GL11.glTranslated(fpOffsetX, fpOffsetY, fpOffsetZ);
            } else {
                GL11.glTranslated(tpOffsetX, tpOffsetY, tpOffsetZ);
            }
        }

        t.startDrawingQuads();
        if (ignoreLight)
            t.setBrightness(15728880);

        RenderUtils.addVertex(v1, 0, 0);
        RenderUtils.addVertex(v2, 0, 1);
        RenderUtils.addVertex(v3, 1, 1);
        RenderUtils.addVertex(v4, 1, 0);

        RenderUtils.addVertex(v5, 0, 0);
        RenderUtils.addVertex(v6, 0, 1);
        RenderUtils.addVertex(v7, 1, 1);
        RenderUtils.addVertex(v8, 1, 0);

        t.draw();

        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
    }
    GL11.glPopMatrix();
}

From source file:cn.lambdalib.template.client.render.entity.RenderIcon.java

License:MIT License

@Override
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glDisable(GL11.GL_CULL_FACE);// www .  j  a  v  a2s . c  o m
    if (!hasLight)
        GL11.glDisable(GL11.GL_LIGHTING);
    //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glAlphaFunc(GL11.GL_GREATER, minTolerateAlpha);
    GL11.glPushMatrix();
    {
        GL11.glTranslatef((float) par2, (float) par4, (float) par6);
        GL11.glScalef(size, size, size);
        postTranslate(par1Entity);
        if (icon != null)
            RenderUtils.loadTexture(icon);

        Tessellator t = Tessellator.instance;
        this.func_77026_a(par1Entity, t);

    }
    GL11.glPopMatrix();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:cn.lambdalib.template.client.render.item.RenderModelItem.java

License:MIT License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    switch (type) {
    case EQUIPPED:
    case EQUIPPED_FIRST_PERSON:
        renderEquipped(item, (RenderBlocks) data[0], (EntityLivingBase) data[1], type);
        break;//from   www .  j av a2  s.c o  m
    case ENTITY:
        renderEntityItem((RenderBlocks) data[0], (EntityItem) data[1]);
        break;
    case INVENTORY:
        renderInventory();
        break;
    default:
        break;

    }
}

From source file:cn.lambdalib.template.client.render.item.RenderModelItem.java

License:MIT License

public void renderInventory() {

    GL11.glDisable(GL11.GL_CULL_FACE);//ww w.  j a v  a 2s  .  c o  m
    GL11.glPushMatrix();
    {

        RenderUtils.loadTexture(texturePath);

        GL11.glTranslated(8.0F + invOffset.x, 8.0F + invOffset.y, 0.0F);
        GL11.glScaled(16F * invScale, 16F * invScale, 16F * invScale);
        float rotation = 145F;
        if (inventorySpin)
            rotation = GameTimer.getAbsTime() / 100F;
        GL11.glRotatef(rotation, 0, 1, 0);
        this.doRotation(invRotation);
        GL11.glScalef(-1F, -1F, 1F);

        renderAtStdPosition();

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

From source file:cn.lambdalib.template.client.render.item.RenderModelItem.java

License:MIT License

protected void renderAtStdPosition(float i) {
    GL11.glScaled(scale, scale, scale);// w  w  w .  j a v  a2  s .  co  m
    GL11.glDisable(GL11.GL_CULL_FACE);
    this.doTransformation(stdOffset);
    GL11.glScalef(-1F, -1F, 1F);
    GL11.glRotated(stdRotation.yCoord + 180, 0.0F, 1.0F, 0.0F);
    GL11.glRotated(stdRotation.zCoord, 0.0F, 0.0F, 1.0F);
    GL11.glRotated(stdRotation.xCoord, 1.0F, 0.0F, 0.0F);

    model.render(null, 0.0625F, i);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:cn.lambdalib.util.client.auxgui.AuxGuiHandler.java

License:MIT License

@SubscribeEvent
public void drawHudEvent(RenderGameOverlayEvent event) {
    GL11.glDepthFunc(GL11.GL_ALWAYS);/*from   w w  w. j av a  2s  .com*/
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.pushTextureState();

    if (event.type == ElementType.EXPERIENCE) {
        Iterator<AuxGui> iter = auxGuiList.iterator();
        startIterating();
        while (iter.hasNext()) {
            AuxGui gui = iter.next();
            if (!gui.isDisposed()) {
                if (!gui.lastFrameActive)
                    gui.lastActivateTime = GameTimer.getTime();
                gui.draw(event.resolution);
                gui.lastFrameActive = true;
            }
        }
        endIterating();
    }

    RenderUtils.popTextureState();
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.lambdalib.util.client.HudUtils.java

License:MIT License

public static void colorRect(double x, double y, double width, double height) {
    boolean prev = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from w w w .j a  v a 2  s .  c o m
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();
    t.addVertex(x + 0, y + height, zLevel);
    t.addVertex(x + width, y + height, zLevel);
    t.addVertex(x + width, y + 0, zLevel);
    t.addVertex(x + 0, y + 0, zLevel);
    t.draw();

    if (prev)
        GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:cn.lambdalib.util.client.HudUtils.java

License:MIT License

public static void drawRectOutline(double x, double y, double w, double h, float lineWidth) {
    GL11.glLineWidth(lineWidth);// ww w .  j a  va 2s  . com
    Tessellator t = Tessellator.instance;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    t.startDrawing(GL11.GL_LINE_LOOP);
    double lw = lineWidth * 0.2;
    x -= lw;
    y -= lw;
    w += 2 * lw;
    h += 2 * lw;
    t.addVertex(x, y, zLevel);
    t.addVertex(x, y + h, zLevel);
    t.addVertex(x + w, y + h, zLevel);
    t.addVertex(x + w, y, zLevel);
    t.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:cn.lambdalib.util.client.HudUtils.java

License:MIT License

public static void drawHoveringText(List par1List, int x, int y, FontRenderer font, int width, int height) {
    if (!par1List.isEmpty()) {
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        RenderHelper.disableStandardItemLighting();
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        int k = 0;
        float zLevel = -90.0F;
        Iterator iterator = par1List.iterator();

        while (iterator.hasNext()) {
            String s = (String) iterator.next();
            int l = font.getStringWidth(s);

            if (l > k) {
                k = l;/*from   w  ww .  j av  a2 s . c o m*/
            }
        }

        int i1 = x + 12;
        int j1 = y - 12;
        int k1 = 8;

        if (par1List.size() > 1) {
            k1 += 2 + (par1List.size() - 1) * 10;
        }

        if (i1 + k > width) {
            i1 -= 28 + k;
        }

        if (j1 + k1 + 6 > height) {
            j1 = height - k1 - 6;
        }

        zLevel = 300.0F;
        int l1 = -267386864;
        drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1);
        drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1);
        drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1);
        drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1);
        drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1);
        int i2 = 1347420415;
        int j2 = (i2 & 16711422) >> 1 | i2 & -16777216;
        drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2);
        drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2);
        drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
        drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);

        for (int k2 = 0; k2 < par1List.size(); ++k2) {
            String s1 = (String) par1List.get(k2);
            font.drawStringWithShadow(s1, i1, j1, -1);

            if (k2 == 0) {
                j1 += 2;
            }

            j1 += 10;
        }

        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        RenderHelper.enableStandardItemLighting();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    }
}