Example usage for org.lwjgl.opengl GL11 glPushMatrix

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

Introduction

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

Prototype

public static native void glPushMatrix();

Source Link

Document

Pushes the current matrix stack down by one, duplicating the current matrix in both the top of the stack and the entry below it.

Usage

From source file:a1.Main.java

License:Open Source License

private void render() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    GL11.glLoadIdentity();//from   www .  ja  va 2s.  c o  m

    GL11.glPushMatrix();
    GUI.getInstance().Render();
    GL11.glPopMatrix();

    // render debug info
    if (Config.debug)
        DrawDebug();

    fps_counter++;
    if (System.currentTimeMillis() - last_fps_tick > 1000) {
        last_fps_tick = System.currentTimeMillis();
        FPS = fps_counter;
        fps_counter = 0;
    }

}

From source file:a1.ObjExp.java

License:Open Source License

@SuppressWarnings("AccessStaticViaInstance")
public void render(Coord dc) {
    double t = (float) life_time / (float) MAX_LIFE_TIME;
    int a = FlyParam.GetAlpha(t);

    String s1 = Integer.toString(combat);
    String s2 = Integer.toString(industry);
    String s3 = Integer.toString(nature);
    String ss = "+" + s1 + "/" + s2 + "/" + s3;
    String s;// w  ww  .j a va 2 s  .  co  m
    int tw = Render2D.GetTextWidth("", ss);
    int x = dc.x - tw / 2 - 7;
    int y = (int) (dc.y - (FlyParam.GetY(t) + 35) - 38 * GUI.map.scale);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    s = "+";
    Render2D.Text("default", x, y, s, new Color(255, 255, 255, a));
    x += Render2D.GetTextWidth("", s) + 2;
    s = s1;
    Render2D.Text("default", x, y, s, new Color(255, 40, 40, a));
    x += Render2D.GetTextWidth("", s) + 4;
    s = "/";
    Render2D.Text("default", x, y, s, new Color(255, 255, 255, a));
    x += Render2D.GetTextWidth("", s) + 2;
    s = s2;
    Render2D.Text("default", x, y, s, new Color(100, 209, 232, a));
    x += Render2D.GetTextWidth("", s) + 4;
    s = "/";
    Render2D.Text("default", x, y, s, new Color(255, 255, 255, a));
    x += Render2D.GetTextWidth("", s) + 2;
    s = s3;
    Render2D.Text("default", x, y, s, new Color(40, 255, 40, a));
    GL11.glPopMatrix();
}

From source file:additionalpipes.client.gui.GuiTeleportManager.java

License:Minecraft Mod Public

private void renderPipeMap(int map, MapData mapData) {
    RenderHelper.disableStandardItemLighting();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_DEPTH_TEST);//from ww  w.  j  a  v  a2s .  co  m
    mc.renderEngine.bindTexture(MAP_TEXTURE);

    GL11.glPushMatrix();
    Tessellator var4 = Tessellator.instance;
    var4.startDrawingQuads();
    byte var5 = 7;
    var4.addVertexWithUV(0 - var5, 128 + var5, 0.0D, 0.0D, 1.0D);
    var4.addVertexWithUV(128 + var5, 128 + var5, 0.0D, 1.0D, 1.0D);
    var4.addVertexWithUV(128 + var5, 0 - var5, 0.0D, 1.0D, 0.0D);
    var4.addVertexWithUV(0 - var5, 0 - var5, 0.0D, 0.0D, 0.0D);
    var4.draw();

    mapRenderer.renderMap(mc.thePlayer, mc.renderEngine, mapData);

    PropertyIntArray pipeArr = (PropertyIntArray) clientProps.propPipes.value.get(PropertyInteger.create(map));
    int[] pipes = pipeArr != null ? pipeArr.value : ArrayUtils.EMPTY_INT_ARRAY;
    for (int p = 0; p < pipes.length / 3; p++) {
        int centerX = pipes[p * 3 + 1];
        int centerZ = pipes[p * 3 + 2];
        GL11.glPushMatrix();
        GL11.glTranslatef(centerX / 2.0F + 64.0F - 4, centerZ / 2.0F + 64.0F - 4, -0.02F);
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.renderEngine,
                new ItemStack(getTeleportPipe(PipeType.values()[pipes[p * 3]]), 1), 0, 0);
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
}

