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:cn.lambdalib.util.deprecated.Mesh.java

License:MIT License

private void redraw(Material mat, boolean execute) {
    if (doesBuffer) {
        if (listID == -1) {
            listID = GL11.glGenLists(1);
            GL11.glNewList(listID, execute ? GL11.GL_COMPILE_AND_EXECUTE : GL11.GL_COMPILE);
        }// www. j a v a2 s.  co  m
    }

    mat.onRenderStage(RenderStage.START);
    GL11.glPushMatrix();

    mat.onRenderStage(RenderStage.BEFORE_TESSELLATE);
    Tessellator t = Tessellator.instance;
    t.startDrawing(GL11.GL_TRIANGLES);
    mat.onRenderStage(RenderStage.START_TESSELLATE);

    if (uvs != null) {
        if (triangles != null) {
            for (int i : triangles) {
                double[] vert = vertices[i];
                double[] uv = uvs[i];
                if (normals != null) {
                    t.setNormal(normals[i][0], normals[i][1], normals[i][2]);
                }
                t.addVertexWithUV(vert[0], vert[1], vert[2], uv[0], uv[1]);

            }
        }
    } else {
        if (triangles != null) {
            for (int i : triangles) {
                double[] vert = vertices[i];
                if (normals != null) {
                    t.setNormal(normals[i][0], normals[i][1], normals[i][2]);
                }
                t.addVertex(vert[0], vert[1], vert[2]);
            }
        }
    }
    t.draw();

    GL11.glPopMatrix();
    mat.onRenderStage(RenderStage.END);

    for (Mesh m : this.sub) {
        m.draw(mat);
    }

    if (doesBuffer) {
        GL11.glEndList();
    }
}

From source file:cn.lambdalib.vis.model.PartedModel.java

License:MIT License

public void draw() {
    if (!doesDraw)
        return;/*from   w  ww.  j a  v a2s. c  om*/

    GL11.glPushMatrix();

    transform.doTransform();
    for (IModel model : childs.values())
        model.draw();

    handleDraw();

    GL11.glPopMatrix();
}

From source file:cn.liutils.api.client.render.RendererSidedCube.java

License:Open Source License

public void doRender(TileEntity tileEntity, double x, double y, double z, float f) {
    Tessellator t = Tessellator.instance;
    int var5 = tileEntity.getBlockMetadata();
    block.setBlockBoundsBasedOnState(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord,
            tileEntity.zCoord);// ww  w  . j a va  2 s . c o  m
    setBound(block);

    Vec3 v1, v2, v3, v4, v5, v6, v7, v8;
    v1 = RenderUtils.newV3(minX, minY, minZ);
    v2 = RenderUtils.newV3(minX, minY, maxZ);
    v3 = RenderUtils.newV3(minX, maxY, maxZ);
    v4 = RenderUtils.newV3(minX, maxY, minZ);

    v5 = RenderUtils.newV3(maxX, minY, minZ);
    v6 = RenderUtils.newV3(maxX, minY, maxZ);
    v7 = RenderUtils.newV3(maxX, maxY, maxZ);
    v8 = RenderUtils.newV3(maxX, maxY, minZ);

    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z);

    RenderUtils.loadTexture(getTexture(tileEntity, 4, var5));
    t.startDrawingQuads();
    t.setNormal(-1, 0, 0);
    addVertex(v1, 0, 1);
    addVertex(v2, 1, 1);
    addVertex(v3, 1, 0);
    addVertex(v4, 0, 0);
    t.draw();

    RenderUtils.loadTexture(getTexture(tileEntity, 5, var5));
    t.startDrawingQuads();
    t.setNormal(1, 0, 0);
    addVertex(v8, 1, 0);
    addVertex(v7, 0, 0);
    addVertex(v6, 0, 1);
    addVertex(v5, 1, 1);
    t.draw();

    RenderUtils.loadTexture(getTexture(tileEntity, 2, var5));
    t.startDrawingQuads();
    t.setNormal(0, 0, -1);
    addVertex(v4, 1, 0);
    addVertex(v8, 0, 0);
    addVertex(v5, 0, 1);
    addVertex(v1, 1, 1);
    t.draw();

    RenderUtils.loadTexture(getTexture(tileEntity, 3, var5));
    t.startDrawingQuads();
    t.setNormal(0, 0, 1);
    addVertex(v3, 0, 0);
    addVertex(v2, 0, 1);
    addVertex(v6, 1, 1);
    addVertex(v7, 1, 0);
    t.draw();

    RenderUtils.loadTexture(getTexture(tileEntity, 1, var5));
    t.startDrawingQuads();
    t.setNormal(0, 1, 0);
    addVertex(v3, 0, 0);
    addVertex(v7, 1, 0);
    addVertex(v8, 1, 1);
    addVertex(v4, 0, 1);
    t.draw();

    RenderUtils.loadTexture(getTexture(tileEntity, 0, var5));
    t.startDrawingQuads();
    t.setNormal(0, -1, 0);
    addVertex(v1, 0, 1);
    addVertex(v5, 1, 1);
    addVertex(v6, 1, 0);
    addVertex(v2, 0, 0);
    t.draw();

    GL11.glPopMatrix();
}

