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:src.graphics.widgets.HUD.java

License:Open Source License

public void renderHUD(Box2D bounds) {
    relBound.set(0, 0, 1, 1);//from www .  j av  a  2  s.  c  o m
    absBound.set(0, 0, 0, 0);
    updateAsBase(bounds);

    final UINode oldSelect = selected;
    if ((selected == null) || (mouseState != DRAGGED)) {
        selected = selectionAt(mousePos);
    }
    if (mouseState != HOVERED) {
        //hoverStart = System.currentTimeMillis() ;
    } else if (selected != null && selected != oldSelect) {
        hoverStart = System.currentTimeMillis();
    }
    if (selected != null)
        switch (mouseState) {
        case (HOVERED):
            selected.whenHovered();
            break;
        case (CLICKED):
            selected.whenClicked();
            break;
        case (PRESSED):
            selected.whenPressed();
            break;
        case (DRAGGED):
            selected.whenDragged();
            break;
        }

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, bounds.xdim(), 0, bounds.ydim(), -100, 100);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    super.render();
}

From source file:tectonicus.util.MatrixUtil.java

License:BSD License

public static void testOrthoMatrix(final int left, final int right, final int bottom, final int top,
        final int near, final int far) {
    // Make an ortho matrix in opengl and pull it out into a Matrix4f
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();//from   ww  w . j  av  a 2s  . c  om
    GL11.glOrtho(left, right, bottom, top, near, far);
    FloatBuffer fromGlBuffer = BufferUtils.createFloatBuffer(16);
    GL11.glGetFloat(GL11.GL_MODELVIEW, fromGlBuffer);
    Matrix4f fromGl = new Matrix4f();
    fromGl.load(fromGlBuffer);

    Matrix4f manual = createOrthoMatrix(left, right, bottom, top, near, far);

    compare(fromGl, manual);
}

From source file:terminal.gld.GLDrawer.java

License:Open Source License

