Example usage for org.lwjgl.opengl GL11 glOrtho

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

Introduction

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

Prototype

public static native void glOrtho(@NativeType("GLdouble") double l, @NativeType("GLdouble") double r,
        @NativeType("GLdouble") double b, @NativeType("GLdouble") double t, @NativeType("GLdouble") double n,
        @NativeType("GLdouble") double f);

Source Link

Document

Manipulates the current matrix with a matrix that produces parallel projection, in such a way that the coordinates (lb – n)T and (rt – n)T specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, respectively (assuming that the eye is located at (0 0 0)T).

Usage

From source file:org.free.jake2.render.lwjgl.Main.java

License:Open Source License

/**
 * R_BeginFrame/*  w w w. j  av a  2s.com*/
 */
protected void R_BeginFrame(float camera_separation) {

    gl_state.camera_separation = camera_separation;

    /*
     ** change modes if necessary
     */
    if (gl_mode.modified || vid_fullscreen.modified) {
        // FIXME: only restart if CDS is required
        cvar ref;

        ref = Cvar.Get("vid_ref", "lwjgl", 0);
        ref.modified = true;
    }

    if (gl_log.modified) {
        GLimp_EnableLogging((gl_log.value != 0.0f));
        gl_log.modified = false;
    }

    if (gl_log.value != 0.0f) {
        GLimp_LogNewFrame();
    }

    /*
     ** update 3Dfx gamma -- it is expected that a user will do a vid_restart
     ** after tweaking this value
     */
    if (vid_gamma.modified) {
        vid_gamma.modified = false;

        if ((gl_config.renderer & GL_RENDERER_VOODOO) != 0) {
            // wird erstmal nicht gebraucht

            /*
            char envbuffer[1024];
            float g;
                    
            g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F;
            Com_sprintf( envbuffer, sizeof(envbuffer), "SSTV2_GAMMA=%f", g );
            putenv( envbuffer );
            Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g );
            putenv( envbuffer );
             */
            VID.Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt");
        }
    }

    GLimp_BeginFrame(camera_separation);

    /*
     ** go into 2D mode
     */
    GL11.glViewport(0, 0, vid.width, vid.height);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, vid.width, vid.height, 0, -99999, 99999);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glColor4f(1, 1, 1, 1);

    /*
     ** draw buffer stuff
     */
    if (gl_drawbuffer.modified) {
        gl_drawbuffer.modified = false;

        if (gl_state.camera_separation == 0 || !gl_state.stereo_enabled) {
            if (gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT")) {
                GL11.glDrawBuffer(GL11.GL_FRONT);
            } else {
                GL11.glDrawBuffer(GL11.GL_BACK);
            }
        }
    }

    /*
     ** texturemode stuff
     */
    if (gl_texturemode.modified) {
        GL_TextureMode(gl_texturemode.string);
        gl_texturemode.modified = false;
    }

    if (gl_texturealphamode.modified) {
        GL_TextureAlphaMode(gl_texturealphamode.string);
        gl_texturealphamode.modified = false;
    }

    if (gl_texturesolidmode.modified) {
        GL_TextureSolidMode(gl_texturesolidmode.string);
        gl_texturesolidmode.modified = false;
    }

    /*
     ** swapinterval stuff
     */
    GL_UpdateSwapInterval();

    //
    // clear screen if desired
    //
    R_Clear();
}

From source file:org.jogamp.glg2d.impl.gl2.GL2Transformhelper.java

License:Apache License

protected void setupGLView() {
    IntBuffer viewportDimensions = BufferUtils.createIntBuffer(16);
    GL11.glGetInteger(GL11.GL_VIEWPORT, viewportDimensions);
    int width = viewportDimensions.get(2);
    int height = viewportDimensions.get(3);

    // setup projection
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();//ww w.j av a2  s.  c  o  m
    GL11.glOrtho(0, width, 0, height, -1, 1);

    // the MODELVIEW matrix will get adjusted later

    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glLoadIdentity();
}

From source file:org.xmlvm.iphone.gl.GL.java

License:Open Source License

public static void glOrthof(float f, float g, float h, float i, float j, float k) {
    GL11.glOrtho(f, g, h, i, j, k);
}

From source file:rainet.Game.java

private void initGL(int width, int height, String title) {
    try {/* w w w .  jav a  2 s  .c o m*/
        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:render.Render.java

License:Open Source License

public void resetGL() {
    try {/*from w  w w.  j a v  a  2  s .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:sketchwars.scenes.Camera.java

public void applyCameraSettings() {
    Vector2d offset = getOffset();

    GL11.glLoadIdentity();/*from w w w .  j  av a2 s .  c om*/
    GL11.glOrtho(worldLeft, worldRight, worldBottom, worldTop, -1.0, 1.0);

    GL11.glScalef(worldWidth / width, worldHeight / height, 1);
    GL11.glTranslatef((float) offset.x, (float) offset.y, 0);
}

From source file:spaceshooter.main.SpaceShooter.java

License:Creative Commons License

public void init() {
    try {//from  w ww.ja va  2  s  . c o  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  2s.c o m*/
    // 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);

}

From source file:src.graphics.common.Viewport.java

License:Open Source License

/**  Similar to flat mode, but the coordinates used correspond directly with
  *  screen-pixel coordinates./*w  ww.  j a  va 2s .  com*/
  */
public void setScreenMode() {
    if (projectMode == MODE_SCREEN)
        return;
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, viewBounds.xdim(), 0, viewBounds.ydim(), -100 * screenS, 100 * screenS);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    projectMode = MODE_SCREEN;
}

From source file:src.graphics.common.Viewport.java

License:Open Source License

/**  Sets the OpenGL projection matrix to the correct height and width.
 *///from w  ww. j av  a  2  s.  c om
private void doOrtho() {
    final float wide = viewBounds.xdim() * 0.5f / screenS, high = viewBounds.ydim() * 0.5f / screenS;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0 - wide, wide, 0 - high, high, -100 / cameraZoom, 100 / cameraZoom);
}