From source file:cn.liutils.api.client.render.RenderIcon.java

License:Open Source License

@Override
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
    GL11.glEnable(GL11.GL_BLEND);//from w w  w .j av  a  2  s .  c  o m
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glDisable(GL11.GL_CULL_FACE);
    if (!enableDepth)
        GL11.glDisable(GL11.GL_DEPTH_TEST);
    if (!hasLight)
        GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    {
        GL11.glTranslatef((float) par2, (float) par4, (float) par6);
        GL11.glScalef(size, size, size);

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

        if (icon != null)
            RenderUtils.loadTexture(icon);

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

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

From source file:cn.liutils.api.draw.DrawObject.java

License:Open Source License

public void draw() {
    post(EventType.PRE_DRAW);/*from   w w  w.ja v a 2 s  .  c  o m*/
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    {
        post(EventType.PRE_TRANSFORM);
        post(EventType.POST_TRANSFORM);
        post(EventType.PRE_TESS);
        post(EventType.DO_TESS);
        post(EventType.POST_TESS);
    }
    GL11.glPopMatrix();
    post(EventType.POST_DRAW);
}

From source file:cn.liutils.api.draw.DrawObjectList.java

License:Open Source License

@Override
public void draw() {
    postAll(EventType.PRE_DRAW);//  w ww  .  j  a va2  s  .  co  m
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    {
        postAll(EventType.PRE_TRANSFORM);
        postAll(EventType.POST_TRANSFORM);
        postAll(EventType.PRE_TESS);
        postAll(EventType.DO_TESS);
        postAll(EventType.POST_TESS);
    }
    GL11.glPopMatrix();
    postAll(EventType.POST_DRAW);
}

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

License:Open Source License

private void drawTraverse(double mx, double my, WidgetNode cur, Iterable<WidgetNode> set, WidgetNode top) {
    if (cur != null && cur.widget.doesDraw) {
        GL11.glPushMatrix();
        GL11.glTranslated(cur.x, cur.y, 0);
        GL11.glScaled(cur.scale, cur.scale, 1);
        //System.out.println(cur.widget + " " + DebugUtils.formatArray(cur.x, cur.y, cur.scale));
        GL11.glColor4d(1, 1, 1, 1); //Force restore color for any widget
        cur.widget.draw((mx - cur.x) / cur.scale, (my - cur.y) / cur.scale, cur == top);
        GL11.glPopMatrix();//  w ww  .j  av  a 2 s .c om
    }

    if (cur == null || cur.widget.doesDraw) {
        if (cur != null)
            cur.iterating = true;
        Iterator<WidgetNode> iter = set.iterator();
        while (iter.hasNext()) {
            WidgetNode wn = iter.next();
            drawTraverse(mx, my, wn, wn, top);
        }
        if (cur != null)
            cur.iterating = false;
    }
}

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

License:Open Source License

@Override
public void drawScreen(int mx, int my, float w) {
    gui.resize(width, height);/*  w w  w. java2  s .com*/
    if (drawBack)
        this.drawDefaultBackground();
    GL11.glPushMatrix();
    {
        GL11.glTranslated(0, 0, 100);
        gui.draw(mx, my);
    }
    GL11.glPopMatrix();
}

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

License:Open Source License

/**
 * Should be called at this widget's draw() function.
 *//*from  w ww  .  j a  v  a  2 s.  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.api.render.model.ModelBaseCustom.java

License:Open Source License

/**
 * Sets the models various rotation angles then renders the model.
 *//*from  www  . ja  v  a 2s .  c om*/
@Override
public final void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6,
        float par7) {
    GL11.glPushMatrix();
    {
        GL11.glTranslated(offset.xCoord, offset.yCoord, offset.zCoord);
        GL11.glScalef(scale, -scale, scale);
        doRenderModel(par3, par5);
    }
    GL11.glPopMatrix();
}