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

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

Introduction

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

Prototype

int GL_TRIANGLES

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

Click Source Link

Usage

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

License:Open Source License

private void renderDusts(GL10 gl, ArrayList<Dust> dusts) {

    gl.glEnable(GL10.GL_BLEND);//from w  w  w.jav  a2  s.co m
    // gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_LIGHTING);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

    dustTexture.bind();
    for (int i = 0; i < dusts.size(); i++) {
        Dust dust = dusts.get(i);
        if (camera.frustum.pointInFrustum(dust.position)) {
            gl.glPushMatrix();
            gl.glColor4f(dust.colour, dust.colour, dust.colour, 1);
            gl.glTranslatef(dust.position.x, dust.position.y, dust.position.z);
            gl.glRotatef(dust.yawAngle + 180, 0, 1, 0);
            gl.glRotatef(dust.pitchAngle, 1, 0, 0);
            gl.glScalef(dust.size, dust.size, dust.size);
            sunMesh.render(GL10.GL_TRIANGLES);
            gl.glPopMatrix();
        }
    }
    gl.glColor4f(1, 1, 1, 1);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_BLEND);
    gl.glEnable(GL10.GL_LIGHTING);
}

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

License:Open Source License

@SuppressWarnings("unused")
private void renderTrails(GL10 gl, ArrayList<Trail> trails) {
    gl.glColor4f(0, 1, 1, 1);/*  ww  w . ja  v  a  2  s  .c o m*/
    jetTexture.bind();
    gl.glEnable(GL10.GL_BLEND);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_LIGHTING);
    gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE);
    jetTexture.bind();
    for (int i = 0; i < trails.size(); i++) {
        Trail trail = trails.get(i);
        gl.glPushMatrix();
        gl.glRotatef(trail.yawAngle, 0, 1, 0);
        gl.glRotatef(trail.pitchAngle, 1, 0, 0);
        gl.glTranslatef(trail.position.x, trail.position.y, trail.position.z);

        float scale = (Trail.TRAIL_LIFE - trail.life) / 4;
        gl.glScalef(scale, scale, scale * 2.5f);
        jetMesh.render(GL10.GL_TRIANGLES);
        gl.glPopMatrix();
    }
    gl.glColor4f(1, 1, 1, 1);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_BLEND);
    gl.glEnable(GL10.GL_LIGHTING);
}

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);/* w ww  .  j  a  v a  2 s  .  c  o 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.digitale.mygdxgame.SplashRenderer.java

License:Open Source License

private void renderStaticShip(GL10 gl, Application app) {

    shipTexture.bind();/*from   ww w .j  av a2s  . co m*/
    gl.glPushMatrix();
    gl.glTranslatef(0, 0, 0);
    shipMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    float noise = (float) Math.random() / 2;
    renderJet(gl, 2.3f, 1f + noise, 1.1f, -.5f, 1.8f, app);
    noise = (float) Math.random() / 2;
    renderJet(gl, 2.3f, 1f + noise, -1.1f, -.5f, 1.8f, app);

}

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

License:Open Source License

private void renderSky(GL10 gl) {

    gl.glDisable(GL10.GL_LIGHTING);/* w  w  w . ja  v  a 2s. c o m*/
    skyTexture.bind();
    gl.glColor4f(1, 1, 1, 1);

    gl.glPushMatrix();
    gl.glTranslatef(0, 0, 0);
    gl.glScalef(100f, 100f, 100f);
    skyMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
}

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

License:Open Source License

private void renderPlanet(GL10 gl, String texture, boolean uvtype, float radius, float x, float y, float z,
        Application app) {//www  .j av  a  2 s .  c  o m
    radius = radius * worldscale;

    if (texture.equals("earth")) {
        //render earth/jupiter  texture
        planetTexture.bind();
    } else if (texture.equals("sun")) {
        //render mars/sun  texture
        planetTexture.bind();
    }

    gl.glPushMatrix();
    //move away from origin
    gl.glTranslatef(x, y, z);
    //scale to 10% size of earth
    gl.glScalef(radius, radius, radius);
    gl.glRotatef((Splash.planetmove / 10) - 180, 0, 1, 0);
    if (uvtype == true) {
        //render lower planet texture
        planetMesh.render(GL10.GL_TRIANGLES);
    } else {
        //render upper planet texture
        planetMesh02.render(GL10.GL_TRIANGLES);
    }
    gl.glPopMatrix();

}

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);//from   w  w  w  .  j  a  va 2 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   www.  j  a  va 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:com.eightbitmage.lwtemplate.WaterRipplesLW.java

License:Apache License

@Override
public void render() {
    GL10 gl = Gdx.graphics.getGL10();/*from  w ww.  j  a  v  a  2s  . c  o m*/
    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    camera.update();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadMatrixf(camera.combined.val, 0);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

    accum += Gdx.graphics.getDeltaTime();
    while (accum > TICK) {
        updateWater();
        float[][] tmp = curr;
        curr = last;
        last = tmp;
        accum -= TICK;
    }

    float alpha = accum / TICK;
    interpolateWater(alpha);

    updateVertices(intp);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    texture.bind();
    mesh.render(GL10.GL_TRIANGLES);

    batch.begin();
    // batch.drawText(font, "fps: " + Gdx.graphics.getFramesPerSecond(), 10,
    // 20, Color.WHITE);
    batch.end();
}

From source file:com.jwatson.omnigame.graphics.CustomBatch.java

License:Apache License

private void renderMesh() {
    if (idx == 0)
        return;//from ww  w  . j av  a  2  s.c  o  m

    renderCalls++;
    totalRenderCalls++;
    int spritesInBatch = idx / 32;
    if (spritesInBatch > maxSpritesInBatch)
        maxSpritesInBatch = spritesInBatch;

    lastTexture.bind();
    mesh.setVertices(vertices, 0, idx);
    mesh.getIndicesBuffer().position(0);
    mesh.getIndicesBuffer().limit(spritesInBatch * 6);

    if (blendingDisabled) {
        Gdx.gl.glDisable(GL20.GL_BLEND);
    } else {
        Gdx.gl.glEnable(GL20.GL_BLEND);
        if (blendSrcFunc != -1)
            Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc);
    }

    if (Gdx.graphics.isGL20Available()) {
        if (customShader != null)
            mesh.render(customShader, GL10.GL_TRIANGLES, 0, spritesInBatch * 6);
        else
            mesh.render(shader, GL10.GL_TRIANGLES, 0, spritesInBatch * 6);
    } else {
        mesh.render(GL10.GL_TRIANGLES, 0, spritesInBatch * 6);
    }

    idx = 0;
    currBufferIdx++;
    if (currBufferIdx == buffers.length)
        currBufferIdx = 0;
    mesh = buffers[currBufferIdx];
}