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.pwootage.pokebot.PokebotUI.java

License:Open Source License

private void render() {
    glMatrixMode(GL11.GL_PROJECTION);//from ww w .j av  a 2s  .c o m
    glLoadIdentity();
    GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
    GLU.gluOrtho2D(0, 1, 0, 1);

    glMatrixMode(GL11.GL_MODELVIEW);
    glLoadIdentity();
    updateTextureIfRequired();
    if (frameTex != null) {
        drawFrame();
    }
    if (tilesTex != null) {
        drawTilesTex();
    }
}

From source file:com.runescape.client.revised.editor.modelviewer.Viewport.java

License:Open Source License

public void render() {
    final Dimension size = this.canvas.getSize();
    if ((size.width > 0) && (size.height > 0)) {
        if ((this.width != size.width) || (this.height != size.height)) {
            this.width = size.width;
            this.height = size.height;
            GL11.glViewport(0, 0, this.width, this.height);
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();/*from w  w  w  . ja v a2s . c  o  m*/
            final float c = (float) Math
                    .sqrt((double) (this.width * this.width) + (double) (this.height * this.height));
            GL11.glOrtho(0.0F, this.width, 0.0F, this.height, -c, c);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            final boolean useShader = this.initShader();
            if (ModelConstants.ENABLE_VERTEX_SHADER && useShader) {
                ARBShaderObjects.glUseProgramObjectARB(this.program);
            }
            if (ModelConstants.ENABLE_LIGHTING) {
                GL11.glEnable(GL11.GL_LIGHTING);
                GL11.glEnable(GL11.GL_LIGHT0);
                final FloatBuffer diffuse = BufferUtils.createFloatBuffer(4)
                        .put(new float[] { 1F, 1F, 1F, 1F });
                final FloatBuffer position = BufferUtils.createFloatBuffer(4)
                        .put(new float[] { 3F, 0F, 1F, 0F });
                final FloatBuffer ambient = BufferUtils.createFloatBuffer(4)
                        .put(new float[] { .1F, .1F, .2F, .3F });
                final FloatBuffer specular = BufferUtils.createFloatBuffer(4)
                        .put(new float[] { 1F, 1F, 1F, 1F });
                GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, (FloatBuffer) specular.flip());
                GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, (FloatBuffer) ambient.flip());
                GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, (FloatBuffer) diffuse.flip());
                GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, (FloatBuffer) position.flip());
                GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 50.0f);
            }
        }
        if (Mouse.isButtonDown(0) && !Mouse.isButtonDown(1)) {
            this.yaw -= Mouse.getDX();
            this.pitch -= Mouse.getDY();
        }
        if (Mouse.isButtonDown(0) && Mouse.isButtonDown(1)) {
            this.offset_z += Mouse.getDY();
        }
        float wheel = Mouse.getDWheel() / 960.0F;
        if (wheel > 1.0F) {
            wheel = 1.0F;
        } else if (wheel < -1.0F) {
            wheel = -1.0F;
        }
        this.scale -= this.scale * wheel;
        if (this.scale < 0.01F) {
            this.scale = 0.01F;
        }
        for (final Model3D dragonModel : this.getDragonList()) {
            final float x = this.width / 1.2F;
            final float y = (-((100.0F * (this.scale))) + (this.offset_z + 0.1F))
                    + ((this.height - dragonModel.height()) / 2.0F);
            final float z = 0.0F;
            dragonModel.calcDimms(false);
            dragonModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale);
        }
        for (final Model3D torvaModel : this.getTorvaList()) {
            final float x = this.width / 1.7F;
            final float y = (-((100.0F * (this.scale))) + this.offset_z)
                    + ((this.height - torvaModel.height()) / 2.0F);
            final float z = 0.0F;
            torvaModel.calcDimms(false);
            torvaModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale);
        }
        for (final Model3D jadModel : this.getJadList()) {
            final float x = this.width / 3.2F;
            final float y = (-((100.0F * (this.scale))) + this.offset_z)
                    + ((this.height - jadModel.height()) / 2.0F);
            final float z = 0.0F;
            jadModel.calcDimms(false);
            jadModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale);
        }
        for (final Model3D trollModel : this.getTrollList()) {
            final float x = this.width / 3.8F;
            final float y = (-((100.0F * (this.scale))) + this.offset_z)
                    + ((this.height - trollModel.height()) / 2.0F);
            final float z = 0.0F;
            trollModel.calcDimms(false);
            trollModel.render(x, y, z, this.pitch, this.yaw, this.roll, this.scale, this.scale, this.scale);
        }
        if (ModelConstants.ENABLE_VERTEX_SHADER && this.initShader()) {
            ARBShaderObjects.glUseProgramObjectARB(0);
        }
        Display.update();
    }
}

From source file:com.rvantwisk.cnctools.opengl.View2D.java

License:Open Source License

@Override
public void begin() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();/*from w w  w  .  j  a va  2s.  c o  m*/
    GL11.glLoadIdentity();

    GL11.glOrtho(0, camera.getWidth(), 0, camera.getHeight(), NEAR, FAR);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
}

From source file:com.rvantwisk.cnctools.opengl.View2D.java

License:Open Source License

@Override
public void end() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
}

From source file:com.rvantwisk.cnctools.opengl.View2D.java

License:Open Source License

@Override
public void display_transform() {

    // _center_on_origin
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();//from w  ww  . ja va2  s. co  m
    GL11.glOrtho(-camera.getX(), camera.getX(), -camera.getY(), camera.getY(), NEAR, FAR);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    // _center_on_origin

    GL11.glTranslatef(camera.getX(), camera.getY(), camera.getZ());
    GL11.glRotatef(camera.getAzimuth(), 0.0f, 0.0f, 1.0f);
    GL11.glScalef(camera.getZoom_factor(), camera.getZoom_factor(), camera.getZoom_factor());
}

From source file:com.rvantwisk.cnctools.opengl.View3D.java

License:Open Source License

@Override
public void begin() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();//from ww  w . j a va  2s.  co  m
    GL11.glLoadIdentity();

    if (camera.isOrtho()) {
        GL11.glOrtho(-camera.getX(), camera.getX(), -camera.getY(), camera.getY(), -NEAR, FAR);
    } else {
        GLU.gluPerspective(camera.getFOVY(), camera.getWidth() / camera.getHeight(), NEAR, FAR);
    }

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
}

From source file:com.samrj.devil.graphics.Camera2D.java

public static void glLoadScreen(int resX, int resY) {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();//from w  w w . j  a  v  a2 s  . co  m
    GL11.glOrtho(0f, resX, 0f, resY, -1f, 1f);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
}

From source file:com.samrj.devil.graphics.Camera2D.java

public static void glLoadIdentity() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
}

From source file:com.samrj.devil.graphics.Camera2D.java

public void glLoadView() {
    GraphicsUtil.glLoadMatrix(getView(), GL11.GL_MODELVIEW);
}

From source file:com.samrj.devil.graphics.Camera3D.java

License:Open Source License

/**
 * Loads this camera's matrices into OpenGL.
 *///from w w  w .  j a v  a 2  s  .co  m
public void glLoadMatrices() {
    GraphicsUtil.glLoadMatrix(projMat, GL11.GL_PROJECTION);
    GraphicsUtil.glLoadMatrix(viewMat, GL11.GL_MODELVIEW);
}