Example usage for org.lwjgl.opengl GL11 GL_MODELVIEW

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

Introduction

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

Prototype

int GL_MODELVIEW

To view the source code for org.lwjgl.opengl GL11 GL_MODELVIEW.

Click Source Link

Document

MatrixMode

Usage

From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java

License:Open Source License

public static void applyTextureTransforms(final Texture texture, final int unit,
        final TextureStateRecord record, final ContextCapabilities caps) {
    final boolean needsReset = !record.units[unit].identityMatrix;

    // Should we apply the transform?
    final boolean doTrans = !texture.getTextureMatrix().isIdentity();

    // Now do them.
    final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord();
    if (doTrans) {
        checkAndSetUnit(unit, record, caps);
        LwjglRendererUtil.switchMode(matRecord, GL11.GL_TEXTURE);

        record.tmp_matrixBuffer.rewind();
        texture.getTextureMatrix().toDoubleBuffer(record.tmp_matrixBuffer, true);
        record.tmp_matrixBuffer.rewind();
        GL11.glLoadMatrix(record.tmp_matrixBuffer);

        record.units[unit].identityMatrix = false;
    } else if (needsReset) {
        checkAndSetUnit(unit, record, caps);
        LwjglRendererUtil.switchMode(matRecord, GL11.GL_TEXTURE);
        GL11.glLoadIdentity();//  www  .j  av a  2 s.  com
        record.units[unit].identityMatrix = true;
    }
    // Switch back to the modelview matrix for further operations
    LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW);
}

From source file:com.darkona.adventurebackpack.client.render.CopygirlRenderUtils.java

License:Open Source License

public static void renderItemIn3d(ItemStack stack) {
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    // Not sure why but this can be null when the world loads.
    if (textureManager == null) {
        return;//from  www . j  av  a2  s .  co  m
    }
    Item item = stack.getItem();

    GL11.glPushMatrix();

    Tessellator tessellator = Tessellator.instance;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
    GL11.glTranslatef(-0.5F, -0.5F, 1 / 32.0F);

    int passes = item.getRenderPasses(stack.getItemDamage());
    for (int pass = 0; pass < passes; pass++) {
        textureManager.bindTexture(((stack.getItemSpriteNumber() == 0) ? TextureMap.locationBlocksTexture
                : TextureMap.locationItemsTexture));
        IIcon icon = item.getIcon(stack, pass);
        if (icon != null) {
            float minU = icon.getMinU();
            float maxU = icon.getMaxU();
            float minV = icon.getMinV();
            float maxV = icon.getMaxV();
            CopygirlRenderUtils.setColorFromInt(item.getColorFromItemStack(stack, pass));
            ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(),
                    icon.getIconHeight(), 0.0625F);
        }
    }

    if (stack.hasEffect(0)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        textureManager.bindTexture(glint);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float f7 = 0.76F;
        GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float f8 = 0.125F;
        GL11.glScalef(f8, f8, f8);
        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();
        GL11.glPushMatrix();
        GL11.glScalef(f8, f8, f8);
        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);
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);

    GL11.glPopMatrix();
}

From source file:com.dbi.games.fortress.engine.MainEngine.java

License:Open Source License

/**
 * Should ONLY be invoked from the GL thread!
 *///from   w  w w .j  a  v a 2s . c o  m
public void renderScene(long deltaNanos) {
    if (!isReady)
        return;
    currentTickLengthNanos += deltaNanos;
    nanosSinceStatsUpdate += deltaNanos;

    framesSinceStatsUpdate++;

    if (currentTickLengthNanos >= targetTickLengthNanos) {
        tick();
    }

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    graphicsEngine.renderMap(currentMap);
    for (Entity ent : entityEngine.findAll()) {
        graphicsEngine.renderEntity(ent);
    }

    if (nanosSinceStatsUpdate > NANOS_PER_STAT_UPDATE) {
        controlWindow.setFPS(framesSinceStatsUpdate * 4);
        controlWindow.setTPS(ticksSinceStatsUpdate * 4, ticksPerSecondTarget);
        framesSinceStatsUpdate = 0;
        ticksSinceStatsUpdate = 0;
        nanosSinceStatsUpdate = 0;
    }
}

From source file:com.dbi.games.fortress.ui.MainAppWindow.java

License:Open Source License

/**
 * Creates new form MainAppWin/*from   ww w.j  av a  2s  . co m*/
 */
