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:org.voxels.platform.LWJGLOpenGLAdapter.java

License:Open Source License

@Override
public int GL_MODELVIEW() {
    return GL11.GL_MODELVIEW;
}

From source file:processing.lwjgl.PLWJGL.java

License:Open Source License

@Override
protected void beginGL() {
    if (projMatrix == null) {
        projMatrix = allocateFloatBuffer(16);
    }//from  www  .  j a v  a 2  s  .  c  om
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    projMatrix.rewind();
    projMatrix.put(pg.projection.m00);
    projMatrix.put(pg.projection.m10);
    projMatrix.put(pg.projection.m20);
    projMatrix.put(pg.projection.m30);
    projMatrix.put(pg.projection.m01);
    projMatrix.put(pg.projection.m11);
    projMatrix.put(pg.projection.m21);
    projMatrix.put(pg.projection.m31);
    projMatrix.put(pg.projection.m02);
    projMatrix.put(pg.projection.m12);
    projMatrix.put(pg.projection.m22);
    projMatrix.put(pg.projection.m32);
    projMatrix.put(pg.projection.m03);
    projMatrix.put(pg.projection.m13);
    projMatrix.put(pg.projection.m23);
    projMatrix.put(pg.projection.m33);
    projMatrix.rewind();
    GL11.glLoadMatrix(projMatrix);

    if (mvMatrix == null) {
        mvMatrix = allocateFloatBuffer(16);
    }
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    mvMatrix.rewind();
    mvMatrix.put(pg.modelview.m00);
    mvMatrix.put(pg.modelview.m10);
    mvMatrix.put(pg.modelview.m20);
    mvMatrix.put(pg.modelview.m30);
    mvMatrix.put(pg.modelview.m01);
    mvMatrix.put(pg.modelview.m11);
    mvMatrix.put(pg.modelview.m21);
    mvMatrix.put(pg.modelview.m31);
    mvMatrix.put(pg.modelview.m02);
    mvMatrix.put(pg.modelview.m12);
    mvMatrix.put(pg.modelview.m22);
    mvMatrix.put(pg.modelview.m32);
    mvMatrix.put(pg.modelview.m03);
    mvMatrix.put(pg.modelview.m13);
    mvMatrix.put(pg.modelview.m23);
    mvMatrix.put(pg.modelview.m33);
    mvMatrix.rewind();
    GL11.glLoadMatrix(mvMatrix);
}

From source file:rainet.Game.java

