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

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

Introduction

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

Prototype

int GL_CULL_FACE

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

Click Source Link

Usage

From source file:com.badlogic.gdx.graphics.g3d.test.QbobViewer.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);//from ww  w. ja v  a2 s  . co m
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    cam.update();
    cam.apply(Gdx.gl10);

    Gdx.gl.glEnable(GL10.GL_CULL_FACE);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0);
    Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
    diffuse.bind();
    diffuse.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE1);
    Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);

    lightMaps[0].bind();
    lightMaps[0].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear);
    setCombiners();

    model[0].render();
    lightMaps[1].bind();
    lightMaps[1].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear);
    setCombiners();

    model[1].render();
    lightMaps[2].bind();
    lightMaps[2].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear);
    setCombiners();

    model[2].render();
    lightMaps[3].bind();
    lightMaps[3].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear);
    setCombiners();
    model[3].render();

    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE1);
    Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0);
    Gdx.gl.glDisable(GL10.GL_CULL_FACE);
    Gdx.gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

    Gdx.gl.glDisable(GL10.GL_BLEND);

    animTime += Gdx.graphics.getDeltaTime();
    if (animTime > anim.totalDuration - anim.frameDuration)
        animTime = 0;
    animModel.setAnimation(anim.name, animTime, true);

    Gdx.gl10.glPushMatrix();
    Gdx.gl10.glTranslatef(cam.position.x, cam.position.y, 6);
    animModel.render();
    Gdx.gl10.glPopMatrix();

    Gdx.gl.glDisable(GL10.GL_DEPTH_TEST);
    batch.begin();
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 10, 20);
    batch.end();

    fps.log();
}

From source file:com.badlogic.gdx.graphics.g3d.test.StillModelViewerGL20.java

License:Apache License

@Override
public void render() {

    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl.glEnable(GL10.GL_CULL_FACE);

    instance.getTransform().rotate(0, 1, -0.1f, 35 * Gdx.graphics.getDeltaTime());
    instance2.getTransform().rotate(0, 1, 0.1f, -15 * Gdx.graphics.getDeltaTime());

    cam.update();//w  w w.jav a  2s .  com

    protoRenderer.begin();
    protoRenderer.draw(model, instance);
    protoRenderer.draw(model, instance2);
    protoRenderer.end();

    batch.begin();
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30);
    batch.end();

    fps.log();
}

From source file:com.badlogic.gdx.physics.bullet.demo.screens.SimulationScreen.java

@Override
public final void render(float graphicsDelta) {
    // Physics//from   w  ww . j  av  a  2s  .  co m
    hookRenderPrePhysics(graphicsDelta);
    final float physicsDelta = stepPhysics();
    hookRenderPostPhysics(graphicsDelta, physicsDelta);

    // Clear frame and enable model styles
    Gdx.gl10.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    hookRenderPostClear(graphicsDelta, physicsDelta);

    // Apply perspective player camera
    perspectiveCamera.apply(Gdx.gl10);

    Gdx.gl10.glEnable(GL10.GL_DITHER);
    Gdx.gl10.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl10.glEnable(GL10.GL_CULL_FACE);
    Gdx.gl10.glEnable(GL10.GL_BLEND);
    Gdx.gl10.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

    // Position lights so lighting calculations for objects are correct
    positionLights(graphicsDelta, physicsDelta);

    renderDynamicsWorld();

    hookRenderScene(graphicsDelta, physicsDelta);

    // Apply orthographic OSD camera
    osdCamera.apply(Gdx.gl10);

    // Disable face culling so we draw everything
    Gdx.gl10.glDisable(GL10.GL_CULL_FACE);

    // Render OSD
    disableLights();
    osdSpriteBatch.begin();
    osdFont.setColor(1, 1, 1, 1f);
    osdFont.draw(osdSpriteBatch, getOSDText(), 10, 10 + osdFont.getCapHeight());
    osdSpriteBatch.end();
    hookRenderOSD(graphicsDelta, physicsDelta);
}

