Example usage for org.lwjgl.opengl GL11 glPopAttrib

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

Introduction

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

Prototype

public static native void glPopAttrib();

Source Link

Document

Resets the values of those state variables that were saved with the last #glPushAttrib PushAttrib .

Usage

From source file:mods.railcraft.client.render.RenderTESRSignals.java

License:Open Source License

private void renderPairs(TileEntity tile, double x, double y, double z, float f, AbstractPair pair,
        ColorProfile colorProfile) {/* w  w  w  .ja  va 2  s  .c om*/
    if (pair.getPairs().isEmpty()) {
        return;
    }
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glLineWidth(5F);

    GL11.glBegin(GL11.GL_LINES);
    for (WorldCoordinate target : pair.getPairs()) {
        int color = colorProfile.getColor(tile, pair.getCoords(), target);
        float c1 = (float) (color >> 16 & 255) / 255.0F;
        float c2 = (float) (color >> 8 & 255) / 255.0F;
        float c3 = (float) (color & 255) / 255.0F;
        GL11.glColor3f(c1, c2, c3);

        GL11.glVertex3f((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f);
        float tx = (float) x + target.x - tile.xCoord;
        float ty = (float) y + target.y - tile.yCoord;
        float tz = (float) z + target.z - tile.zCoord;
        GL11.glVertex3f(tx + 0.5f, ty + 0.5f, tz + 0.5f);
    }
    GL11.glEnd();

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:mods.railcraft.client.render.RenderTrackBuffer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float time) {
    if (tile instanceof TileTrack) {
        if (((TileTrack) tile).getTrackInstance() instanceof TrackBufferStop) {
            TrackBufferStop track = (TrackBufferStop) ((TileTrack) tile).getTrackInstance();
            GL11.glPushMatrix();/*  ww  w.  ja  v  a2 s .co m*/
            GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_CULL_FACE);
            GL11.glColor3f(1, 1, 1);
            GL11.glTranslatef((float) x, (float) y, (float) z);

            model.resetRotation();

            int meta = tile.getBlockMetadata();
            if (meta == 1) {
                model.rotateY((float) (Math.PI / 2.0));
            }

            if (meta == 0 != track.isReversed()) {
                model.rotateY((float) Math.PI);
            }

            bindTexture(TEXTURE);
            model.render(1f / 16f);
            GL11.glPopAttrib();
            GL11.glPopMatrix();
        }
    }
}

From source file:net.adam_keenan.voxel.hud.HUD.java

License:Creative Commons License

public static void drawCrosshairs() {

    float screenx = (float) Display.getWidth() / 2, screeny = (float) Display.getHeight() / 2;
    float x1, y1, x2, y2, width1 = 4, height1 = 20, width2 = height1, height2 = width1;
    x1 = screenx - width1 / 2;/*from   w w  w.ja v a2  s  .c  om*/
    y1 = screeny - height1 / 2;
    x2 = screenx - width2 / 2;
    y2 = screeny - height2 / 2;

    FloatBuffer perspectiveProjectionMatrix;
    FloatBuffer orthographicProjectionMatrix;
    perspectiveProjectionMatrix = BufferUtils.createFloatBuffer(16);
    orthographicProjectionMatrix = BufferUtils.createFloatBuffer(16);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, perspectiveProjectionMatrix);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, orthographicProjectionMatrix);
    //      GL11.glLoadMatrix(perspectiveProjectionMatrix);

    GL11.glMatrixMode(GL11.GL_PROJECTION); // For text drawing
    GL11.glLoadMatrix(orthographicProjectionMatrix);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glLoadIdentity(); // Clears matrix

    GL11.glColor4f(0, 0, 0, .5f);
    GL11.glRectf(x1, y1, x1 + width1, y1 + height1);
    GL11.glRectf(x2, y2, x2 + (width2 - width1) / 2, y2 + height2);
    GL11.glRectf(x2 + (width2 + width1) / 2, y2, x2 + width2, y2 + height2);

    GL11.glPopMatrix();
    GL11.glPopAttrib();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadMatrix(perspectiveProjectionMatrix);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

}

From source file:net.cortexmodders.lyoko.client.render.RenderUtil.java

License:MIT License

public static void alphaOff() {
    GL11.glPopAttrib();
    GL11.glPopAttrib();
}

From source file:net.malisis.core.client.gui.component.UIComponent.java

License:Open Source License

/**
 * Draws this {@link UIComponent} Called by {@link #parent} component.<br>
 * Will set the size of {@link #shape} according to the size of this <code>UIComponent</code><br>
 * Rendering is surrounded by glPushAttrib(GL_ALL_ATTRIB_BITS) so no state should bleed between components. Also, a draw() is triggered
 * between background and foreground.//from   w w  w. j a v a2  s .  c o m
 *
 * @param renderer the renderer
 * @param mouseX the mouse x
 * @param mouseY the mouse y
 * @param partialTick the partial tick
 */
