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:net.adam_keenan.voxel.hud.HUD.java

License:Creative Commons License

public static void drawCrosshairs() {

    float screenx = (float) Display.getWidth() / 2, screeny = (float) Display.getHeight() / 2;
    float x1, y1, x2, y2, width1 = 4, height1 = 20, width2 = height1, height2 = width1;
    x1 = screenx - width1 / 2;/*from www.j  a  v  a  2 s  .co  m*/
    y1 = screeny - height1 / 2;
    x2 = screenx - width2 / 2;
    y2 = screeny - height2 / 2;

    FloatBuffer perspectiveProjectionMatrix;
    FloatBuffer orthographicProjectionMatrix;
    perspectiveProjectionMatrix = BufferUtils.createFloatBuffer(16);
    orthographicProjectionMatrix = BufferUtils.createFloatBuffer(16);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, perspectiveProjectionMatrix);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
    GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, orthographicProjectionMatrix);
    //      GL11.glLoadMatrix(perspectiveProjectionMatrix);

    GL11.glMatrixMode(GL11.GL_PROJECTION); // For text drawing
    GL11.glLoadMatrix(orthographicProjectionMatrix);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glLoadIdentity(); // Clears matrix

    GL11.glColor4f(0, 0, 0, .5f);
    GL11.glRectf(x1, y1, x1 + width1, y1 + height1);
    GL11.glRectf(x2, y2, x2 + (width2 - width1) / 2, y2 + height2);
    GL11.glRectf(x2 + (width2 + width1) / 2, y2, x2 + width2, y2 + height2);

    GL11.glPopMatrix();
    GL11.glPopAttrib();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadMatrix(perspectiveProjectionMatrix);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

}

From source file:net.ae97.notlet.client.GameInstance.java

License:Open Source License

public static void createTextures() throws LWJGLException {
    Display.setDisplayMode(new DisplayMode(width, height));
    Display.create();/*from   w  w w .j a  va  2 s . com*/
    Display.setVSyncEnabled(true);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glClearColor(0.0f, 0.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, 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);

    Font awtFont = new Font("Times New Roman", Font.BOLD, 18);
    font = new TrueTypeFont(awtFont, true);

    try {
        textureMapping.put("SMALLLET",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("SMALLLET.png")));
        textureMapping.put("healthbar",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("healthbar.png")));
        textureMapping.put("score",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("score.png")));
        textureMapping.put("arrow",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("arrow.png")));
        textureMapping.put("dirt",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("dirt.png")));
        textureMapping.put("rangerD",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerD.png")));
        textureMapping.put("rangerL",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerL.png")));
        textureMapping.put("rangerR",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerR.png")));
        textureMapping.put("rangerU",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("rangerU.png")));
        textureMapping.put("skele",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("skele.png")));
        textureMapping.put("slime",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("slime.png")));
        textureMapping.put("hp", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("hp.png")));
        textureMapping.put("pb", TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("pb.png")));
        textureMapping.put("wall",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("wall.png")));
        textureMapping.put("exit",
                TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("exit.png")));
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:net.minecraft.client.gui.GuiAchievement.java

private void updateAchievementWindowScale() {
    GL11.glViewport(0, 0, this.theGame.displayWidth, this.theGame.displayHeight);
    GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
    GL11.glLoadIdentity();// ww w.  j  a va2 s  .c o  m
    GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
    GL11.glLoadIdentity();
    this.achievementWindowWidth = this.theGame.displayWidth;
    this.achievementWindowHeight = this.theGame.displayHeight;
    ScaledResolution var1 = new ScaledResolution(this.theGame.gameSettings, this.theGame.displayWidth,
            this.theGame.displayHeight);
    this.achievementWindowWidth = var1.getScaledWidth();
    this.achievementWindowHeight = var1.getScaledHeight();
    GL11.glClear(256);
    GL11.glMatrixMode(5889 /*GL_PROJECTION*/);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, (double) this.achievementWindowWidth, (double) this.achievementWindowHeight, 0.0D,
            1000.0D, 3000.0D);
    GL11.glMatrixMode(5888 /*GL_MODELVIEW0_ARB*/);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
}

From source file:net.phatcode.rel.multimedia.Renderer.java

License:Open Source License

