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.liutils.api.gui.Widget.java

License:Open Source License

/**
 * Should be called at this widget's draw() function.
 *//*w  w w .  ja  va  2  s  .  com*/
protected void drawBlackout() {

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(1, 0, 1, 0);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    GL11.glColor4d(0, 0, 0, 0.6);
    HudUtils.setZLevel(-1);
    HudUtils.drawModalRect(0, 0, 1, 1);

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    RenderUtils.bindIdentity();

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:cn.liutils.cgui.gui.component.ProgressBar.java

License:Open Source License

public ProgressBar() {
    super("ProgressBar");
    this.addEventHandler(new FrameEventHandler() {

        @Override//  www .  j a  va2 s  . com
        public void handleEvent(Widget wi, FrameEvent event) {

            if (illustrating) {
                progress = 0.5 * (1 + Math.sin(GameTimer.getAbsTime() / 1000.0));
            }

            {
                long time = GameTimer.getAbsTime();
                if (lastDrawTime == 0)
                    lastDrawTime = time;

                double dt = Math.min((time - lastDrawTime) * 0.001, 10); //convert to seconds

                if (progressDisplay == -1) {
                    progressDisplay = progress;
                } else {
                    //Buffering
                    double delta = progress - progressDisplay;
                    double sgn = Math.signum(delta);
                    delta = Math.min(Math.abs(delta), dt * maxDelta);
                    progressDisplay += sgn * delta;
                }

                { //Fluctuation
                    double accel = (rand.nextDouble() - 0.5) * maxFluctSpeed;
                    curSpeed += accel;
                    curSpeed = Math.max(-maxFluctSpeed, Math.min(curSpeed, maxFluctSpeed));
                    curFluct += curSpeed * dt;
                    curFluct = Math.max(-0.5 * fluctRegion, Math.min(curFluct, 0.5 * fluctRegion));
                }

                lastDrawTime = time;
            }

            {
                double disp;
                if (progressDisplay == 0) {
                    disp = 0;
                } else if (progressDisplay == 1) {
                    disp = 1;
                } else {
                    disp = Math.max(0, Math.min(progressDisplay + curFluct, 1.0));
                }

                //System.out.println(progressDisplay + " " + curFluct + " " + disp);
                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.liutils.cgui.gui.LIGui.java

License:Open Source License

/**
 * Go down the hierarchy tree and draw each widget node.
 *///w ww . j a  va2 s .  c om
public void draw(double mx, double my) {
    frameUpdate();
    updateMouse(mx, my);

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

    drawTraverse(mx, my, null, this, getTopWidget(mx, my));

    GL11.glEnable(GL11.GL_ALPHA_TEST);
}

From source file:cn.liutils.cgui.loader.ui.Window.java

License:Open Source License

protected void drawSplitLine(double y) {
    Tessellator t = Tessellator.instance;
    GuiEdit.bindColor(3);//from ww w.j a  va  2 s.c  o m
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glLineWidth(1.5f);
    t.startDrawing(GL11.GL_LINES);
    t.addVertex(0, y, -90);
    t.addVertex(transform.width, y, -90);
    t.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:cn.liutils.core.event.LIClientEvents.java

License:Open Source License

@SubscribeEvent
public void drawHudEvent(RenderGameOverlayEvent event) {
    GL11.glDepthFunc(GL11.GL_ALWAYS);//from  ww  w .java 2 s . com
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    if (event.type == ElementType.CROSSHAIRS) {
        for (AuxGui gui : auxGuiList) {
            if (gui.isOpen())
                gui.draw(event.resolution);
        }
    }
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

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

License:Open Source License

public static void colorRect(double x, double y, double width, double height) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//w w w . j  av  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();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:cn.liutils.util.helper.Font.java

License:Open Source License

/**
 * Draw a string with alignment.//from   w  w w  .j  a v  a  2 s. c  o  m
 * @param str
 * @param x
 * @param y
 * @param size
 * @param color
 * @param align
 */
public void draw(String str, double x, double y, double size, int color, Align align) {
    GL11.glEnable(GL11.GL_BLEND);
    //GL11.glDepthMask(false);
    double scale = size / mcFont().FONT_HEIGHT;
    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, 0);
        GL11.glScaled(scale, scale, 1);
        String[] ss = str.split("\n");
        for (int i = 0; i < ss.length; ++i) {
            GL11.glPushMatrix();
            {
                double dy = i * mcFont().FONT_HEIGHT;
                GL11.glTranslated(0, dy, 0);
                drawSingleLine(ss[i], color, align);
            }
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
}

From source file:cn.liutils.util.HudUtils.java

License:Open Source License

public static void drawModalRect(double x, double y, double width, double height) {

    double f = SCALE_X;
    double f1 = SCALE_Y;
    Tessellator t = Tessellator.instance;
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*  w  w  w .ja  v a2 s .  c om*/
    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();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:cn.liutils.util.HudUtils.java

License:Open Source License

public static void drawHoveringText(List par1List, int par2, int par3, 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;/* w w  w  .ja  v a 2s .  c om*/
            }
        }

        int i1 = par2 + 12;
        int j1 = par3 - 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);
    }
}

From source file:cn.liutils.util.HudUtils.java

License:Open Source License

public static void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) {
    float f = (par5 >> 24 & 255) / 255.0F;
    float f1 = (par5 >> 16 & 255) / 255.0F;
    float f2 = (par5 >> 8 & 255) / 255.0F;
    float f3 = (par5 & 255) / 255.0F;
    float f4 = (par6 >> 24 & 255) / 255.0F;
    float f5 = (par6 >> 16 & 255) / 255.0F;
    float f6 = (par6 >> 8 & 255) / 255.0F;
    float f7 = (par6 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);//w w w  . j  a  v  a 2s .  c o m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();
    t.setColorRGBA_F(f1, f2, f3, f);
    t.addVertex(par3, par2, -90D);
    t.addVertex(par1, par2, -90D);
    t.setColorRGBA_F(f5, f6, f7, f4);
    t.addVertex(par1, par4, -90D);
    t.addVertex(par3, par4, -90D);
    t.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}