Example usage for org.lwjgl.opengl GL11 glLoadIdentity

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

Introduction

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

Prototype

public static native void glLoadIdentity();

Source Link

Document

Sets the current matrix to the identity matrix.

Usage

From source file:zildo.fwk.gfx.filter.BlendFilter.java

License:Open Source License

@Override
public boolean renderFilter() {
    int currentSquareSize = getCurrentSquareSize();

    if (currentSquareSize == 1) {
        return true;
    }//from   ww w  . j a  va 2  s  .  c  o  m
    fbo.endRendering();

    // Get on top of screen and disable blending
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 0);

    GL11.glColor3f(1f, 1f, 1f);

    // Draw squares
    int nSquareX = Zildo.viewPortX / currentSquareSize;
    int nSquareY = Zildo.viewPortY / currentSquareSize;
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glBegin(GL11.GL_QUADS);
    for (int i = 0; i < nSquareY + 1; i++) {
        for (int j = 0; j < nSquareX + 1; j++) {
            ClientEngineZildo.ortho.boxTexturedOpti(j * currentSquareSize, i * currentSquareSize,
                    currentSquareSize, currentSquareSize, (j * currentSquareSize) / (float) ScreenFilter.realX,
                    (i * currentSquareSize) / (float) ScreenFilter.realY, 0, 0);
        }
    }
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);

    return true;
}

From source file:zildo.fwk.gfx.filter.BlurFilter.java

License:Open Source License

@Override
public boolean renderFilter() {

    boolean result = true;

    fbo.endRendering();//from   w  w w . j a v a 2  s  . c o m

    // Get on top of screen and disable blending
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 0);

    //GL11.glDisable(GL11.GL_BLEND);

    if (nImagesSaved < nImages) {
        // All images are not stored yet. So we just display the current one.
        nImagesSaved++;
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texBuffer[currentImage]);
        super.render();
        result = false;
    } else {
        super.focusOnZildo();

        // Draw each image, with intensified colors
        for (int i = 0; i < nImages; i++) {
            float coeff = startCoeff + i * (incCoeff / nImages);
            GL11.glColor4f(coeff, coeff, coeff, 1.0f);
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, texBuffer[(i + currentImage + 1) % nImages]);
            super.render();
            if (i == 0) {
                // Enable blend from second one
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); //_MINUS_SRC_ALPHA);
            }
        }

    }

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);

    // Switch
    currentImage = (currentImage + 1) % nImages;

    return result;
}

From source file:zildo.fwk.gfx.filter.CircleFilter.java

License:Open Source License

@Override
public boolean renderFilter() {

    // Get on top of screen and disable blending
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();//from w  ww .j  ava 2  s.co m
    GL11.glTranslatef(0, -sizeY, 1);

    GL11.glColor3f(1f, 1f, 1f);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glBegin(GL11.GL_QUADS);
    int radius = (int) (coeffLevel * (255 - getFadeLevel())); // + 20;
    int radiusSquare = (int) Math.pow(radius, 2);
    int col = 0;

    int sizeA = center.y - radius;
    int sizeB = Zildo.viewPortY - (center.y + radius);

    // 1) Draw the two areas outside the circle
    if (sizeA > 0) {
        ClientEngineZildo.ortho.boxOpti(0, 0, Zildo.viewPortX, sizeA, 2, null);
    }
    if (sizeB > 0) {
        ClientEngineZildo.ortho.boxOpti(0, center.y + radius, Zildo.viewPortX, sizeB, 2, null);
    }

    // 2) Draw the circle area
    int startI = Math.max(0, sizeA);
    int endI = Math.min(Zildo.viewPortY, center.y + radius);

    for (int i = startI; i < endI; i++) {
        int start = (int) Math.pow(i - center.y, 2);

        // Calculate DELTA and 2 roots x1 & x2
        double delta = 4 * (radiusSquare - start);
        double squareRootDelta = Math.sqrt(delta);
        int x1 = (int) (center.x - squareRootDelta / 2);
        int x2 = (int) (center.x + squareRootDelta / 2);
        ClientEngineZildo.ortho.boxOpti(0, i, x1, 1, col, null);
        ClientEngineZildo.ortho.boxOpti(x2, i, Zildo.viewPortX - x2, 1, col, null);
    }
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);

    return true;
}

From source file:zildo.fwk.gfx.filter.CloudFilter.java

License:Open Source License

@Override
public boolean renderFilter() {

    super.startInitialization();
    updateTile(0, 0, u, v, Reverse.NOTHING);
    this.endInitialization();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();/*from   ww  w .ja v  a 2s  .com*/
    GL11.glTranslatef(0, -sizeY, 1);

    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    float colorFactor = 0.2f;
    GL11.glColor4f(colorFactor, colorFactor, colorFactor, 0.1f);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, ClientEngineZildo.tileEngine.texCloudId);
    super.render();

    GL11.glDisable(GL11.GL_BLEND);

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    return true;
}

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();/*ww  w  .j av a  2s .co 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.fwk.opengl.OpenGLZildo.java

License:Open Source License

@Override
public void render(boolean p_clientReady) {

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear
    // The/*from w  w  w .j  a  va  2  s .co  m*/
    // Screen
    // And
    // The
    // Depth
    // Buffer

    GL11.glLoadIdentity(); // Reset The Projection Matrix

    // invert the y axis, down is positive
    float zz = z * 5.0f;
    if (zz != 0.0f) {
        GL11.glTranslatef(-zoomPosition.getX() * zz, zoomPosition.getY() * zz, 0.0f);
    }
    GL11.glScalef(1 + zz, -1 - zz, 1);
    if (ClientEngineZildo.filterCommand != null) {
        ClientEngineZildo.filterCommand.doPreFilter();
    }

    clientEngineZildo.renderFrame(awt);
    if (!p_clientReady && !awt) {
        clientEngineZildo.renderMenu();
    }

    if (ClientEngineZildo.filterCommand != null) {
        ClientEngineZildo.filterCommand.doFilter();
        ClientEngineZildo.filterCommand.doPostFilter();
    }

    if (framerate != 0) {
        Display.sync(framerate);
    }

    if (!awt) {
        Display.update();
    }
}