public static void otherDraw() {
    String s = "";
    char[][] charr = ((GLDummyTerm) Init.terminal).term;
    for (int x = 0; x < 80; x++) {
        for (int y = 0; y < 80; y++) {
            s += charr[y][x];/*  w  w  w  .  j a  va 2  s  . c o  m*/
        }
        s += '\n';
    }
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    GL11.glOrtho(0, 800, 0, 600, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    if (GLDummyTerm.changed()) {
        strdispl = glGenLists(1);
        glNewList(strdispl, GL_COMPILE);
        fnt.drawString(000, 600, s, 0, s.length() - 1, .35f, .35f, TrueTypeFont.ALIGN_LEFT,
                GLDummyTerm.toColArr());
        glEndList();
        GLDummyTerm.donechanged();
    }
    glCallList(strdispl);
    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
}

From source file:terminal.gld.GLDungeonDraw.java

License:Open Source License

private static void drawHUD() {
    glDisable(GL_FOG);/*from   ww  w . j  ava 2s  .  c  om*/
    String s = "";
    s = entity.player.Display.getDispLine();
    int e = glGetError();
    if (e != GL11.GL_NO_ERROR)
        System.out.println(e + " h " + org.lwjgl.opengl.Util.translateGLErrorString(e));
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    GL11.glOrtho(0, 800, 0, 600, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    glPushMatrix();
    glLoadIdentity();

    glClear(GL_DEPTH_BUFFER_BIT);
    // glColor3f(1, 0, 0);
    String str = cleanstr(s);
    GLDrawer.fnt.drawString(10, 130, str, 0, str.length() - 1, .35f, .35f, TrueTypeFont.ALIGN_LEFT,
            mkcolarr(s));

    glPopMatrix();

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    // glLoadIdentity();
    // GLU.gluPerspective(80, 1366 / 786, 1f, 500f);
    glMatrixMode(GL_MODELVIEW);

}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glOrtho(double a, double b, double c, double d, double e, double f) {
    GL11.glOrtho(a, b, c, d, e, f);
}

From source file:vengine.VGraphicLayer.java

public void set() {
    if (!inited) {
        init();//  ww w  .  j a  va  2 s  . c  o m
        inited = true;
    }
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:vengine.VGraphics.java

public static void start() {

    Thread renderingThread = new Thread("RenderingThread") {

        @Override//from   ww w.j a v a 2s .  co  m
        public void run() {
            try {
                Display.setDisplayMode(new DisplayMode(8000, 6000));
                Display.setTitle(VEngine.cfg.g("mod"));
                Display.setIcon(new ByteBuffer[] { new ImageIOImageData().imageToByteBuffer(
                        ImageIO.read(new File(VEngine.cfg.g("modhome") + "/icon.png")), false, false, null),

                        new ImageIOImageData().imageToByteBuffer(
                                ImageIO.read(new File(VEngine.cfg.g("modhome") + "/icon.png")), false, false,
                                null) });
                Display.setFullscreen(true);
                Display.setResizable(true);
                Display.create();
                GL11.glMatrixMode(GL11.GL_PROJECTION);
                GL11.glLoadIdentity();
                GL11.glOrtho(0, 1, 1, 0, 1, -1);
                GL11.glMatrixMode(GL11.GL_MODELVIEW);

                VGraphics g = new VGraphics();

                Random r = new Random();

                while (!Display.isCloseRequested()) {

                    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                    GL11.glEnable(GL11.GL_TEXTURE_2D); // ?  ? ? ?.
                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    GL11.glEnable(GL11.GL_BLEND);
                    WIDTH = Display.getWidth();
                    HEIGHT = Display.getHeight();
                    vgm.render(g);

                    Display.update();
                }
                Display.destroy();
                System.exit(0);
            } catch (LWJGLException ex) {
                Logger.getLogger(VGraphics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(VGraphics.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    };
    renderingThread.setPriority(Thread.MAX_PRIORITY);
    renderingThread.start();

}

From source file:zildo.fwk.gfx.Ortho.java

License:Open Source License

public void setOrthographicProjection(boolean p_zoom) {
    if (!orthoSetUp) {
        // switch to projection mode
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        // save previous matrix which contains the
        // settings for the perspective projection
        GL11.glPushMatrix();//from  w ww. ja v  a  2 s .c  o  m
        // reset matrix
        GL11.glLoadIdentity();
        // set a 2D orthographic projection
        if (p_zoom) {
            GL11.glOrtho(0, w / 2, 0, h / 2, -99999, 99999);
            GL11.glTranslatef(0, -h / 2, 0);
        } else {
            GL11.glOrtho(0, w, 0, h, -99999, 99999);
        }
        // invert the y axis, down is positive
        // GL11.glScalef(1, -1, 1);
        // GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        // mover the origin from the bottom left corner
        // to the upper left corner
        GL11.glTranslatef(0, h, 0);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);

        orthoSetUp = true;
    }
}

From source file:zildo.platform.opengl.LwjglOrtho.java

License:Open Source License

@Override
public void setOrthographicProjection(boolean p_zoom) {
    if (!orthoSetUp) {
        // switch to projection mode
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        // save previous matrix which contains the
        // settings for the perspective projection
        GL11.glPushMatrix();//from  w  w  w .  j  a  va  2 s.c om
        // reset matrix
        GL11.glLoadIdentity();
        // set a 2D orthographic projection
        GL11.glViewport(0, 0, Zildo.screenX, Zildo.screenY);
        if (p_zoom) {
            GL11.glOrtho(0, w / 2, 0, h / 2, -99999, 99999);
            GL11.glTranslatef(0, -h / 2, 0);
        } else {
            GL11.glOrtho(0, w, 0, h, -99999, 99999);
        }
        // invert the y axis, down is positive
        // GL11.glScalef(1, -1, 1);
        // GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        // mover the origin from the bottom left corner
        // to the upper left corner
        GL11.glTranslatef(0, h, 0);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);

        orthoSetUp = true;
    }
}

From source file:zsawyer.mods.stereoscopic3d.MinecraftCopy.java

License:Open Source License

/**
 * Displays a new screen./* www  . j a  v a2  s  . c  o  m*/
 */
public static void loadScreen() throws LWJGLException {
    ScaledResolution var1 = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    GL11.glClear(16640);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, var1.getScaledWidth_double(), var1.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
    GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
    GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_FOG);
    Tessellator var2 = Tessellator.instance;
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture("/title/mojang.png"));
    var2.startDrawingQuads();
    var2.setColorOpaque_I(16777215);
    var2.addVertexWithUV(0.0D, (double) mc.displayHeight, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV((double) mc.displayWidth, (double) mc.displayHeight, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV((double) mc.displayWidth, 0.0D, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
    var2.draw();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    var2.setColorOpaque_I(16777215);
    short var3 = 256;
    short var4 = 256;
    mc.scaledTessellator((var1.getScaledWidth() - var3) / 2, (var1.getScaledHeight() - var4) / 2, 0, 0, var3,
            var4);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    Display.swapBuffers();
}