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.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java

License:LGPL

private void drawPanorama(int par1, int par2, float par3) {
    Tessellator tessellator = Tessellator.instance;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();//from  w  ww  .  j a  va  2  s. c om
    GL11.glLoadIdentity();
    Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    byte b0 = 8;

    for (int k = 0; k < b0 * b0; ++k) {
        GL11.glPushMatrix();
        float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F;
        float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F;
        float f3 = 0.0F;
        GL11.glTranslatef(f1, f2, f3);
        GL11.glRotatef(MathHelper.sin(((float) this.panoramaTimer + par3) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F,
                0.0F);
        GL11.glRotatef(-((float) this.panoramaTimer + par3) * 0.1F, 0.0F, 1.0F, 0.0F);

        for (int l = 0; l < 6; ++l) {
            GL11.glPushMatrix();

            if (l == 1) {
                GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 2) {
                GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 3) {
                GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 4) {
                GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
            }

            if (l == 5) {
                GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
            }

            this.mc.getTextureManager().bindTexture(titlePanoramaPaths[l]);
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA_I(16777215, 255 / (k + 1));
            float f4 = 0.0F;
            tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, (double) (0.0F + f4), (double) (0.0F + f4));
            tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, (double) (1.0F - f4), (double) (0.0F + f4));
            tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, (double) (1.0F - f4), (double) (1.0F - f4));
            tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, (double) (0.0F + f4), (double) (1.0F - f4));
            tessellator.draw();
            GL11.glPopMatrix();
        }

        GL11.glPopMatrix();
        GL11.glColorMask(true, true, true, false);
    }

    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
    GL11.glColorMask(true, true, true, true);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}

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

License:Open Source License