private void initGL(int width, int height, String title) {
    try {/* w ww .  j  av a 2s .  c  om*/
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.setLocation(6, 7);
        Display.setTitle(title);
        Display.create();
        Display.setVSyncEnabled(true);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, width, height);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, height, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:rainwarrior.mt100.Screen.java

License:Open Source License

@SideOnly(Side.CLIENT)
public void render(float cw, float ch) {
    Tessellator tes = Tessellator.instance;
    GL11.glMatrixMode(GL11.GL_TEXTURE);//from   w  w  w . j  av  a2  s .co m
    GL11.glPushMatrix();
    PstFont curFont = PstFontRegistry.nullFont, tmpFont;
    curFont.bindFontTexture();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    double cx = cw / width;
    double cy = ch / height;
    double tx, ty;
    double x, y;
    double eps = 1D / 128D;
    Integer c;
    // First pass - background, second pass - foreground
    for (int pass = 0; pass < 2; pass++) {
        tes.startDrawingQuads();
        if (pass == 0) {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        } else {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        }
        for (int i = 0, I = scroll, k = pass * 4 + scroll * width * 8; i < height; i++, I++) {
            if (I >= height)
                I -= height;
            if (k >= width * height * 8)
                k -= width * height * 8;
            for (int j = 0; j < width; j++, k += 8) {
                x = j * cx;
                y = i * cy;
                if (debug)
                    MT100.logger.info("k: " + k + " " + color[k + 0] + " " + color[k + 1] + " " + color[k + 2]
                            + " " + color[k + 3]);
                if (pass == 0) {
                    setColorToTesselator(tes, k);
                    tes.addVertex(x, y, 0F);
                    tes.addVertex(x, y + cy, 0F);
                    tes.addVertex(x + cx, y + cy, 0F);
                    tes.addVertex(x + cx, y, 0F);
                    if (I == this.y && j == this.x) // cursor
                    {
                        setColorToTesselator(tes, k + 4);
                        tes.addVertex(x, y + cy * .9, eps);
                        tes.addVertex(x, y + cy, eps);
                        tes.addVertex(x + cx, y + cy, eps);
                        tes.addVertex(x + cx, y + cy * .9, eps);
                    }
                } else {
                    c = screen[I * width + j];
                    if (debug)
                        MT100.logger.info("c: " + c);
                    if (debug)
                        MT100.logger.info("font: " + curFont.fontFile);
                    tmpFont = PstFontRegistry.getFont(c);
                    if (tmpFont != curFont) {
                        curFont = tmpFont;
                        if (debug)
                            MT100.logger.info("switching!");
                        tes.draw();
                        tes.startDrawingQuads();
                        GL11.glMatrixMode(GL11.GL_TEXTURE);
                        curFont.bindFontTexture();
                        GL11.glMatrixMode(GL11.GL_MODELVIEW);
                    }
                    setColorToTesselator(tes, k);
                    c = PstFontRegistry.getIndex(c);
                    if (debug)
                        MT100.logger.info("c2: " + c);
                    if (c != null) {
                        tx = c / (curFont.length >> curFont.lShift) * curFont.width;
                        if (debug)
                            MT100.logger.info("tx: " + (c / (curFont.length >> curFont.lShift)));
                        ty = c % (curFont.length >> curFont.lShift) * curFont.height;
                        if (debug)
                            MT100.logger.info("ty: " + (c % (curFont.length >> curFont.lShift)));
                        tes.addVertexWithUV(x, y, 0F, tx + eps, ty + eps);
                        tes.addVertexWithUV(x, y + cy, 0F, tx + eps, ty + curFont.height - eps);
                        tes.addVertexWithUV(x + cx, y + cy, 0F, tx + curFont.width - eps,
                                ty + curFont.height - eps);
                        tes.addVertexWithUV(x + cx, y, 0F, tx + curFont.width - eps, ty + eps);
                        /*                     GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
                                             GL11.glTexCoord2d(tx, ty);
                                             GL11.glVertex3d(x, y, 0.F);
                                             GL11.glTexCoord2d(tx, ty + curFont.height);
                                             GL11.glVertex3d(x, y + cy, 0.F);
                                             GL11.glTexCoord2d(tx + curFont.width, ty);
                                             GL11.glVertex3d(x + cx, y, 0.F);
                                             GL11.glTexCoord2d(tx + curFont.width, ty + curFont.height);
                                             GL11.glVertex3d(x + cx, y + cy, 0.F);
                                             GL11.glEnd();*/
                        if (I == this.y && j == this.x) // cursor
                        {
                            setColorToTesselator(tes, k - 4);
                            tes.addVertexWithUV(x, y + cy * .9, eps, tx + eps, ty + eps);
                            tes.addVertexWithUV(x, y + cy, eps, tx + eps, ty + curFont.height - eps);
                            tes.addVertexWithUV(x + cx, y + cy, eps, tx + curFont.width - eps,
                                    ty + curFont.height - eps);
                            tes.addVertexWithUV(x + cx, y + cy * .9, eps, tx + curFont.width - eps, ty + eps);
                        }
                    }
                }
            }
        }
        tes.draw();
    }
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    if (debug) {
        MT100.logger.info("cx: " + cx);
        MT100.logger.info("cy: " + cy);
    }
    debug = false;
}

From source file:render.Render.java

License:Open Source License

public void resetGL() {
    try {/*from w  w w . j  a v  a 2s  .c  o m*/
        Display.setDisplayMode(
                new DisplayMode(Display.getParent().getWidth(), Display.getParent().getHeight()));
    } catch (LWJGLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(-Display.getWidth() / 2, Display.getWidth() / 2, -Display.getHeight() / 2,
            Display.getHeight() / 2, -1.0, 1.0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

}

From source file:rtype.Prototyp.java

License:Open Source License

private void initGL() {

    GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
    GL11.glClearDepth(1.0f); // Depth Buffer Setup
    GL11.glDisable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
    GL11.glEnable(GL11.GL_BLEND);//from w w  w  .  ja v  a2 s  . co  m
    GL11.glDepthMask(false);
    GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
    GL11.glLoadIdentity(); // Reset The Projection Matrix

    GLU.gluOrtho2D(-(int) SCREEN_WIDTH / 2, (int) SCREEN_WIDTH / 2, (int) -SCREEN_HEIGHT / 2,
            (int) SCREEN_HEIGHT / 2);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    if (useDevil)
        ;//textureLoader = new DevilTextureLoader();
    else {
        textureLoader = new WorkAroundTextureLoader();
    }
    textureLoader.init();
}

From source file:shadowmage.meim.client.gui.GuiModelEditor.java

License:Open Source License

private void setupModelView() {
    /**//from   w ww.j  a  v a  2 s . c om
     * load a clean projection matrix
     */
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    /**
     * set up the base projection transformation matrix, as well as view target and position
     * (camera setup)
     */
    float aspect = (float) this.mc.displayWidth / (float) this.mc.displayHeight;
    GLU.gluPerspective(60.f, aspect, 0.1f, 100.f);
    GLU.gluLookAt(viewPosX, viewPosY, viewPosZ, viewTargetX, viewTargetY, viewTargetZ, 0, 1, 0);

    /**
     * load a clean model-view matrix
     */
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    /**
     * and finally, clear the depth buffer 
     * (we want to ignore any world/etc, as we're rendering over-top of it all anyway)
     */
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
}

From source file:shadowmage.meim.client.gui.GuiModelEditor.java

License:Open Source License

private void resetModelView() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
}

From source file:spaceshooter.main.SpaceShooter.java

License:Creative Commons License

public void init() {
    try {/*from   ww  w . j a  va  2s . co m*/
        Display.setDisplayMode(new DisplayMode(RenderingHelper.xSize, RenderingHelper.ySize));
        Display.setTitle("Space Shooter");
        Display.sync(60);
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, RenderingHelper.xSize, 0, RenderingHelper.ySize, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    while (!Display.isCloseRequested()) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

        LevelHelper.level.get(level).setup();
        LevelHelper.level.get(level).generateLevel();

        player.handleInput();
        player.draw();
        player.onUpdate();

        Display.update();
    }
    Display.destroy();
}

From source file:Src.Framework.Window.java

public void initGL() {
    //Make the OpenGL context curent
    glfwMakeContextCurrent(windowHandle);
    // Enable v-sync
    glfwSwapInterval(1);/*  w  w w .  j a  v a 2 s . c  om*/
    // Make the window visible
    glfwShowWindow(windowHandle);
    //sets up OpenGL Bindings for use
    GLContext.createFromCurrent();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    //set the clear color
    glClearColor(0.0f, 1.0f, 0.0f, 0.0f);

    // enable alpha blending
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, windowWidth, windowHeight);
    GL11.glOrtho(0, windowWidth, windowHeight, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

}