Example usage for org.lwjgl.opengl GL11 glPopMatrix

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

Introduction

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

Prototype

public static native void glPopMatrix();

Source Link

Document

Pops the top entry off the current matrix stack, replacing the current matrix with the matrix that was the second entry in the stack.

Usage

From source file:com.flaiker.geometri.tileentities.TileEntityMathRenderer.java

License:MIT License

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
    TileEntityMath myte = ((TileEntityMath) te);

    model.prepareForRender(myte.getCoordinatePairs());

    TextureManager tm = Minecraft.getMinecraft().getTextureManager();
    tm.bindTexture(new ResourceLocation(Geometri.MODID, "textures/blocks/testBlock.png"));

    GL11.glPushMatrix();//w w w .  j av  a  2 s.  c o  m

    GL11.glTranslatef((float) x, (float) y, (float) z);

    model.render();

    GL11.glPopMatrix();
}

From source file:com.fr3gu.letsmod.client.RenderSpaceship.java

License:LGPL

public void renderSpaceship(EntitySpaceship spaceship, double x, double y, double z, float yaw,
        float partialTickTime) {
    GL11.glPushMatrix();/*from  w  w w .  j ava 2s . c o  m*/
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glRotatef(180.0F - yaw, 0.0F, 1.0F, 0.0F);
    GL11.glScaled(-1.0F, -1.0F, 1.0F);

    func_110777_b(spaceship);

    model.render(spaceship, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

    GL11.glPopMatrix();
}

From source file:com.freyja.FES.client.models.ModelInjector.java

License:LGPL

public void render(RoutingEntity te, double x, double y, double z) {
    GL11.glPushMatrix();//from  w w w  . java2  s  .  c o m

    GL11.glTranslatef((float) x + 0.5f, (float) y, (float) z + 0.5f);

    ForgeDirection orientation = te.getOrientation();

    if (orientation == ForgeDirection.DOWN) {
        GL11.glRotatef(180, 1, 0, 0);
        GL11.glTranslatef(0, -1f, 0f);
    }

    if (orientation == ForgeDirection.SOUTH) {
        GL11.glRotatef(90, 1, 0, 0);
        GL11.glTranslatef(0, -.5f, -.5f);
    }

    if (orientation == ForgeDirection.NORTH) {
        GL11.glRotatef(90, -1, 0, 0);
        GL11.glTranslatef(0, -.5f, .5f);
    }

    if (orientation == ForgeDirection.WEST) {
        GL11.glRotatef(90, 0, 0, 1);
        GL11.glTranslatef(.5f, -.5f, 0);
    }

    if (orientation == ForgeDirection.EAST) {
        GL11.glRotatef(90, 0, 0, -1);
        GL11.glTranslatef(-.5f, -.5f, 0);
    }

    GL11.glScalef(0.5f, 0.5f, 0.5f);

    FMLClientHandler.instance().

            getClient()

                    .renderEngine.bindTexture("/mods/FES/textures/injector.png");
    this.

            render();

    GL11.glPopMatrix();
}

From source file:com.freyja.FES.client.models.ModelReceptacle.java

License:LGPL

public void render(RoutingEntity te, double x, double y, double z) {
    GL11.glPushMatrix();//from www  .j  a va  2s.  c o m

    GL11.glTranslatef((float) x + 0.5f, (float) y, (float) z + 0.5f);

    ForgeDirection orientation = te.getOrientation();

    if (orientation == ForgeDirection.DOWN) {
        GL11.glRotatef(180, 1, 0, 0);
        GL11.glTranslatef(0, -1f, 0f);
    }

    if (orientation == ForgeDirection.SOUTH) {
        GL11.glRotatef(90, 1, 0, 0);
        GL11.glTranslatef(0, -.5f, -.5f);
    }

    if (orientation == ForgeDirection.NORTH) {
        GL11.glRotatef(90, -1, 0, 0);
        GL11.glTranslatef(0, -.5f, .5f);
    }

    if (orientation == ForgeDirection.WEST) {
        GL11.glRotatef(90, 0, 0, 1);
        GL11.glTranslatef(.5f, -.5f, 0);
    }

    if (orientation == ForgeDirection.EAST) {
        GL11.glRotatef(90, 0, 0, -1);
        GL11.glTranslatef(-.5f, -.5f, 0);
    }

    GL11.glScalef(0.5f, 0.5f, 0.5f);

    FMLClientHandler.instance().getClient().renderEngine.bindTexture("/mods/FES/textures/receptacle.png");

    this.render();

    GL11.glPopMatrix();
}

From source file:com.freyja.FES.client.renderers.ItemRenderInjector.java

License:LGPL

private void renderInjector(float x, float y, float z, float scale) {
    GL11.glPushMatrix();//w ww. j av  a2s  .co  m

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glTranslatef(x, y, z);
    GL11.glScalef(scale, scale, scale);
    GL11.glRotatef(180f, 0f, 1f, 0f);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture("/mods/FES/textures/injector.png");
    modelInjector.render();

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.gameminers.ethereal.architect.ModelCanvas.java

License:Open Source License

@Override
protected void paintGL() {
    try {/* w  ww .  ja  v  a  2 s .co  m*/
        if (getWidth() != current_width || getHeight() != current_height) {
            current_width = getWidth();
            current_height = getHeight();
            GL11.glViewport(0, 0, current_width, current_height);
        }
        GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f);
        GL11.glClearDepth(1.0);
        GL11.glColor3f(1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, zoom);
        GL11.glRotatef(angle, 0f, 1f, 0f);
        GL11.glRotatef(tilt, 1f, 0f, 0f);
        GL11.glTranslatef(-16, -16, -16);
        if (lit) {
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient);
        } else {
            GL11.glDisable(GL11.GL_LIGHTING);
        }
        if (textured) {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        if (model != null) {
            if (model.isAmbientOcclusionEnabled()) {
                GL11.glShadeModel(GL11.GL_SMOOTH);
            } else {
                GL11.glShadeModel(GL11.GL_FLAT);
            }
            for (ModelElement ele : model.getElements()) {
                GL11.glPushMatrix();
                if (ele.isShade()) {
                    GL11.glEnable(GL11.GL_LIGHTING);
                } else {
                    GL11.glDisable(GL11.GL_LIGHTING);
                }
                float fromX = ele.getFrom()[0];
                float fromY = ele.getFrom()[1];
                float fromZ = ele.getFrom()[2];
                float toX = ele.getTo()[0];
                float toY = ele.getTo()[1];
                float toZ = ele.getTo()[2];

                float fX = (fromX > toX ? fromX : toX);
                float fY = (fromY > toY ? fromY : toY);
                float fZ = (fromZ > toZ ? fromZ : toZ);
                float tX = (fromX > toX ? toX : fromX);
                float tY = (fromY > toY ? toY : fromY);
                float tZ = (fromZ > toZ ? toZ : fromZ);

                GL11.glTranslatef(fX, fY, fZ);
                float scaleX = tX - fX;
                float scaleY = tY - fY;
                float scaleZ = tZ - fZ;
                GL11.glBegin(GL11.GL_QUADS);
                GL11.glNormal3f(0, 0, -1f);
                for (int i = 0; i < vertices.length / 3; i++) {
                    int faceIdx = i / 4;
                    ModelFace face;
                    switch (faceIdx) {
                    case 0:
                        face = ele.getFaces().getNorth();
                        break;
                    case 1:
                        face = ele.getFaces().getSouth();
                        break;
                    case 2:
                        face = ele.getFaces().getUp();
                        break;
                    case 3:
                        face = ele.getFaces().getDown();
                        break;
                    case 4:
                        face = ele.getFaces().getWest();
                        break;
                    case 5:
                        face = ele.getFaces().getEast();
                        break;
                    default:
                        face = null;
                        break;
                    }
                    int idx = i * 3;
                    float vX = vertices[idx] * scaleX;
                    float vY = vertices[idx + 1] * scaleY;
                    float vZ = vertices[idx + 2] * scaleZ;
                    /*float u;
                    float v;
                    GL11.glTexCoord2f(u, v);*/
                    GL11.glVertex3f(vX, vY, vZ);
                }
                GL11.glEnd();
                GL11.glPopMatrix();
            }
        }
        GL11.glPopMatrix();
        swapBuffers();
        repaint();
    } catch (LWJGLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.gameminers.mav.component.Component.java

License:Open Source License

public final void render() {
    GL11.glPushMatrix();
    GL11.glTranslatef(x, y, z);
    doRender();
    GL11.glPopMatrix();
}

From source file:com.gameminers.mav.Mav.java

License:Open Source License

private static void doRender() {
    GL11.glPushMatrix();/* w ww  .  j av a2  s.  c  o m*/
    if (audioManager.getSink().getLevel() <= 8) {
        if (silentFrames == 0 && personality instanceof PolygonPersonality) {
            ((PolygonPersonality) personality).calm();
        }
        silentFrames++;
    } else {
        silentFrames = 0;
    }
    if (silentFrames < 10) {
        RenderState.idle = false;
        if (personality instanceof PolygonPersonality) {
            ((PolygonPersonality) personality).targetPulse = (audioManager.getSink().getLevel() / 64f);
        }
    } else {
        RenderState.idle = true;
    }

    if (listening) {
        if (audioManager.getSource().getLevel() <= 8) {
            silentListenFrames++;
        } else {
            silentListenFrames = 0;
        }
        if (silentListenFrames < 10) {
            RenderState.idle = false;
            if (personality instanceof PolygonPersonality) {
                ((PolygonPersonality) personality).targetInnerPulse = (audioManager.getSource().getLevel()
                        / 64f);
            }
        }
    }
    personalityRenderer.render();
    if (currentScreen != null && personality.renderScreen()) {
        GL11.glPushMatrix();
        currentScreen.render();
        GL11.glPopMatrix();
    }
    personality.postRender();
    String size = Display.getWidth() + "x" + Display.getHeight();
    Fonts.base[0].drawString((Display.getWidth() - Fonts.base[0].getWidth(size)) - 8, 8, size);
    Fonts.base[0].drawString(8, 8, fps + " FPS");
    Fonts.base[0].drawString(8, 24, (nspf / 1000000f) + " ms/f");
    Fonts.base[0].drawString(8, 40,
            (((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024) / 1024f)
                    + "MiB");
    if (personality instanceof PolygonPersonality) {
        Fonts.base[0].drawString(8, 56, ((PolygonPersonality) personality).angle + "");
    }
    Rendering.drawRectangle(0, 0, Display.getWidth(), Display.getHeight(), 0, 0, 0, (fadeFrames / FADE_TIME),
            1);
    GL11.glPopMatrix();
}

From source file:com.gameminers.mav.render.IconRenderer.java

License:Open Source License

@Override
public void run() {
    try {/*from   w  ww .  ja va  2s  .  c o  m*/
        init();
    } catch (Exception e) {
        return;
    }
    try {
        final ByteBuffer icon = BufferUtils.createByteBuffer(SIZE * SIZE * 4);
        while (run) {
            // LWJGL makes a deep copy of our ByteBuffer, so skip frames we don't need to render
            if (!ArrayUtils.isEquals(RenderState.lagRGB, previousRGB)) {
                previousRGB = RenderState.lagRGB.clone();
                Rendering.beforeFrame(SIZE, SIZE);
                GL11.glPushMatrix();
                Mav.personality.renderIconBackground(SIZE);
                GL11.glTranslatef(SIZE / 2f, SIZE / 2f, 0);
                Mav.personality.renderIconForeground(SIZE);
                GL11.glPopMatrix();
                GL11.glReadBuffer(GL11.GL_FRONT);
                GL11.glReadPixels(0, 0, SIZE, SIZE, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, icon);
                Display.setIcon(new ByteBuffer[] { icon });
            }
            sleep(33L); // We don't care very much about accuracy, and using LWJGL's sync() method screws up the main context
        }
    } catch (InterruptedException e) {
    }
}

From source file:com.gameminers.mav.render.PersonalityRenderer.java

License:Open Source License

public void render() {
    float w = Display.getWidth() / 2f;
    GL11.glPushMatrix();/*w  w  w. ja  v  a2s  .  com*/
    Mav.personality.renderBackground();
    //// This code was originally a test to see how bad the overdraw was, but it looks pretty damn cool.
    //// TODO, implement
    //GL11.glRotatef(30f, 0.5f, 1.0f, 0f);
    GL11.glTranslatef(Display.getWidth() / 2f, 10 + (w / 2f), 50);
    Mav.personality.renderForeground(w * 0.9f);
    GL11.glPopMatrix();
    if (Mav.personality.renderScreen()) {
        int y = (int) w;
        String[] split = RenderState.getLines();
        for (String s : split) {
            TrueTypeFont font = Fonts.light[1];
            if (s.startsWith("\u00A7l")) {
                font = Fonts.base[1];
                s = s.substring(2);
            } else if (s.startsWith("\u00A7L")) {
                font = Fonts.light[2];
                s = s.substring(2);
            } else if (s.startsWith("\u00A7s")) {
                font = Fonts.light[0];
                s = s.substring(2);
            }
            font.drawString((Display.getWidth() / 2) - (font.getWidth(s) / 2), y, s, Color.white);
            y += font.getHeight();
        }
    }
}