From source file:additionalpipes.client.gui.GuiTeleportManager.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    super.drawGuiContainerForegroundLayer(mouseX, mouseY);

    float scrollPercent = scrollLine / (float) getScrollMax();
    int scrollBarLeft = guiLeft + xSize - 20;
    int scrollBarTop = guiTop + 18;
    int scrollBarBottom = scrollBarTop + 113;
    boolean isClicking = Mouse.isButtonDown(0);
    if (!wasClicking && isClicking && mouseX >= scrollBarLeft && mouseX < scrollBarLeft + 20
            && mouseY >= scrollBarTop && mouseY < scrollBarBottom) {
        isScrolling = needsScrollBars();
    }//  w  w  w. ja  v a2s.c o  m
    if (!isClicking) {
        isScrolling = false;
    }
    wasClicking = isClicking;
    if (isScrolling) {
        scrollPercent = (mouseY - scrollBarTop - 7.5F) / (scrollBarBottom - scrollBarTop - 20.0F);
        if (scrollPercent < 0.0F) {
            scrollPercent = 0.0F;
        } else if (scrollPercent > 1.0F) {
            scrollPercent = 1.0F;
        }
        scrollLine = (int) (scrollPercent * getScrollMax() + 0.5D);
        validateScrollLine();
    }

    fontRenderer.drawString(StringUtils.localize("container.teleportManager"), 8, 6,
            clientProps.propIsPublic.value ? 0x0000FF : 0x404040);
    fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 130, 0x404040);

    RenderHelper.disableStandardItemLighting();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(CREATIVE_TEXTURE);
    drawTexturedModalRect(xSize - 20, 18 + (int) (93 * scrollPercent), 232 + (needsScrollBars() ? 0 : 12), 0,
            12, 15);

    theMap = -1;
    int[] maps = clientProps.propMaps.value;
    if (maps.length == 0) {
        if (mouseX >= guiLeft + 8 && mouseX < guiLeft + 8 + 36 * MAPS_ROW && mouseY >= guiTop + 18
                && mouseY < guiTop + 18 + 36 * MAPS_COL) {
            String text = StringUtils
                    .localize(AdditionalPipes.disableLinkingUsage ? "gui.map.emptyHint.position"
                            : "gui.map.emptyHint.link");
            int width = fontRenderer.getStringWidth(text);
            GL11.glPushMatrix();
            GL11.glTranslatef(-guiLeft, -guiTop, 0);
            drawCreativeTabHoveringText(text, mouseX - 12 - width / 2, mouseY - 4);
            GL11.glPopMatrix();
        }
    } else if (currentMap == -1) {
        ItemStack mapStack = new ItemStack(Item.map, 1, 0);
        for (int i = 0; i < MAPS_COL; i++) {
            for (int j = 0; j < MAPS_ROW; j++) {
                int index = j + (scrollLine + i) * MAPS_ROW;
                if (index < maps.length) {
                    mapStack.setItemDamage(maps[index]);
                    MapData mapData = Item.map.getMapData(mapStack, mc.theWorld);
                    if (mapData != null) {
                        int x = 10 + j * 36;
                        int y = 20 + i * 36;
                        GL11.glPushMatrix();
                        GL11.glTranslatef(x, y, 0.0F);
                        GL11.glScalef(0.25F, 0.25F, 0.25F);
                        renderPipeMap(maps[index], mapData);
                        GL11.glPopMatrix();
                    }
                }
            }
        }
        int index = getMapIndexAtPos(mouseX, mouseY);
        if (index >= 0 && index < maps.length) {
            theMap = index;
            mapStack.setItemDamage(maps[index]);
            drawItemStackTooltip(mapStack, mouseX - guiLeft + 8, mouseY - guiTop + 8);
        }
    } else {
        MapData mapData = Item.map.getMapData(new ItemStack(Item.map, 1, maps[currentMap]), mc.theWorld);
        if (mapData != null) {
            GL11.glPushMatrix();
            GL11.glTranslatef(7, guiTop, 0.0F);
            GL11.glScalef(1.25F, 1.25F, 1.25F);
            renderPipeMap(maps[currentMap], mapData);
            GL11.glPopMatrix();
        }
    }
    RenderHelper.enableGUIStandardItemLighting();
}

From source file:adrianton.gloptat.plotter.Displayer.java

License:Open Source License

