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

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

Introduction

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

Prototype

int GL_TRIANGLE_FAN

To view the source code for com.badlogic.gdx.graphics GL10 GL_TRIANGLE_FAN.

Click Source Link

Usage

From source file:com.badlogic.gdx.tests.lw.PongLW.java

License:Apache License

@Override
public void render() {
    // we update the game state so things move.
    updateGame();/*from w  w w  .  j a v a2 s . c o m*/

    // First we clear the screen
    GL10 gl = Gdx.graphics.getGL10();
    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    // Next we update the camera and set the camera matrix
    camera.update();
    camera.apply(Gdx.gl10);

    // Now we render the ball, we remember that we
    // Defined 4 vertices so we use a triangle fan
    // We also push and pop the matrix. This is not really
    // necessary as the model view matrix doesn't contain
    // anything at this point.
    gl.glPushMatrix();
    gl.glTranslatef(ball.x, ball.y, 0);
    ballMesh.render(GL10.GL_TRIANGLE_FAN);
    gl.glPopMatrix();

    // Rendering the two paddles works analogous
    gl.glPushMatrix();
    gl.glTranslatef(leftPaddle.x, leftPaddle.y, 0);
    paddleMesh.render(GL10.GL_TRIANGLE_FAN);
    gl.glPopMatrix();

    gl.glPushMatrix();
    gl.glTranslatef(rightPaddle.x, rightPaddle.y, 0);
    paddleMesh.render(GL10.GL_TRIANGLE_FAN);
    gl.glPopMatrix();

    // Finally we render the text centered at the top
    // of the screen. We use the text bounds for this.
    // For text to be transparent we have to enable blending and texturing.
    // We could setup blending once but i'm lazy :)
    spriteBatch.begin();
    // spriteBatch.drawText(font, score, Gdx.graphics.getWidth() / 2 - font.getStringWidth(score) / 2, Gdx.graphics.getHeight()
    // - font.getLineHeight(), Color.WHITE);
    spriteBatch.end();
}

From source file:com.davidykay.shootout.Renderer.java

License:Apache License

private void renderExplosions(GL10 gl, ArrayList<Explosion> explosions) {
    gl.glEnable(GL10.GL_BLEND);/*from   www  . j a va 2s.  co  m*/
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    explosionTexture.bind();
    for (int i = 0; i < explosions.size(); i++) {
        Explosion explosion = explosions.get(i);
        gl.glPushMatrix();
        gl.glTranslatef(explosion.position.x, explosion.position.y, explosion.position.z);
        explosionMesh.render(GL10.GL_TRIANGLE_FAN,
                (int) ((explosion.aliveTime / Explosion.EXPLOSION_LIVE_TIME) * 15) * 4, 4);
        gl.glPopMatrix();
    }
    gl.glDisable(GL10.GL_BLEND);
}

From source file:com.davidykay.shootout.Renderer.java

License:Apache License

private void renderBombExplosions(GL10 gl, ArrayList<Explosion> explosions) {
    gl.glEnable(GL10.GL_BLEND);//from   w  ww  .  ja v a 2s.c  o m
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    bombExplosionTexture.bind();
    for (int i = 0; i < explosions.size(); i++) {
        Explosion explosion = explosions.get(i);
        gl.glPushMatrix();
        gl.glTranslatef(explosion.position.x, explosion.position.y, explosion.position.z);
        explosionMesh.render(GL10.GL_TRIANGLE_FAN,
                (int) ((explosion.aliveTime / Explosion.EXPLOSION_LIVE_TIME) * 15) * 4, 4);
        gl.glPopMatrix();
    }
    gl.glDisable(GL10.GL_BLEND);
}

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

License:Open Source License