Renderer(int screenWidth, int screenHeight) {
    try {//from w  ww .  j  a  v a  2 s .com
        Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight));
        Display.create();
        Display.setTitle("AnyaBasic 0.4.0 beta");
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    this.screenWidth = screenWidth;
    this.screenHeight = screenHeight;

    GL11.glViewport(0, 0, screenWidth, screenHeight);

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

    GL11.glOrtho(0, screenWidth, screenHeight, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glLoadIdentity();

    GL11.glShadeModel(GL11.GL_SMOOTH); //set shading to smooth(try GL_FLAT)
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //set Clear color to BLACK
    GL11.glClearDepth(1.0f); //Set Depth buffer to 1(z-Buffer)
    GL11.glDisable(GL11.GL_DEPTH_TEST); //Disable Depth Testing so that our z-buffer works

    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0);

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

    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.375f, 0.375f, 0); // magic trick

}

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setProjectionOrtho(double left, double right, double bottom, double top, double zNear,
        double zFar) {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity(); // glOrtho sadly doesn't set all rows and columns
    GL11.glOrtho(left, right, bottom, top, zNear, zFar);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    return this;
}

From source file:org.agpu.oc.common.tileentity.AdvancedMonitor.java

public void startDrawing2D(int x, int y, int width, int height) {
    if (worldObj.isRemote) {
        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frameBufferID);

        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        GL11.glViewport(x, y, width, height);

        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();// w w w  .j  ava  2 s . com
        GL11.glLoadIdentity();
        GL11.glOrtho(0, width, height, 0, 1, -1);

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

        GL11.glClearColor(cr, cg, cb, ca);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    }
}

From source file:org.cogaen.lwjgl.scene.Camera.java

License:Open Source License

void applyTransform() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*from  ww w.j  av a2s.c o m*/
    GL11.glOrtho(0, this.width, 0, this.height, 1, -1);
    GL11.glTranslated(this.width / 2, this.height / 2, 0.0);

    GL11.glScaled(this.zoom, this.zoom, 0.0);
    GL11.glRotatef((float) -this.angle, 0, 0, 1);
    GL11.glTranslated(-this.posX, -this.posY, 0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glViewport(this.viewport.getX(), this.viewport.getY(), this.viewport.getWidth(),
            this.viewport.getHeight());
}

From source file:org.cogaen.lwjgl.scene.SceneService.java

License:Open Source License

public void renderScene() {

    // quite and dirty frame counter
    this.clock.tick();
    this.fpsSum += this.clock.getDelta();
    if (++this.fpsCnt >= this.fpsAvg) {
        this.fpsCnt = 0;
        this.fps = String.format("FPS: %2.2f", (1.0 / (this.fpsSum / this.fpsAvg)));
        this.fpsSum = 0.0;
    }//from   w ww  .j a v a 2s .c  o m

    // Clear the screen and depth buffer
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

    // render layers in each camera
    for (Camera camera : cameras) {
        if (!camera.isActive()) {
            continue;
        }

        camera.applyTransform();
        for (int i = this.layers.size() - 1; i >= 0; --i) {
            this.layers.get(i).render(camera.getMask());
        }

        for (RenderSubsystem rs : this.subSystems) {
            rs.render(camera.getMask());
        }
    }

    // draw overlays
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 1.0, 0, 1.0 / getAspectRatio(), 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glViewport(0, 0, this.config.getWidth(), this.config.getHeight());

    this.overlayRoot.renderWithAspectRatio(0xFFFFFFFF, getAspectRatio());
    //      this.overlayRoot.render(0xFFFFFFFF);

    // render frame counter
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, this.config.getWidth(), this.config.getHeight(), 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4d(1, 0, 1, 1);
    font.drawString(5, this.config.getHeight() - 20, this.fps);

    Display.update();

    if (Display.isCloseRequested()) {
        this.evtSrv.dispatchEvent(new SimpleEvent(WINDOW_CLOSE_REQUEST));
    }
}

From source file:org.evilco.emulator.core.graphic.matrix.MonochromeMatrixScreen.java

License:Apache License

/**
 * {@inheritDoc}/*from  ww  w. j ava  2  s  . c  o  m*/
 */
@Override
public void initialize() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    GL11.glOrtho(0, this.getWidth(), this.getHeight(), 0, 1, -1);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void setOrtho(double left, double right, double bottom, double top, double near, double far) {
    GL11.glOrtho(left, right, bottom, top, near, far);
}