Example usage for org.lwjgl.opengl GL11 glMatrixMode

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

Introduction

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

Prototype

public static native void glMatrixMode(@NativeType("GLenum") int mode);

Source Link

Document

Set the current matrix mode.

Usage

From source file:herzog3d.Camera.java

License:Open Source License

public void transform() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();//  w w  w .  j av  a2 s . c o  m
    GLU.gluPerspective(40, 1, 1, 100);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    Vector3f targetPos = new Vector3f(mech.getPos());
    GLU.gluLookAt(pos.x, pos.y, pos.z, targetPos.x, targetPos.y, targetPos.z, 0, 0, 1);
}

From source file:herzog3d.Game.java

License:Open Source License

/**
 * All rendering is done in here//w  w  w . ja  v a 2  s.c o m
 */
public void draw() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    cam.transform();
    GLUtils.glLightPos(1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    getMap().draw(cam);

    for (Unit unit : units) {
        if (unit.isActive()) {
            unit.draw();
        }
    }

    for (Base base : bases) {
        base.draw(map);
    }
    for (Effect effect : effects) {
        effect.draw();
    }

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 600, 0, 0, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    Material.DEFAULT_WHITE.bind();
    for (HZWidget overlay : overlays) {
        if (overlay.isVisible()) {
            overlay.draw();
        }
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_DEPTH_TEST);

}

From source file:hexagonalminesweeper.HexagonalMinesweeper.java

public static void renderGL() {
    try {//w w  w . j  ava2  s .  c o  m
        Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(800, 600));
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, 800, 600);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 600, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    Display.setVSyncEnabled(true);
}

From source file:hud.UnitDisplay.java

License:Open Source License

public void draw() {
    GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE);
    GL11.glColor4f(0.0f, 0.0f, 0.4f, 1.0f);
    GL11.glLineWidth(2.0f);//from w ww . ja  va 2  s  .com
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2i(x, y);
    GL11.glVertex2i(x, y + height);
    GL11.glVertex2i(x + width, y + height);
    GL11.glVertex2i(x + width, y);
    GL11.glEnd();

    GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
    GL11.glColor4f(0.0f, 0.5f, 1.0f, 0.8f);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2i(x, y);
    GL11.glVertex2i(x, y + height);
    GL11.glVertex2i(x + width, y + height);
    GL11.glVertex2i(x + width, y);
    GL11.glEnd();
    GL11.glDisable(GL11.GL_BLEND);

    int[] viewport = GLUtils.getViewport();

    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluPerspective(45, 1.0f, 0.001f, 5.0f);
    GL11.glViewport(getX(), viewport[3] - (getY() + height), width, height);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluLookAt(2.0f * (float) Math.cos(angle), 2.0f * (float) Math.sin(angle), 1.0f, 0, 0, 0, 0, 0, 1);
    //        GL11.glTranslatef(x + width/2, y + height/2,0);
    currentUnit.draw();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
}

From source file:illarion.graphics.lwjgl.RenderDisplayLWJGL.java

License:Open Source License

/**
 * Setup the openGL render environment. Such as the view port the matrix for
 * the orthogonal view and so on./*  w  w  w. jav  a  2 s.  c  o m*/
 */
protected void setupOpenGL() {
    if (!Display.isCreated()) {
        return;
    }

    // set the basic view port of the game. This should be the full size of
    // the client window
    GL11.glViewport(0, 0, resWidth, resHeight);

    // enable alpha blending based on the picture alpha channel
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // disable death test, we work in 2D anyway, there is no depth
    GL11.glDisable(GL11.GL_DEPTH_TEST);

    // switch to projection matrix to set up the orthogonal view that we
    // need
    GL11.glMatrixMode(GL11.GL_PROJECTION);

    // load the identity matrix to we have a clean start
    GL11.glLoadIdentity();

    // setup the orthogonal view
    GLU.gluOrtho2D(0, resWidth, 0, resHeight);

    // set clear color to black
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    // sync frame (only works on windows)
    if (Graphics.NO_SLOWDOWN) {
        Display.setVSyncEnabled(false);
    } else {
        Display.setVSyncEnabled(true);
    }

    // clean up the screen
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    // switch to model view matrix, so we can place the sprites correctly
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
}

From source file:im.bci.jnuit.lwjgl.LwjglNuitRenderer.java

License:Open Source License

@Override
public void render(Root root) {
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT
            | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT);
    GL11.glViewport(0, 0, LwjglHelper.getWidth(), LwjglHelper.getHeight());
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();/*from ww w.j av  a2s  .  c o m*/
    GL11.glLoadIdentity();
    GL11.glOrtho(root.getX(), root.getWidth(), root.getHeight(), root.getY(), -1.0, 1.0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    drawBackgroundAndBorder(root);
    drawStack(root);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:io.flob.blackheart.DisplayDriver.java

License:Open Source License

private void init_GL() {
    GL11.glClearColor(0.1F, 0.1F, 0.1F, 1.0F);
    GL11.glEnable(GL11.GL_BLEND);/* w ww.  jav  a 2 s . c o m*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GLU.gluPerspective(60.0f, ((float) Display.getWidth()) / ((float) Display.getHeight()), 0.1f, 40.0f);
}

From source file:io.flob.blackheart.DisplayDriver.java

License:Open Source License

public void mode_2D() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();//from  ww w. j ava2 s.  c  o  m
    GL11.glLoadIdentity();
    GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 0, 1);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glDisable(GL11.GL_FOG);
}

From source file:io.flob.blackheart.DisplayDriver.java

License:Open Source License

public void mode_3D() {
    GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w  ww. j  a  v a2 s.c om*/
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glLoadIdentity();
    GL11.glEnable(GL11.GL_FOG);
}

From source file:io.flob.clicker.DisplayDriver.java

License:Open Source License

private void init_GL() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*from   w ww. j a  va2  s .c  o m*/
    GL11.glOrtho(0, width, height, 0, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
    GL11.glClearDepth(1.0f);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}