Example usage for org.lwjgl.opengl GL11 glDisable

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

Introduction

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

Prototype

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

Source Link

Document

Disables the specified OpenGL state.

Usage

From source file:cn.liutils.api.gui.LIGui.java

License:Open Source License

/**
 * Go down the hierarchy tree and draw each widget node.
 *//* w  ww.  jav a  2s  . c om*/
public void draw(double mx, double my) {
    frameUpdate();
    updateMouse(mx, my);
    iterating = true;
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDepthFunc(GL11.GL_ALWAYS);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDepthMask(false);
    drawTraverse(mx, my, null, this, getTopNode(mx, my));
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    iterating = false;
}

From source file:cn.liutils.api.gui.Widget.java

License:Open Source License

/**
 * Should be called at this widget's draw() function.
 *//*ww w.  jav a2s  .  c  o m*/
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//w ww .ja  v a  2s . c om
        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.component.Tint.java

License:Open Source License

public Tint() {
    super("Tint");

    addEventHandler(new FrameEventHandler() {
        @Override//w  w w  . j  a va 2 s. com
        public void handleEvent(Widget w, FrameEvent event) {
            if (affectTexture) {
                DrawTexture dt = DrawTexture.get(w);
                if (dt != null) {
                    dt.color = event.hovering ? hoverColor : idleColor;
                }
            } else {
                if (event.hovering)
                    hoverColor.bind();
                else
                    idleColor.bind();

                GL11.glDisable(GL11.GL_ALPHA_TEST);
                HudUtils.colorRect(0, 0, w.transform.width, w.transform.height);
                //GL11.glEnable(GL11.GL_ALPHA_TEST);
            }
        }
    });
}

From source file:cn.liutils.cgui.gui.LIGui.java

License:Open Source License

/**
 * Go down the hierarchy tree and draw each widget node.
 *//*from  w  w w.  j a v a  2 s  . c  o m*/
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);/*w ww. j  av a  2s  .  co  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  w w w.  jav a  2s. c o  m*/
    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);
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();/* ww  w .  ja va2  s .  c  om*/
    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 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);
    t.startDrawingQuads();//ww  w. ja v a  2s.  c  o  m
    {
        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  .j av  a 2s  . c  o m
            }
        }

        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);
    }
}