@Override
protected void paintGL() {
    try {/*from   ww  w.j  av  a2s. c  o  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.render.Rendering.java

License:Open Source License

public static void beforeFrame(int width, int height) {
    GL11.glViewport(0, 0, width, height);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*from  w w w  .  j  av  a  2 s .  com*/
    GL11.glOrtho(0, width, height, 0, 100, -100);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:com.github.begla.blockmania.rendering.cameras.FirstPersonCamera.java

License:Apache License

public void loadProjectionMatrix() {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluPerspective(FOV, ASPECT_RATIO, 0.1f, 1024f);

    glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:com.github.begla.blockmania.rendering.cameras.FirstPersonCamera.java

License:Apache License

public void loadModelViewMatrix() {
    glMatrixMode(GL11.GL_MODELVIEW);
    glLoadIdentity();//from   w w w. ja  va  2 s  .  c  o m

    Vector3f right = new Vector3f();
    right.cross(_viewingDirection, _up);
    right.scale((float) _bobbingRotationOffsetFactor);

    right.y += _bobbingVerticalOffsetFactor;

    GLU.gluLookAt(_position.x + right.x, _position.y + (float) _bobbingVerticalOffsetFactor * 2.0f + right.y,
            _position.z + right.z, _position.x + _viewingDirection.x + right.x,
            _position.y + _viewingDirection.y + (float) _bobbingVerticalOffsetFactor * 2.0f + right.y,
            _position.z + _viewingDirection.z + right.z, _up.x + right.x, _up.y + right.y, _up.z + right.z);

    _viewFrustum.updateFrustum();
}

From source file:com.github.begla.blockmania.rendering.cameras.FirstPersonCamera.java

License:Apache License

public void loadNormalizedModelViewMatrix() {
    glMatrixMode(GL11.GL_MODELVIEW);
    glLoadIdentity();//  w ww.jav  a  2  s .  c o  m

    Vector3f right = new Vector3f();
    right.cross(_viewingDirection, _up);
    right.scale((float) _bobbingRotationOffsetFactor);

    right.y += _bobbingVerticalOffsetFactor;

    GLU.gluLookAt(right.x, right.y, right.z, _viewingDirection.x + right.x, _viewingDirection.y + right.y,
            _viewingDirection.z + right.z, _up.x + right.x, _up.y + right.y, _up.z + right.z);
}

From source file:com.github.jtse.puzzle.Puzzle.java

License:Apache License

public void run() {
    try {//from ww w.ja  v  a2 s. co m
        int width = Display.getDisplayMode().getWidth();
        int height = Display.getDisplayMode().getHeight();

        Display.create();
        // Display.setDisplayMode(new DisplayMode(width, height));
        Runnable renderBackground = renderBackgroundProvider.get();

        Display.setFullscreen(true);

        Display.setVSyncEnabled(true);

        configureScene.run();

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glViewport(0, 0, width, height);
        glMatrixMode(GL11.GL_MODELVIEW);
        glMatrixMode(GL11.GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, width, height, 0, 1, -1);
        glMatrixMode(GL11.GL_MODELVIEW);

        // init resources
        Texture[] textures = new Texture[images.size()];
        Point[] points = new Point[images.size()];
        Region[] regions = new Region[images.size() + 4]; // 4 is for walls

        for (int i = 0; i < images.size(); i++) {
            textures[i] = Textures.createImage(new File(basePath, images.get(i).get("image")));
            regions[i] = Region.createRegion(textures[i]);
            points[i] = new Point(Integer.parseInt(images.get(i).get("x")),
                    Integer.parseInt(images.get(i).get("y")));
        }

        reset(regions, points);

        // Define the wall
        regions[images.size() + 0] = Region.createBlock(width, 1, 0, -1);
        regions[images.size() + 1] = Region.createBlock(1, height, width, 0);
        regions[images.size() + 2] = Region.createBlock(width, 1, 0, height);
        regions[images.size() + 3] = Region.createBlock(1, height, -1, 0);

        boolean quit = false;

        while (!Display.isCloseRequested() && !quit) {
            MouseEvent mouseEvent = mousePoller.poll();
            MouseEvent mouseDelta = deltaMouseEventFilter.apply(mouseEvent);

            Display.sync(60);

            if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
                quit = true;
            }

            if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
                reset(regions, points);
            }

            if (mouseEvent.isButtonDown() && !mouseDelta.isButtonDown()) {
                int x = mouseEvent.getX();
                int y = height - mouseEvent.getY();
                int dx = mouseDelta.getX();
                int dy = mouseDelta.getY();

                for (int i = 0; i < regions.length; i++) {
                    if (regions[i].contains(x, y)) {
                        regions[i].setDxDy(dx, -dy);

                        displacement.apply(regions[i], dx, -dy, regions);

                        i = regions.length;
                    }
                }
            }

            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            renderBackground.run();

            StringBuilder s = new StringBuilder("Regions ({}): ");
            // Move regions
            for (int i = 0; i < textures.length; i++) {
                int x = regions[i].getX();
                int y = regions[i].getY();

                s.append(x).append(",").append(y);

                if (i != (textures.length - 1)) {
                    s.append(",");
                }

                if (!regions[i].isHidden()) {
                    Textures.renderImage(textures[i], x, y);
                }
            }
            log.info(s.toString(), textures.length);

            Display.update();
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        Display.destroy();
        UI.confirm(e.getClass() == ScriptException.class ? "Script file contains errors:\n" + e.getMessage()
                : e.getMessage());
        return;
    }
    Display.destroy();
}

From source file:com.irr310.i3d.scene.I3dCamera.java

License:Open Source License

public void display(float width, float height) {

    this.currentWidth = width;
    this.currentHeight = height;

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*from w  ww  .ja  va 2 s .  c o  m*/
    GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    backgroundScene.display(this);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    initPerspective();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    GL11.glPushMatrix();

    configureView(glu);

    if (!configured) {
        configured = true;
        if (cameraInitialisation != null) {
            cameraInitialisation.run();
            cameraInitialisation = null;
        }
    }

    GL11.glColor3f(1, 0, 0);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3d(0, 0, 0);
    GL11.glVertex3d(100, 100, 100);
    GL11.glEnd();

    preDisplayScene();
    if (currentScene != null) {
        currentScene.display(this);
    }
    postDisplayScene();

    preDisplayGui();
    postDisplayGui();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    hudScene.display(this);

    GL11.glPopMatrix();

}

From source file:com.kauridev.lunarfever.Lunar.java

License:Open Source License

private void initOpenGL() {
    try {/*from  w  w w. j ava 2  s.com*/
        Display.setDisplayMode(new DisplayMode(TARGET_WIDTH, TARGET_HEIGHT));
        Display.setTitle("Lunar Fever");
        Display.setFullscreen(false);
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

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

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, TARGET_WIDTH, 0, TARGET_HEIGHT, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:com.kegare.caveworld.client.gui.GuiListSlot.java

License:Minecraft Mod Public

private void drawPanorama(float ticks) {
    Tessellator tessellator = Tessellator.instance;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();//  w  w  w.ja va2s.c  om
    GL11.glLoadIdentity();
    Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    byte b0 = 8;

    for (int k = 0; k < b0 * b0; ++k) {
        GL11.glPushMatrix();
        float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F;
        float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F;
        float f3 = 0.0F;
        GL11.glTranslatef(f1, f2, f3);
        GL11.glRotatef(MathHelper.sin((panoramaTimer + ticks) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(-(panoramaTimer + ticks) * 0.1F, 0.0F, 1.0F, 0.0F);

        for (int l = 0; l < 6; ++l) {
            GL11.glPushMatrix();

            if (l == 1) {
                GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 2) {
                GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 3) {
                GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 4) {
                GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
            }

            if (l == 5) {
                GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
            }

            mc.getTextureManager().bindTexture(getPanoramaPaths().getPath(l));
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA_I(16777215, 255 / (k + 1));
            float f4 = 0.0F;
            tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, 0.0F + f4, 0.0F + f4);
            tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, 1.0F - f4, 0.0F + f4);
            tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0F - f4, 1.0F - f4);
            tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, 0.0F + f4, 1.0F - f4);
            tessellator.draw();
            GL11.glPopMatrix();
        }

        GL11.glPopMatrix();
        GL11.glColorMask(true, true, true, false);
    }

    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
    GL11.glColorMask(true, true, true, true);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}