From source file:com.badlogic.gdx.tests.DecalTransform.java

License:Apache License

@Override
public void create() {
    image = new Texture(Gdx.files.internal("data/badges/128/badge0.png"));
    image.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    image.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);

    float w = 100;// Gdx.graphics.getWidth()/2;
    float h = 80;// Gdx.graphics.getHeight()/2;

    for (int i = 0; i < DECAL_COUNT; i++) {
        sprites[i] = Decal.newDecal(20, 20, new TextureRegion(image), false);
        sprites[i].setX(20 * i);//from   w w w  .j  av  a2  s . c o m
    }

    batch = new DecalBatch();
    Gdx.gl.glClearColor(1, 1, 0, 1);

    float move = 100f;
    float scale = 1;
    float rotate = 50;
    keyActions.put(Input.Keys.W, new TransY(move));
    keyActions.put(Input.Keys.S, new TransY(-move));
    keyActions.put(Input.Keys.A, new TransX(-move));
    keyActions.put(Input.Keys.D, new TransX(move));
    keyActions.put(Input.Keys.Q, new Scale(scale));
    keyActions.put(Input.Keys.E, new Scale(-scale));
    keyActions.put(Input.Keys.J, new RotateZ(rotate));
    keyActions.put(Input.Keys.U, new RotateY(rotate));
    keyActions.put(Input.Keys.K, new RotateX(rotate));
    keyActions.put(Input.Keys.Z, new TransZ(-move));
    keyActions.put(Input.Keys.X, new TransZ(move));
    Gdx.input.setInputProcessor(this);
    Gdx.gl.glDisable(GL10.GL_CULL_FACE);
}

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

License:Apache License

public void render(Application app, Simulation simulation) {
    GL10 gl = app.getGraphics().getGL10();
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glViewport(0, 0, app.getGraphics().getWidth(), app.getGraphics().getHeight());

    renderBackground(gl);/*from ww  w. j  a v a 2s .co m*/
    renderEarth(gl);

    gl.glDisable(GL10.GL_DITHER);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glEnable(GL10.GL_CULL_FACE);

    //setProjectionAndCamera(app.getGraphics(), simulation.ship, app);
    setProjectionAndCameraAugmentedReality(app.getGraphics(), simulation, app);

    setLighting(gl);

    gl.glEnable(GL10.GL_TEXTURE_2D);

    renderMoon(gl, simulation.ship);
    renderShip(gl, simulation.ship, app);
    renderAliens(gl, simulation.aliens);

    gl.glDisable(GL10.GL_TEXTURE_2D);
    renderBlocks(gl, simulation.blocks);

    gl.glDisable(GL10.GL_LIGHTING);

    //renderShots(gl, simulation.shots);
    //renderRays(gl, simulation.mRays, true);
    renderAlienRays(gl, simulation.mAlienRays);
    renderPlayerRays(gl, simulation.mShipRays);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    renderExplosions(gl, simulation.explosions);
    renderBombExplosions(gl, simulation.bombExplosions);

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

    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    if (simulation.ship.lives != lastLives || simulation.score != lastScore || simulation.wave != lastWave) {
        status = "lives: " + simulation.ship.lives + " wave: " + simulation.wave + " score: "
                + simulation.score;
        lastLives = simulation.ship.lives;
        lastScore = simulation.score;
        lastWave = simulation.wave;
    }
    spriteBatch.enableBlending();
    spriteBatch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
    font.draw(spriteBatch, status, 0, 320);
    spriteBatch.end();

    alienAngle += app.getGraphics().getDeltaTime() * 90;
    if (alienAngle > 360)
        alienAngle -= 360;
}

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

License:Open Source License