private void renderExplosions(GL10 gl, ArrayList<Explosion> explosions) {
    gl.glDisable(GL10.GL_CULL_FACE);/*from w  w w.  ja va2s .co m*/
    gl.glEnable(GL10.GL_BLEND);
    // gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glDisable(GL10.GL_LIGHTING);
    for (int i = 0; i < explosions.size(); i++) {
        Explosion explosion = explosions.get(i);
        gl.glPushMatrix();
        if (explosion.type == Explosion.NORMAL) {
            gl.glTranslatef(explosion.position.x, explosion.position.y, explosion.position.z);
            explosionTexture.bind();
            gl.glScalef(10, 10, 10);
            gl.glRotatef(explosion.yawAngle, 0, 1, 0);
            gl.glRotatef(explosion.pitchAngle, 1, 0, 0);
            explosionMesh.render(GL10.GL_TRIANGLE_FAN,
                    (int) ((explosion.aliveTime / explosion.explosionLiveTime) * 15) * 4, 4);

        } else if (explosion.type == Explosion.SWANSONG) {
            gl.glTranslatef(explosion.position.x, explosion.position.y, explosion.position.z);
            swansongTexture.bind();
            gl.glColor4f(1 - (explosion.aliveTime / 2), 1 - (explosion.aliveTime / 2),
                    1 - (explosion.aliveTime / 2), 1 - (explosion.aliveTime / 2));
            gl.glRotatef(explosion.yawAngle, 0, 1, 0);
            gl.glRotatef(explosion.pitchAngle, 1, 0, 0);
            gl.glScalef(explosion.scale * 10, explosion.scale * 10, explosion.scale * 10);
            sunMesh.render(GL10.GL_TRIANGLES);
            gl.glScalef(1, 1, 1);
            gl.glColor4f(1f, 1f, 1f, 1f);
        } else if (explosion.type == Explosion.RANKUP) {
            gl.glTranslatef(explosion.position.x, explosion.position.y, explosion.position.z);
            lvlupTexture.bind();
            gl.glColor4f(1 - (explosion.aliveTime / 2), 1 - (explosion.aliveTime / 2),
                    1 - (explosion.aliveTime / 2), 1 - (explosion.aliveTime / 2));
            gl.glRotatef(explosion.yawAngle, 0, 1, 0);
            gl.glRotatef(explosion.pitchAngle, 1, 0, 0);
            gl.glRotatef(explosion.aliveTime * 360f, 0, 0, 1);
            gl.glScalef(explosion.scale, explosion.scale, explosion.scale);
            sunMesh.render(GL10.GL_TRIANGLES);
            gl.glScalef(1, 1, 1);
            gl.glColor4f(1f, 1f, 1f, 1f);

        } else if (explosion.type == Explosion.LEVELUP) {
            gl.glTranslatef(explosion.position.x, explosion.position.y, explosion.position.z);
            lvlupTexture.bind();
            gl.glColor4f(1 - (explosion.aliveTime / 4), .5f, //1 - (explosion.aliveTime / 2),
                    .5f - (explosion.aliveTime / 2), 1 - (explosion.aliveTime / 2));
            gl.glRotatef(explosion.yawAngle, 0, 1, 0);
            gl.glRotatef(explosion.pitchAngle, 1, 0, 0);
            gl.glRotatef(explosion.aliveTime * 360f, 0, 0, 1);
            gl.glScalef(explosion.scale, explosion.scale, explosion.scale);
            sunMesh.render(GL10.GL_TRIANGLES);
            gl.glScalef(1, 1, 1);
            gl.glColor4f(1f, 1f, 1f, 1f);
        }
        gl.glPopMatrix();
    }
    gl.glDisable(GL10.GL_BLEND);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glEnable(GL10.GL_LIGHTING);
}

From source file:com.explatcreations.sft.graphics.Fbo.java

License:Open Source License

public void drawSimple(final Shader shader, final Mesh mesh, IAction func) {
    draw(func);/*from   w ww .  j  a v a  2s . c  om*/

    shader.draw(new IAction() {
        @Override
        public void eval() {
            getTexture().bind();
            mesh.render(shader.getShader(), GL10.GL_TRIANGLE_FAN);
        }
    });

}

From source file:com.explatcreations.sft.graphics.ScreenStretcher.java

License:Open Source License

public void render() {
    fbo.draw(new IAction() {
        @Override/*from ww w . j a  v a2  s  . co  m*/
        public void eval() {
            for (IAction layer : layers) {
                layer.eval();
            }
        }
    });
    shader.draw(new IAction() {
        @Override
        public void eval() {
            fbo.getTexture().bind(0);
            mesh.render(shader.getShader(), GL10.GL_TRIANGLE_FAN);
        }
    });

    layers.clear();
}

From source file:com.explatcreations.sft.graphics.Sepiaizer.java

License:Open Source License

private void shaderDraw() {
    Renderer.batch.end();//from w w  w .  jav  a2s  .c  o m
    shader.draw(new IAction() {
        @Override
        public void eval() {
            fbo.getTexture().bind(0);
            mesh.render(shader.getShader(), GL10.GL_TRIANGLE_FAN);
        }
    });
    Renderer.batch.begin();
}

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

License:Open Source License

public static void fillQuad(float x1, float y1, float s1, float t1, float x2, float y2, float s2, float t2) {
    doQuad(x1, y1, s1, t1, x2, y2, s2, t2, GL10.GL_TRIANGLE_FAN);
}