public void draw(GuiRenderer renderer, int mouseX, int mouseY, float partialTick) {
    if (!isVisible())
        return;

    if (shape != null) {
        shape.resetState();
        shape.setSize(getWidth(), getHeight());
    }
    if (rp != null)
        rp.reset();

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    if (getAlpha() < 255) {
        GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);
        GL14.glBlendColor(1, 1, 1, (float) getAlpha() / 255);
    }

    //draw background
    renderer.currentComponent = this;
    drawBackground(renderer, mouseX, mouseY, partialTick);
    renderer.next();

    //draw foreground
    renderer.currentComponent = this;

    ClipArea area = this instanceof IClipable ? ((IClipable) this).getClipArea() : null;
    if (area != null)
        renderer.startClipping(area);

    //GL11.glColor4f(1, 1, 1, 0.5F);

    drawForeground(renderer, mouseX, mouseY, partialTick);

    if (area != null)
        renderer.endClipping(area);

    renderer.next();

    for (IControlComponent c : controlComponents)
        c.draw(renderer, mouseX, mouseY, partialTick);

    GL11.glPopAttrib();
}

From source file:net.malisis.core.client.gui.GuiRenderer.java

License:Open Source License

/**
 * Ends the clipping./*from  ww  w  . j  a  v a2 s.co m*/
 *
 * @param area the area
 */
public void endClipping(ClipArea area) {
    if (area.noClip || area.width() <= 0 || area.height() <= 0)
        return;

    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    GL11.glPopAttrib();
}

From source file:net.malisis.core.renderer.MalisisRenderer.java

License:Open Source License

/**
 * Cleans the current renderer state./*from  w w w .j  a  va  2s.  c  o m*/
 */
public void clean() {
    if (renderType == RenderType.ISBRH_WORLD) {
        tessellatorUnshift();
    } else if (renderType == RenderType.ISBRH_INVENTORY) {
        draw();
        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    } else if (renderType == RenderType.ITEM_INVENTORY) {
        draw();
        GL11.glPopAttrib();
    } else if (renderType == RenderType.TESR_WORLD) {
        draw();
        GL11.glPopMatrix();
        GL11.glPopAttrib();
    } else if (renderType == RenderType.WORLD_LAST) {
        draw();
        GL11.glPopMatrix();
        GL11.glPopAttrib();
    }
    reset();
}

From source file:net.mechanicalcat.pycode.gui.GuiTextArea.java

License:Open Source License