private void renderSolarSystem(Application app, Simulation simulation) {
    GL10 gl = app.getGraphics().getGL10();
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glViewport(0, 0, app.getGraphics().getWidth(), app.getGraphics().getHeight());

    // renderBackground(gl);

    gl.glDisable(GL10.GL_DITHER);/*w  w  w .j a  va  2 s .  c  o  m*/
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glEnable(GL10.GL_CULL_FACE);

    setProjectionAndCamera(app.getGraphics(), Simulation.ship, app, gl);
    setLighting(gl);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    // renderRoids(gl);
    // camera.unproject(GameLoop.touchPoint.set(Gdx.input.getX(),
    // Gdx.input.getY(), 0));

    // render earth
    // renderPlanet(gl, "earth", true, 63780f, 200000, 0, 50000);
    // render mars
    renderPlanet(gl, "sun", true, 33970, 0, 0, 50000);
    // render sun
    renderSun(gl, 69550f, 0, 0, -500000, app);
    // render jupiter
    // renderPlanet(gl, "earth", false, 714920f, -4000000, 0, 50000);
    // render moon
    // renderMoon(gl, 17370f, 100000, 0, -50000);

    // renderDrones(gl, simulation.drones, app, Simulation.ship);
    renderSky(gl, Simulation.ship, app);
    renderActors(gl);

    // do alpha models after this

    // render station
    renderStation(gl, "station01", true, 1000f, 0, 0, 0);
    // render myship
    renderShip(gl, Simulation.ship, Stardust3d.myCharacter.getShipname());
    renderDusts(gl, Simulation.dusts);
    renderShots(gl, simulation.shots);
    renderMissiles(gl, simulation.missiles);
    // renderTrails(gl, simulation.trails);
    gl.glDisable(GL10.GL_TEXTURE_2D);
    // renderBlocks(gl, simulation.blocks);

    // gl.glDisable(GL10.GL_LIGHTING);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    renderExplosions(gl, Simulation.explosions);

    renderHud(simulation, gl);
    stationAngle += app.getGraphics().getDeltaTime() * 1;
    if (stationAngle > 360)
        stationAngle -= 360;

    invaderAngle += app.getGraphics().getDeltaTime() * 10;
    if (invaderAngle > 360)
        invaderAngle -= 360;
}

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

License:Open Source License

/**
 * @param simulation/*  w w  w .ja  va  2 s . com*/
 * @param gl
 */
private void renderHud(Simulation simulation, GL10 gl) {

    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    spriteBatch.enableBlending();
    spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    spriteBatch.begin();
    if (Ship.STATUS == 1) {
        hurtflash(gl);
        renderReticules(simulation);
        if (Ship.docking) {
            float textlength = fontnormal.getBounds("Docking in " + (5 - (Simulation.docktick / 10))).width;
            fontnormal.draw(spriteBatch, "Docking in " + (5 - (Simulation.docktick / 10)),
                    (width / 2) - (textlength / 2), (height / 2) + 64);
        }

    } else {
        if (Ship.undocking) {
            float textlength = fontnormal.getBounds("Undocking in " + (4 - (Simulation.docktick / 10))).width;
            fontnormal.draw(spriteBatch, "Undocking in " + (4 - (Simulation.docktick / 10)),
                    (width / 2) - (textlength / 2), (height / 2) + 64);
        }

    }

    // GameLoop.touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0);

    spriteBatch.enableBlending();
    spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    if (GameLoop.androidVersion != 0) {
        renderButtonsAndroid(simulation);
    } else {
        renderButtonsPC(simulation);
    }

    renderChat();

    renderScreens();
    spriteBatch.end();

    spriteBatch.begin();
    spriteBatch.enableBlending();
    spriteBatch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
    spriteBatch.end();
    stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
    stage.draw();
    if (Stardust3d.DEBUG)
        Table.drawDebug(stage);
}

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

License:Open Source License

private void renderShip(GL10 gl, Ship ship, String shipname) {
    if (ship.isExploding)
        return;/*w ww .  j a  v a  2  s . c o m*/

    if (shipname.equals("stickleback")) {
        gl.glDisable(GL10.GL_CULL_FACE);
        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(Ship.position.x, Ship.position.y, Ship.position.z);
    gl.glDisable(GL10.GL_BLEND);
    gl.glRotatef(Ship.yawAngle, 0, 1, 0);
    gl.glRotatef(Ship.pitchAngle, 1, 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);
    }
    renderJets(gl, shipname, Ship.SHIP_VELOCITY);
    gl.glPopMatrix();
}

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

