Example usage for com.badlogic.gdx.graphics GL10 glPushMatrix

List of usage examples for com.badlogic.gdx.graphics GL10 glPushMatrix

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics GL10 glPushMatrix.

Prototype

public void glPushMatrix();

Source Link

Usage

From source file:com.digitale.mygdxgame.SplashRenderer.java

License:Open Source License

private void renderSun(GL10 gl, float radius, float x, float y, float z, Application app) {

    gl.glDisable(GL10.GL_LIGHTING);// w  w  w . j a va2 s.  c  o m
    radius = radius * worldscale;
    sunTexture.bind();
    gl.glPushMatrix();
    //move away from origin
    gl.glTranslatef(x, y, z);
    //scale to size of earth
    gl.glScalef(radius, radius, radius);
    gl.glDisable(GL10.GL_CULL_FACE);

    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    gl.glPushMatrix();
    gl.glDisable(GL10.GL_LIGHTING);
    //gl.glRotatef((Splash.planetmove/10), .25f, .75f, .5f);
    sunMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

}

From source file:com.digitale.mygdxgame.SplashRenderer.java

License:Open Source License

/**
* render ship jets/*from ww  w . j ava 2  s.c o  m*/
* @param basescale :- scale factor for jet size before applying thrust
* @param length  :- scale factor for jet length, typically thrust value + random noise
* @param x The jet's x-coordinate.
* @param y The jet's  y-coordinate.
* @param z The jet's  z-coordinate.
* @return The product, in a vector <#, #, #, 1>, representing the
* rotated point.
*/
private void renderJet(GL10 gl, float baseScale, float length, float x, float y, float z, Application app) {
    jetTexture.bind();
    gl.glPushMatrix();
    //move away from origin
    gl.glTranslatef(x, y, z);
    //scale to size of earth
    gl.glScalef(baseScale, baseScale, baseScale * length);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    gl.glDisable(GL10.GL_LIGHTING);
    //gl.glRotatef((Splash.planetmove/10), .25f, .75f, .5f);
    jetMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
    //gl.glEnable(GL10.GL_DEPTH_TEST);
}

From source file:org.interreg.docexplore.reader.book.BookEngineRenderer.java

License:Open Source License

public void render() {
    BookSpecification spec = engine.book;
    BookModel model = engine.model;//w w  w  .j a va2 s.com

    GL10 gl = Gdx.gl10;

    cnt += .01;

    engine.attractor.attract(engine.camera, .075f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    engine.camera.apply(gl);

    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_LIGHT0);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, ambient);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, diffuse);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, position);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glTranslatef((float) engine.globalTrans, 0, 0);
    gl.glRotatef((float) (engine.globalRot * 180 / Math.PI), 0, 1, 0);

    boolean pageIsActive = engine.hand.pageIsActive;
    int leftPageIndex = model.leftStack.nStackPages > 0 ? 1 + 2 * (model.leftStack.nStackPages - 1) : -1;
    int rightPageIndex = model.rightStack.nStackPages > 0 ? leftPageIndex + 1 + (pageIsActive ? 2 : 0) : -1;

    Bindable leftPage = leftPageIndex >= 0 ? spec.pages.get(leftPageIndex).getTexture() : null;
    Bindable rightPage = rightPageIndex >= 0 ? spec.pages.get(rightPageIndex).getTexture() : null;
    Bindable pageFront = pageIsActive ? spec.pages.get(leftPageIndex + 1).getTexture() : null;
    Bindable pageBack = pageIsActive ? spec.pages.get(leftPageIndex + 2).getTexture() : null;

    Gdx.gl10.glEnable(GL10.GL_CULL_FACE);
    gl.glPolygonMode(GL10.GL_FRONT_AND_BACK, GL10.GL_FILL);

    boolean zoomed = engine.zoom.active;
    model.render(leftPage, rightPage, pageFront, pageBack, engine.book.coverTex, engine.book.innerCoverTex,
            zoomed ? null : leftRoiMask, zoomed ? null : rightRoiMask);

    for (Component extension : engine.components)
        extension.render();

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
}