public void drawEditor() {
    String content = getString();

    // first up, determine the scroll offset
    int xoff = textXOffset / SCROLL_SCALE;
    int yoff = textYOffset / SCROLL_SCALE;
    if (yoff > 0) {
        yoff = 0;//from www.  ja  v  a2s. co m
        textYOffset = 0;
    } else {
        int totHeight = -this.fontRenderer.FONT_HEIGHT * this.lines.length;
        if (totHeight < height && yoff < totHeight + height) {
            yoff = totHeight + height;
            textYOffset = yoff * SCROLL_SCALE;
        }
    }
    if (xoff < 0) {
        xoff = 0;
        textXOffset = 0;
    } else {
        int maxWidth = 0;
        for (String line : this.lines) {
            int w = this.fontRenderer.getStringWidth(line);
            if (w > maxWidth)
                maxWidth = w;
        }
        if (maxWidth > width && xoff > maxWidth - width) {
            xoff = maxWidth - width;
            textXOffset = xoff * SCROLL_SCALE;
        }
    }

    // offset rendering by the scroll offset
    GlStateManager.pushMatrix();
    GlStateManager.translate(-xoff, yoff, 0);
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor(xScissor, yScissor, wScissor, hScissor);

    // draw cursor
    int cursorPos;
    if (this.cursorRow == this.lines.length) {
        cursorPos = 0; // current line is empty
    } else {
        cursorPos = this.fontRenderer
                .getStringWidth(this.lines[this.cursorRow].substring(0, this.cursorColumn));
    }
    int cursor_x = this.xPosition + cursorPos;
    int cursor_y = this.yPosition + this.cursorRow * this.fontRenderer.FONT_HEIGHT + 1;
    if (this.cursorCounter / 6 % 2 == 0) {
        this.fontRenderer.drawString("_", cursor_x, cursor_y, 0);
    } else {
        this.fontRenderer.drawString("_", cursor_x, cursor_y, 0x55000000);
    }

    // draw content
    int x = this.xPosition;
    int y = this.yPosition;
    for (String s : this.lines) {
        this.fontRenderer.drawString(s, x, y, 0);
        y += this.fontRenderer.FONT_HEIGHT;
    }

    // reset state
    GlStateManager.popMatrix();
    GL11.glPopAttrib();
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java

License:Open Source License

@SideOnly(Side.CLIENT)
@Override//from w ww  . j a  v  a 2 s . co  m
public void renderInventoryBlock(net.minecraft.block.Block block, int metadata, int modelId,
        RenderBlocks renderer) {
    Optional<ItemRenderer> opRenderer = this.dummy.components.getOp(ItemRenderer.class);
    if (opRenderer.isPresent()) {
        GL11.glPushAttrib(GL_TEXTURE_BIT);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glPushMatrix();
        Tessellator.instance.startDrawingQuads();
        BWModel model = new BWModel();
        opRenderer.get().onRender.accept(model);
        model.render();
        Tessellator.instance.draw();
        GL11.glPopMatrix();
        GL11.glPopAttrib();
    }
}

From source file:ocelot.mods.qp2.client.RenderRefinery.java

License:Open Source License

private void render(TileRefineryPlus tile, double x, double y, double z) {
    FluidStack liquid1 = null, liquid2 = null, liquidResult = null;

    float anim = 0;
    int angle = 0;
    ModelRenderer theMagnet = this.magnet[0];
    if (tile != null) {
        liquid1 = tile.src1;//w  w  w  .  jav a  2 s  . c  om
        liquid2 = tile.src2;
        liquidResult = tile.res;

        anim = tile.getAnimationStage();

        angle = 0;
        switch (tile.worldObj.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)) {
        case 2:
            angle = 90;
            break;
        case 3:
            angle = 270;
            break;
        case 4:
            angle = 180;
            break;
        case 5:
            angle = 0;
            break;
        }

        if (tile.animationSpeed <= 1) {
            theMagnet = this.magnet[0];
        } else if (tile.animationSpeed <= 2.5) {
            theMagnet = this.magnet[1];
        } else if (tile.animationSpeed <= 4.5) {
            theMagnet = this.magnet[2];
        } else {
            theMagnet = this.magnet[3];
        }
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
    GL11.glScalef(0.99F, 0.99F, 0.99F);

    GL11.glRotatef(angle, 0, 1, 0);

    bindTexture(TEXTURE);

    GL11.glPushMatrix();
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    GL11.glTranslatef(-4F * pixel, 0, -4F * pixel);
    this.tank.render(pixel);
    GL11.glTranslatef(4F * pixel, 0, 4F * pixel);

    GL11.glTranslatef(-4F * pixel, 0, 4F * pixel);
    this.tank.render(pixel);
    GL11.glTranslatef(4F * pixel, 0, -4F * pixel);

    GL11.glTranslatef(4F * pixel, 0, 0);
    this.tank.render(pixel);
    GL11.glTranslatef(-4F * pixel, 0, 0);
    GL11.glPopMatrix();

    float trans1, trans2;

    if (anim <= 100) {
        trans1 = 12F * pixel * anim / 100F;
        trans2 = 0;
    } else if (anim <= 200) {
        trans1 = 12F * pixel - (12F * pixel * (anim - 100F) / 100F);
        trans2 = 12F * pixel * (anim - 100F) / 100F;
    } else {
        trans1 = 12F * pixel * (anim - 200F) / 100F;
        trans2 = 12F * pixel - (12F * pixel * (anim - 200F) / 100F);
    }

    GL11.glPushMatrix();
    GL11.glScalef(0.99F, 0.99F, 0.99F);
    GL11.glTranslatef(-0.51F, trans1 - 0.5F, -0.5F);
    theMagnet.render(pixel);
    GL11.glPopMatrix();

    GL11.glPushMatrix();
    GL11.glScalef(0.99F, 0.99F, 0.99F);
    GL11.glTranslatef(-0.51F, trans2 - 0.5F, 12F * pixel - 0.5F);
    theMagnet.render(pixel);
    GL11.glPopMatrix();

    if (tile != null) {
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        GL11.glScalef(0.5F, 1, 0.5F);

        if (liquid1 != null && liquid1.amount > 0) {
            int[] list1 = FluidRenderer.getFluidDisplayLists(liquid1, tile.worldObj, false);

            if (list1 != null) {
                bindTexture(FluidRenderer.getFluidSheet(liquid1));
                FluidRenderer.setColorForFluidStack(liquid1);
                GL11.glCallList(
                        list1[(int) (liquid1.amount / (float) tile.buf * (FluidRenderer.DISPLAY_STAGES - 1))]);
            }
        }

        if (liquid2 != null && liquid2.amount > 0) {
            int[] list2 = FluidRenderer.getFluidDisplayLists(liquid2, tile.worldObj, false);

            if (list2 != null) {
                GL11.glPushMatrix();
                GL11.glTranslatef(0, 0, 1);
                bindTexture(FluidRenderer.getFluidSheet(liquid2));
                FluidRenderer.setColorForFluidStack(liquid2);
                GL11.glCallList(
                        list2[(int) (liquid2.amount / (float) tile.buf * (FluidRenderer.DISPLAY_STAGES - 1))]);
                GL11.glPopMatrix();
            }
        }

        if (liquidResult != null && liquidResult.amount > 0) {
            int[] list3 = FluidRenderer.getFluidDisplayLists(liquidResult, tile.worldObj, false);

            if (list3 != null) {
                GL11.glPushMatrix();
                GL11.glTranslatef(1, 0, 0.5F);
                bindTexture(FluidRenderer.getFluidSheet(liquidResult));
                FluidRenderer.setColorForFluidStack(liquidResult);
                GL11.glCallList(list3[(int) (liquidResult.amount / (float) tile.buf
                        * (FluidRenderer.DISPLAY_STAGES - 1))]);
                GL11.glPopMatrix();
            }
        }
        GL11.glPopAttrib();
    }

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}