License:Open Source License

/**
 * @param gl//from w w w .  java2 s.c om
 * @param shipname
 * @param velocity
 */
private void renderJets(GL10 gl, String shipname, float velocity) {
    float noise = (float) Math.random();
    float length = velocity / 50;
    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();
    // gl.glPushMatrix();
    for (int i = 0; i < Stardust3d.shipdefs.size(); i++) {
        String currentShipdef = Stardust3d.shipdefs.get(i).getModel().substring(0,
                Stardust3d.shipdefs.get(i).getModel().length() - 4);
        if (Stardust3d.DEEPDEBUG)
            System.out.println("shipdef " + currentShipdef);
        if (currentShipdef.equals(shipname)) {
            if (Stardust3d.shipdefs.get(i).getJet1x() != 99999) {
                gl.glTranslatef(Stardust3d.shipdefs.get(i).getJet1x(), Stardust3d.shipdefs.get(i).getJet1y(),
                        Stardust3d.shipdefs.get(i).getJet1z());
                gl.glScalef(2f, 2f, (1f + length + noise));
                jetMesh.render(GL10.GL_TRIANGLES);
                gl.glScalef(.5f, .5f, 1 / (1f + length + noise));
                gl.glTranslatef(-Stardust3d.shipdefs.get(i).getJet1x(), -Stardust3d.shipdefs.get(i).getJet1y(),
                        -Stardust3d.shipdefs.get(i).getJet1z());
                // gl.glScalef(1, 1, 1);
            }
            if (Stardust3d.shipdefs.get(i).getJet2x() != 99999) {
                gl.glTranslatef(Stardust3d.shipdefs.get(i).getJet2x(), Stardust3d.shipdefs.get(i).getJet2y(),
                        Stardust3d.shipdefs.get(i).getJet2z());
                gl.glScalef(2f, 2f, (1f + length + noise));
                jetMesh.render(GL10.GL_TRIANGLES);
            }
            if (Stardust3d.shipdefs.get(i).getJet3x() != 99999) {
                gl.glTranslatef(Stardust3d.shipdefs.get(i).getJet3x(), Stardust3d.shipdefs.get(i).getJet3y(),
                        Stardust3d.shipdefs.get(i).getJet3z());
                gl.glScalef(2f, 2f, (1f + length + noise));
                jetMesh.render(GL10.GL_TRIANGLES);
            }
            if (Stardust3d.shipdefs.get(i).getJet4x() != 99999) {
                gl.glTranslatef(Stardust3d.shipdefs.get(i).getJet4x(), Stardust3d.shipdefs.get(i).getJet4y(),
                        Stardust3d.shipdefs.get(i).getJet4z());
                gl.glScalef(2f, 2f, (1f + length + noise));
                jetMesh.render(GL10.GL_TRIANGLES);
            }
            if (Stardust3d.shipdefs.get(i).getJet5x() != 99999) {
                gl.glTranslatef(Stardust3d.shipdefs.get(i).getJet5x(), Stardust3d.shipdefs.get(i).getJet5y(),
                        Stardust3d.shipdefs.get(i).getJet5z());
                gl.glScalef(2f, 2f, (1f + length + noise));
                jetMesh.render(GL10.GL_TRIANGLES);
            }
        }
    }
    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 renderActorShip(GL10 gl, Actor actor, String shipname) {
    if (shipname.equals("stickleback")) {
        gl.glDisable(GL10.GL_CULL_FACE);
        shipTexture01.bind();/*from www  .  ja  v  a 2 s. com*/
    } 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.glDisable(GL10.GL_BLEND);
    gl.glRotatef(actor.yawangle, 0, 1, 0);
    gl.glRotatef(actor.pitchangle, 1, 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);
    }

    renderJets(gl, shipname, actor.velocity);
    gl.glPopMatrix();
}