From source file:zildo.platform.filter.LwjglBilinearFilter.java

License:Open Source License

@Override
public boolean renderFilter() {
    graphicStuff.fbo.endRendering();//from  w w w.  j  a v  a  2  s .  c  om

    // Select right texture
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    // Disable blend
    GL11.glDisable(GL11.GL_BLEND);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 1);

    // This filter is in charge to alter all screen colors
    Vector3f v = ClientEngineZildo.ortho.getFilteredColor();
    GL11.glColor3f(v.x, v.y, v.z);

    // Draw texture with depth
    super.render();

    // Reset full color
    GL11.glColor3f(1, 1, 1);

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    return true;
}

From source file:zildo.platform.filter.LwjglBlendFilter.java

License:Open Source License

@Override
public boolean renderFilter() {
    int currentSquareSize = getCurrentSquareSize();

    graphicStuff.fbo.endRendering();/*from  ww w  .java  2 s.co m*/

    // Get on top of screen and disable blending
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 0);

    Vector3f v = ClientEngineZildo.ortho.getFilteredColor();
    GL11.glColor3f(v.x, v.y, v.z);

    // Draw squares
    int nSquareX = Zildo.viewPortX / currentSquareSize;
    int nSquareY = Zildo.viewPortY / currentSquareSize;
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    if (currentSquareSize == 1) { // Square size=1 means this effect is useless !
        super.render();
    } else {
        GL11.glBegin(GL11.GL_QUADS);

        for (int i = 0; i < nSquareY + 1; i++) {
            for (int j = 0; j < nSquareX + 1; j++) {
                ClientEngineZildo.ortho.boxTexturedOpti(j * currentSquareSize, i * currentSquareSize,
                        currentSquareSize, currentSquareSize,
                        (j * currentSquareSize) / (float) ScreenFilter.realX,
                        (i * currentSquareSize) / (float) ScreenFilter.realY, 0, 0);
            }
        }
        GL11.glEnd();
    }
    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);

    return true;
}

From source file:zildo.platform.filter.LwjglBlurFilter.java

License:Open Source License

@Override
public boolean renderFilter() {

    boolean result = true;

    graphicStuff.fbo.endRendering();//from   w w w  .  j  a va 2  s. c  om

    // Get on top of screen and disable blending
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 0);

    //GL11.glDisable(GL11.GL_BLEND);

    if (nImagesSaved < nImages) {
        // All images are not stored yet. So we just display the current one.
        nImagesSaved++;
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texBuffer[currentImage]);
        super.render();
        result = false;
    } else {
        super.focusOnZildo();

        // Draw each image, with intensified colors
        for (int i = 0; i < nImages; i++) {
            float coeff = startCoeff + i * (incCoeff / nImages);
            GL11.glColor4f(coeff, coeff, coeff, 1.0f);
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, texBuffer[(i + currentImage + 1) % nImages]);
            super.render();
            if (i == 0) {
                // Enable blend from second one
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); //_MINUS_SRC_ALPHA);
            }
        }

    }

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);

    // Switch
    currentImage = (currentImage + 1) % nImages;

    return result;
}

From source file:zildo.platform.filter.LwjglCircleFilter.java

License:Open Source License

@Override
public boolean renderFilter() {
    graphicStuff.fbo.endRendering();/*from  ww w .j  a  va2  s.  c o m*/

    // Get on top of screen and disable blending
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 1);

    Vector3f curColor = ClientEngineZildo.ortho.getFilteredColor();
    GL11.glColor3f(curColor.x, curColor.y, curColor.z);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    super.render();
    GL11.glBegin(GL11.GL_QUADS);
    int radius = (int) (coeffLevel * (255 - getFadeLevel())); // + 20;
    int radiusSquare = (int) Math.pow(radius, 2);
    int col = 0;

    int sizeA = center.y - radius;
    int sizeB = Zildo.viewPortY - (center.y + radius);

    // 1) Draw the two areas outside the circle
    if (sizeA > 0) {
        ClientEngineZildo.ortho.boxOpti(0, 0, Zildo.viewPortX, sizeA, col, null);
    }
    if (sizeB > 0) {
        ClientEngineZildo.ortho.boxOpti(0, center.y + radius, Zildo.viewPortX, sizeB, col, null);
    }

    // 2) Draw the circle area
    int startI = Math.max(0, sizeA);
    int endI = Math.min(Zildo.viewPortY, center.y + radius);

    for (int i = startI; i < endI; i++) {
        int start = (int) Math.pow(i - center.y, 2);

        // Calculate DELTA and 2 roots x1 & x2
        double delta = 4 * (radiusSquare - start);
        double squareRootDelta = Math.sqrt(delta);
        int x1 = (int) (center.x - squareRootDelta / 2);
        int x2 = (int) (center.x + squareRootDelta / 2);
        ClientEngineZildo.ortho.boxOpti(0, i, x1, 1, col, null);
        ClientEngineZildo.ortho.boxOpti(x2, i, Zildo.viewPortX - x2, 1, col, null);
    }
    GL11.glEnd();
    GL11.glPopMatrix();

    // Reset full color
    GL11.glColor3f(1, 1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);

    return true;
}