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 renderStaticShip(GL10 gl, Ship ship, Application app, String shipname) {
    if (ship.isExploding)
        return;//ww  w .  ja  v  a2  s .co m

    if (shipname.equals("stickleback")) {
        shipTexture01.bind();
    } else if (shipname.equals("salx")) {
        shipTexture02.bind();

    } else if (shipname.equals("cynomys")) {
        shipTexture03.bind();
    } else if (shipname.equals("squirrel")) {
        gl.glDisable(GL10.GL_CULL_FACE);
        squirrelTexture.bind();
    }
    gl.glPushMatrix();
    gl.glTranslatef(0, 0, 0);

    if (shipname.equals("stickleback")) {
        shipMesh01.render(GL10.GL_TRIANGLES);
    } else if (shipname.equals("salx")) {
        shipMesh02.render(GL10.GL_TRIANGLES);
    } else if (shipname.equals("cynomys")) {
        shipMesh03.render(GL10.GL_TRIANGLES);

    } else if (shipname.equals("squirrel")) {
        squirrelMesh.render(GL10.GL_TRIANGLES);
    }
    gl.glPopMatrix();
}

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

License:Open Source License

private void renderHangar(GL10 gl, Ship ship, Application app) {
    if (ship.isExploding)
        return;/*from w w w . j a v a2  s  .c om*/
    // render hangar
    hangarTexture.bind();
    gl.glPushMatrix();
    hangarMesh.render(GL10.GL_TRIANGLES);

    // do forcefield
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);

    gl.glDisable(GL10.GL_LIGHTING);

    forcefieldMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_CULL_FACE);
}

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

License:Open Source License

private void renderSky(GL10 gl, Ship ship, Application app) {

    gl.glDisable(GL10.GL_LIGHTING);/*from   www .  ja v a 2  s  .com*/
    skyTexture.bind();
    gl.glColor4f(1, 1, 1, 1);

    gl.glPushMatrix();
    gl.glTranslatef(Ship.position.x, Ship.position.y, Ship.position.z);
    gl.glScalef(155f, 155f, 155f);
    skyMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
}

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

License:Open Source License

private void renderPlanet(GL10 gl, String texture, boolean uvtype, float radius, float x, float y, float z) {
    radius = radius * worldscale;/*from   ww w  .j a v a2s.c  om*/

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

    gl.glPushMatrix();
    // move away from origin
    gl.glTranslatef(x, y, z);
    // scale to 10% size of earth
    gl.glScalef(radius, radius, radius);

    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.Renderer.java

License:Open Source License

private void renderStation(GL10 gl, String texture, boolean uvtype, float radius, float x, float y, float z) {
    radius = radius * worldscale;//from  ww w.j  av  a 2s.co  m

    if (texture.equals("station01")) {
        // render earth/jupiter texture
        stationTexture.bind();
    } else if (texture.equals("sun")) {
        // render mars/sun texture
        planetTexture02.bind();
    }
    // render station
    gl.glPushMatrix();
    // move away from origin
    gl.glTranslatef(x, y, z);
    // scale to 10% size of earth
    gl.glScalef(radius, radius, radius);
    gl.glRotatef(Station.yawAngle, 0, 1, 0);
    stationMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();

    // render station forcefield
    // gl.glPushMatrix();
    // rendermode for glow

    // gl.glEnable(GL10.GL_BLEND);
    // gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    // gl.glPushMatrix();
    // gl.glDisable(GL10.GL_LIGHTING);
    // gridTexture.bind();
    // gl.glColor4f(.5f, .5f, 1f, 1f);
    // gl.glScalef(radius * 1.2f, radius * 1.2f, radius * 1.2f);
    // doubleside render
    // gl.glDisable(GL10.GL_CULL_FACE);
    // gl.glRotatef(-Station.yawAngle, 0, 1, 0);
    // moonMesh.render(GL10.GL_TRIANGLES);
    // gl.glPopMatrix();
    // gl.glColor4f(1, 1, 1, 1);
    // doubleside render off
    // gl.glEnable(GL10.GL_CULL_FACE);
    // gl.glEnable(GL10.GL_LIGHTING);
}

From source file:com.digitale.mygdxgame.Renderer.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 ww .  j  a v  a 2 s .c o m*/
    radius = radius * worldscale;
    planetTexture02.bind();
    gl.glPushMatrix();
    // move away from origin
    gl.glTranslatef(x, y, z);
    // scale to size of earth
    gl.glScalef(radius, radius, radius);
    planetMesh02.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
}

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

License:Open Source License

@SuppressWarnings("unused")
private void renderMoon(GL10 gl, float radius, float x, float y, float z) {
    radius = radius * worldscale;/*w  ww. java2  s  .c  o  m*/
    moonTexture.bind();
    gl.glPushMatrix();
    // move away from origin
    gl.glTranslatef(x, y, z);
    // scale to size of moon
    gl.glScalef(radius, radius, radius);
    moonMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();

}

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

License:Open Source License