public MainAppWindow() {
    initComponents();

    glCanvas.addComponentListener(new ComponentListener() {
        public void componentShown(ComponentEvent e) {
            setNeedValidation();
        }

        public void componentResized(ComponentEvent e) {
            setNeedValidation();
        }

        public void componentMoved(ComponentEvent e) {
            setNeedValidation();
        }

        public void componentHidden(ComponentEvent e) {
            setNeedValidation();
        }
    });

    File currentDir = new File("lib/natives");
    if (!currentDir.exists()) {
        //            JOptionPane.showMessageDialog(null, "directory location: "+currentDir.getAbsolutePath()+" does not exist!");
        currentDir = new File("build/libs/natives");
    }
    Logger.getLogger("LWJGLThread").log(Level.INFO, "LWJGL directory is " + currentDir.getAbsolutePath());

    System.setProperty("org.lwjgl.librarypath", currentDir.getAbsolutePath());

    Thread glThread = new Thread("GLThread") {

        @Override
        public void run() {
            long lastFrame = System.nanoTime();
            long currentFrame;
            try {
                Display.setParent(glCanvas);
                Display.create();

                GL11.glEnable(GL11.GL_TEXTURE_2D);
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                GL11.glDisable(GL11.GL_DEPTH_TEST);
                GL11.glClearColor(0f, 0f, 0f, 0f);
                GL11.glMatrixMode(GL11.GL_PROJECTION);
                GL11.glLoadIdentity();
                GL11.glOrtho(0f, (float) glCanvas.getWidth(), (float) glCanvas.getHeight(), 0f, -1, 1);
                GL11.glMatrixMode(GL11.GL_MODELVIEW);
                GL11.glLoadIdentity();
                GL11.glViewport(0, 0, glCanvas.getWidth(), glCanvas.getHeight());

                MainEngine.get().graphicsEngine().buildDefaultRenderers();

                while (MainEngine.get().isRunning()) {
                    try {
                        currentFrame = System.nanoTime();

                        MainEngine.get().renderScene(currentFrame - lastFrame);

                        lastFrame = currentFrame;

                        Display.update();

                        if (needUpdateViewport) {
                            needUpdateViewport = false;

                            GL11.glMatrixMode(GL11.GL_PROJECTION);
                            GL11.glLoadIdentity();
                            GL11.glOrtho(0, glCanvas.getWidth(), glCanvas.getHeight(), 0, -1, 1);
                            GL11.glViewport(0, 0, glCanvas.getWidth(), glCanvas.getHeight());
                        }
                    } catch (Throwable ex) {
                        ex.printStackTrace();
                        Logger.getLogger("LWJGLThread").log(Level.SEVERE,
                                "There was a SEROUS uncaught error in the render thread.  Shutting down.  Please restart!",
                                ex);
                        MainEngine.get().shutdown();
                    }
                }
            } catch (Throwable ex) {
                throw new RuntimeException("There was an issue starting LWJGL!", ex);
            }
        }

    };
    glThread.start();
}

From source file:com.dinasgames.engine.graphics.GL.java

public static void setMatrixMode(MatrixMode mode) {

    if (version >= 11) {
        int glMode = -1;
        switch (mode) {
        case Projection:
            glMode = GL11.GL_PROJECTION;
            break;
        case ModelView:
            glMode = GL11.GL_MODELVIEW;
            break;
        case Texture:
            glMode = GL11.GL_TEXTURE;//from w w  w . ja  v  a2  s. c  o  m
            break;
        }
        if (glMode != -1) {
            GL11.glMatrixMode(glMode);
        }
    }
}

From source file:com.dinasgames.engine.graphics.RenderTarget.java

public void pushGLStates() {

    //if(true){return;}

    if (activate(true)) {
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();/*  w  ww. j a  v  a2  s .  com*/
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
    }
    resetGLStates();

}

From source file:com.dinasgames.engine.graphics.RenderTarget.java

public void popGLStates() {

    //if(true){return;}

    if (activate(true)) {
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPopMatrix();//from   w  w w .j  av a  2  s  .co  m
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPopMatrix();
    }

}

From source file:com.dinasgames.engine.graphics.RenderTarget.java

public void resetGLStates() {

    //if(true){return;}

    if (activate(true)) {
        //GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);//from   w ww .  j a  v  a2  s . c  o m
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        //GL11.glEnable(GL13.GL_MULTISAMPLE);
        mCache.glStatesSet = true;

        applyBlendMode(BlendMode.BlendAlpha);
        applyTransform(Transform.Identity);
        applyTexture(null);

        mCache.useVertexCache = false;

        setView(new View(getView()));

    }
}

From source file:com.dyonovan.tcnodetracker.lib.truetyper.FontHelper.java

License:Open Source License

private static void set2DMode(FloatBuffer matrixData) {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution sr = new ScaledResolution(mc.getMinecraft(), mc.displayWidth, mc.displayHeight);
    mc.entityRenderer.setupOverlayRendering();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();// w  w  w.j  a  v  a2 s  .c o  m
    //GL11.glLoadMatrix(matrixData);

    GL11.glLoadIdentity();
    GL11.glOrtho(0, mc.displayWidth, 0, mc.displayHeight, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    Matrix4f matrix = new Matrix4f();
    matrix.load(matrixData);
    GL11.glTranslatef(matrix.m30 * sr.getScaleFactor(), -matrix.m31 * sr.getScaleFactor(), 0f);

}

From source file:com.dyonovan.tcnodetracker.lib.truetyper.FontHelper.java

License:Open Source License

private static void set3DMode() {
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();/*from  w w  w .  j  a  va  2  s.com*/
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    Minecraft mc = Minecraft.getMinecraft();
    mc.entityRenderer.setupOverlayRendering();
}