private void box() {
    float spx = -rezx / 2f;
    float spy = -rezy / 2f;
    float epx = spx + rezx;
    float epy = spy + rezy;

    GL11.glPushMatrix();
    GL11.glTranslatef(0, 0, (float) (minc + (maxc - minc) / 2));
    GL11.glScalef(rezx / 2f, rezy / 2f, (float) (maxc - minc) / 2f);
    Box.call();//from w  w  w .  j a  v a2 s  . com
    GL11.glPopMatrix();
}

From source file:adrianton.gloptat.plotter.Displayer.java

License:Open Source License

private void pointers() {
    if (pointers != null) {
        float spx = -rezx / 2f;
        float spy = -rezy / 2f;
        float tmpx, tmpy;
        float rapx, rapy;
        int tmpi, tmpj;

        rapx = rezx / (float) (dom.d[0].r - dom.d[0].l);
        rapy = rezy / (float) (dom.d[1].r - dom.d[1].l);

        int i;//from  w ww.j  a  va 2 s  .  c o m
        for (i = 0; i < pointers.length; i++) {
            tmpx = spx + (float) (pointers[i][0] - dom.d[0].l) * rapx;
            tmpy = spy + (float) (pointers[i][1] - dom.d[1].l) * rapy;

            tmpi = (int) ((pointers[i][0] - dom.d[0].l) * rapx); // should interpolate
            tmpj = (int) ((pointers[i][1] - dom.d[1].l) * rapy);

            tmpi = Math.min(Math.max(0, tmpi), rezx - 1);
            tmpj = Math.min(Math.max(0, tmpj), rezy - 1);

            if (dom.in(pointers[i])) {
                GL11.glPushMatrix();
                GL11.glTranslatef(tmpx, tmpy, (float) (val[tmpi][tmpj]));
                GL11.glScaled(1.1, 1.1, 0.5);
                Pointer.call();
                GL11.glPopMatrix();
            }
        }
    }
}

From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java

License:Minecraft Mod Public

private void renderItem3D(ItemRenderType type, ItemStack itemStack, Object... data) {
    TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine;
    Tessellator tessellator = Tessellator.instance;

    if (this.shouldRenderOverlay(itemStack)) {
        // render colored overlay
        renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
        this.setColorByItemStack(itemStack);
        Icon icon = this.getIcon(itemStack, 0);
        ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
                icon.getIconWidth(), icon.getIconHeight(), 0.0625F);

        // render glint
        if (itemStack.hasEffect(0)) {
            renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT);

            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glMatrixMode(GL11.GL_TEXTURE);

            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);

            // first pass
            GL11.glPushMatrix();
            GL11.glScalef(0.125F, 0.125F, 0.125F);
            float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
            GL11.glTranslatef(f9, 0.0F, 0.0F);
            GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
            GL11.glPopMatrix();//from ww  w  .j  av  a2 s. c  o m

            // second pass
            GL11.glPushMatrix();
            GL11.glScalef(0.125F, 0.125F, 0.125F);
            f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
            GL11.glTranslatef(-f9, 0.0F, 0.0F);
            GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
            GL11.glPopMatrix();

            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    // render uncolored icon
    renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    Icon icon = this.getIcon(itemStack, 1);
    ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
            icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
}

From source file:akarnokd.opengl.experiment.Planet.java

License:Apache License

/** Draw with full position and rotation information. */
public void drawFull() {
    GL11.glPushMatrix();
    GL11.glTranslatef(x, y, z);/*from   w w w .  j  a v a2 s.  co m*/
    GL11.glRotatef(rotate, 0, 0, 1);
    draw();
    GL11.glPopMatrix();
}

From source file:akarnokd.opengl.experiment.Planet.java

License:Apache License

public void drawFull(boolean forSelect) {
    GL11.glPushMatrix();
    GL11.glTranslatef(x, y, z);
    GL11.glRotatef(rotate, 0, 0, 1);
    draw(forSelect);
    GL11.glPopMatrix();
}

From source file:akarnokd.opengl.experiment.Planet.java

License:Apache License

public void drawWireframe() {
    GL11.glPushMatrix();
    GL11.glTranslatef(x, y, z);
    GL11.glRotatef(rotate, 0, 0, 1);

    GL11.glCallList(wireframe);

    GL11.glPopMatrix();
}