From source file:org.interreg.docexplore.reader.book.ParchmentEngine.java

License:Open Source License

public void render() {
    if (book == null || !active)
        return;/*ww w  . j  av  a 2s.  c  om*/

    GL10 gl = Gdx.gl10;

    cnt += .01;

    globalFrame.attract(camera, .075f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    camera.apply(gl);

    Gdx.gl10.glEnable(GL10.GL_TEXTURE_2D);
    Gdx.gl10.glDisable(GL10.GL_CULL_FACE);
    Gdx.gl10.glDisable(GL10.GL_LIGHTING);
    gl.glPolygonMode(GL10.GL_FRONT_AND_BACK, GL10.GL_FILL);

    int page = (int) (-camera.position.y * book.aspectRatio);
    int p0 = Math.max(0, page - pageSpread), p1 = Math.min(book.pages.size() - 1, page + pageSpread);
    for (int i = p0; i <= p1; i++) {
        book.pages.get(i).getTexture().bind();
        GfxUtils.fillQuad(-.5f, -(float) (i / book.aspectRatio), 0, 0, .5f,
                -(float) ((i + 1) / book.aspectRatio), 1, 1);
    }

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
}

From source file:org.interreg.docexplore.reader.book.roi.ROIOverlay.java

License:Open Source License

public void render() {
    if (alpha < alphaGoal)
        alpha += .02f;//from  ww w.j ava2 s . c  o m
    else if (alpha > alphaGoal)
        alpha -= .02f;
    alpha = alpha < 0 ? 0 : alpha > 1 ? 1 : alpha;
    if (alpha == 0)
        return;
    GL10 gl = Gdx.gl10;

    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glOrthof(-1, 1, -1, 1, -1, 1);

    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glColor4f(0, 0, 0, .75f * alpha);
    doQuad(-2 * offsetMargin, 1, 1, -1);

    float y0 = 0;
    gl.glEnable(GL10.GL_TEXTURE_2D);

    gl.glColor4f(1, 1, 1, alpha);
    for (OverlayElement element : elements) {
        float w = elementWidth(element);
        float h = elementHeight(w, element);
        if (element.bind()) {
            doQuad(-offsetMargin + .5f - .5f * w, 1 - y0 + offset, -offsetMargin + .5f + .5f * w,
                    1 - y0 - h + offset);
            y0 += h + vmargin * element.marginFactor();
        }
    }

    if (offset > 0) {
        up.bind();
        gl.glColor4f(1, 1, 1, .5f * alpha);
        float bw = .05f;
        doQuad(1 - bw, 1, 1, 1 - (bw * Gdx.graphics.getWidth() / Gdx.graphics.getHeight()));
    }
    if (offset < maxOffset) {
        down.bind();
        gl.glColor4f(1, 1, 1, .5f * alpha);
        float bw = .05f;
        doQuad(1 - bw, (bw * Gdx.graphics.getWidth() / Gdx.graphics.getHeight()) - 1, 1, -1);
    }

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();

    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}

From source file:org.interreg.docexplore.reader.book.roi.ROIOverlay.java

License:Open Source License

static void doQuad(float x1, float y1, float x2, float y2) {
    if (quad == null)
        quad = GfxUtils.buildQuad(0, 0, 0, 0, 1, 1, 1, 1);

    GL10 gl = Gdx.gl10;
    gl.glMatrixMode(GL10.GL_MODELVIEW);/*  w ww.  ja v a 2s .co  m*/
    gl.glPushMatrix();
    gl.glTranslatef(x1, y1, 0);
    gl.glScalef(x2 - x1, y2 - y1, 1);
    quad.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
}

From source file:org.interreg.docexplore.reader.gfx.Camera.java

License:Open Source License

public void setup() {
    GL10 gl = Gdx.gl10;
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();/*from   w  w  w  .  j a v a  2 s  .c o  m*/
    gl.glFrustumf(-.25f, .25f, -.25f, .25f, .25f, 100f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();

    double[] buf = Math3D.getVector3d(), up = Math3D.getVector3d();
    Math3D.crossProduct(Math3D.basej, dir, buf);
    Math3D.crossProduct(dir, buf, up);
    Math3D.normalize(up, up);

    position.set((float) eye[0], (float) eye[1], (float) eye[2]);
    target.set((float) (eye[0] + dir[0]), (float) (eye[1] + dir[1]), (float) (eye[2] + dir[2]));
    cup.set((float) up[0], (float) up[1], (float) up[2]);
    model.setToLookAt(position, target, cup);
    //      Gdx.glu.gluLookAt(gl, (float)eye[0], (float)eye[1], (float)eye[2], 
    //         (float)(eye[0]+dir[0]), (float)(eye[1]+dir[1]), (float)(eye[2]+dir[2]), 
    //         (float)up[0], (float)up[1], (float)up[2]);

    Math3D.freeVector3d(buf);
    Math3D.freeVector3d(up);
}

From source file:org.interreg.docexplore.reader.gui.GuiLayer.java

License:Open Source License

public void render() {
    GL10 gl = Gdx.gl10;

    gl.glMatrixMode(GL10.GL_MODELVIEW);/*from  w  w  w . j  a va2  s  .c  o  m*/
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glOrthof(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, -1, 1);

    for (Widget widget : widgets)
        widget.render();

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();
}

From source file:org.interreg.docexplore.reader.InputManager.java

License:Open Source License

public void render() {
    if (cursor == null)
        return;//from  w ww.j a  v  a 2s .  com

    GL10 gl = Gdx.gl10;
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glOrthof(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, -1, 1);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();

    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glColor4f(1, 1, 1, 1);

    if (cursor != null) {
        cursor.bind();
        int my = Gdx.graphics.getHeight() - Mouse.getY();
        GfxUtils.fillQuad(Mouse.getX() - cursorHotSpot[0], my - cursorHotSpot[1], 0, 0,
                Mouse.getX() - cursorHotSpot[0] + cursor.width(), my - cursorHotSpot[1] + cursor.height(), 1,
                1);
    }

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();

    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glEnable(GL10.GL_DEPTH_TEST);

    app.debugGfx.render();
}

From source file:org.interreg.docexplore.reader.shelf.ShelfEngine.java

License:Open Source License

public synchronized void render() {
    if (alpha < .01)
        return;/*from ww w  .j ava2s .c o m*/

    GL10 gl = Gdx.gl10;

    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_STENCIL_TEST);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glOrthof(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, -1, 1);

    gl.glEnable(GL10.GL_TEXTURE_2D);

    if (textures == null)
        cursor = -1;
    else if (cursor > textures.length)
        cursor = textures.length - 1;
    if (cursor >= 0) {
        for (int i = 0; i < textures.length; i++) {
            int j = (textures.length / 2 + (i + 1) / 2 * (i % 2 == 0 ? 1 : -1)) % textures.length;
            int index = (cursor + j) % textures.length;
            Texture tex = textures[index];
            if (tex != null) {
                double x = getEntryX(j);
                double y = getEntryY(j);
                float k = (float) (.75 + .125 * (y + 1));
                k *= k;
                //float colk = (float)(.5*(y+1));
                gl.glColor4f(1, 1, 1, alpha * k);
                float x0 = (float) (.5 * (Gdx.graphics.getWidth() - k * tex.width())
                        + x * Gdx.graphics.getWidth() / 4);
                float y0 = (float) (.5 * (Gdx.graphics.getHeight() - k * tex.height())
                        + y * Gdx.graphics.getHeight() / 5);
                tex.bind();
                GfxUtils.fillQuad(x0, y0, 0, 0, x0 + k * tex.width(), y0 + k * tex.height(), 1, 1);
            }
        }
    }

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();

    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}