private void renderActors(GL10 gl) {

    for (int i = 0; i < Stardust3d.actorsList.size(); i++) {
        try {//from   w  w  w  . jav  a 2  s .  c  o  m
            Actor actor = Stardust3d.actorsList.get(i);

            if (actor != null && !(actor.shipname.equals("dead")) && actor.getHitpoints() > 0
                    && actor.getStatus() == 1) {
                // only do for ships in space

                if (actor.getStatus() == 1 && actor.position.dst(Ship.position) < 5000) {
                    if ((actor.visible)) {
                        gl.glPushMatrix();
                        gl.glTranslatef(actor.position.x, actor.position.y, actor.position.z);

                        gl.glScalef(1, 1, 1);
                        String actorName = (actor.get_firstname() + actor.get_surname());

                        if (actorName.equals("Hive AIShield Disruptor")) {

                            gl.glRotatef(actor.yawangle, 0, 1, 0);
                            gl.glRotatef(actor.pitchangle, 1, 0, 0);
                            gl.glRotatef(invaderAngle, 0, 0, 1);
                            shieldDisruptorTexture.bind();
                            shieldDisruptorMesh.render(GL10.GL_TRIANGLES);

                            gl.glEnable(GL10.GL_BLEND);
                            gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
                            gl.glScalef(.5f, .5f, .5f);
                            gl.glDisable(GL10.GL_CULL_FACE);
                            gl.glDisable(GL10.GL_LIGHTING);
                            gl.glColor4f(.0f, 1f, 0f, 1);

                            swirlyTexture.bind();
                            // gl.glRotatef(-(invaderAngle * 20), 0, 0, 1);
                            coneMesh.render(GL10.GL_TRIANGLES);
                            gl.glColor4f(1f, 1f, 1f, 1f);
                            gl.glDisable(GL10.GL_BLEND);
                            gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
                            gl.glEnable(GL10.GL_LIGHTING);
                            gl.glEnable(GL10.GL_CULL_FACE);
                        } else if (actorName.equals("Hive AIScout")) {

                            gl.glRotatef(actor.yawangle, 0, 1, 0);
                            gl.glRotatef(actor.pitchangle, 1, 0, 0);
                            jetTexture.bind();
                            gl.glScalef(1f, 1f, 1f);
                            shieldDisruptorMesh.render(GL10.GL_TRIANGLES);
                            gl.glScalef(20f, 20f, 20f);
                            gl.glDisable(GL10.GL_CULL_FACE);
                            gl.glEnable(GL10.GL_BLEND);
                            gl.glDisable(GL10.GL_LIGHTING);
                            gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
                            gl.glColor4f(.0f, .5f, 1f, 1);
                            gl.glRotatef(-actor.yawangle, 0, 1, 0);
                            gl.glRotatef(-actor.pitchangle, 1, 0, 0);
                            swansongTexture.bind();

                            looking = Util.lookAt(Simulation.camera, actor.position);
                            gl.glRotatef(looking.y, 0, 1, 0);
                            gl.glRotatef(-looking.x, 1, 0, 0);

                            sunMesh.render(GL10.GL_TRIANGLES);
                            gl.glColor4f(1f, 1f, 1f, 1f);
                            gl.glDisable(GL10.GL_BLEND);
                            // gl.glBlendFunc(GL10.GL_SRC_ALPHA,
                            // GL10.GL_ONE);
                            gl.glEnable(GL10.GL_LIGHTING);
                            gl.glEnable(GL10.GL_CULL_FACE);

                        } else {
                            renderActorShip(gl, actor, actor.shipname);
                        }
                        gl.glPopMatrix();
                    }
                }
            }
        } catch (IndexOutOfBoundsException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}

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

License:Open Source License

private void renderShots(GL10 gl, ArrayList<Shot> shots) {
    gl.glColor4f(1, 1, 0, 1);//from www .jav a2  s  .co m
    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 < shots.size(); i++) {
        Shot shot = shots.get(i);
        gl.glPushMatrix();

        gl.glTranslatef(shot.position.x, shot.position.y, shot.position.z);
        gl.glRotatef(shot.yawAngle, 0, 1, 0);
        gl.glRotatef(shot.pitchAngle, 1, 0, 0);
        gl.glScalef(3 + (float) (shot.shotLife) * 1f, (float) (3 + shot.shotLife) * 1f,
                (float) (3 + shot.shotLife) * 1f);
        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 renderMissiles(GL10 gl, ArrayList<Missile> missiles) {
    gl.glColor4f(1, 0, 0, 1);/*from   www  .j  a  va 2  s  . c o  m*/
    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 < missiles.size(); i++) {
        Missile missile = missiles.get(i);
        gl.glPushMatrix();

        gl.glTranslatef(missile.position.x, missile.position.y, missile.position.z);
        gl.glRotatef(missile.yawAngle, 0, 1, 0);
        gl.glRotatef(missile.pitchAngle, 1, 0, 0);
        gl.glScalef(10f, 10f, 10f);
        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);
}