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

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

Introduction

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

Prototype

int GL_BLEND

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

Click Source Link

Usage

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.  jav  a  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);
}

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);
    // gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_LIGHTING);/*from   w w  w  .j a va 2  s.com*/
    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);//from   w  ww  . j  ava 2  s.  com
    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);//from   w  ww.  j av  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 renderInsideStation(Application app) {
    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());
    gl.glEnable(GL10.GL_BLEND);
    gl.glDisable(GL10.GL_DITHER);//from   ww w.j a  va 2s.  co m
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glEnable(GL10.GL_CULL_FACE);
    setStaticProjectionAndCamera(app.getGraphics(), app, gl);
    setLighting(gl);
    gl.glEnable(GL10.GL_TEXTURE_2D);
    renderSky(gl);
    renderPlanet(gl, "sun", true, 1737f, Splash.planetmove - 150, 0, -2500, app);
    renderSky(gl);
    gl.glDisable(GL10.GL_DITHER);
    gl.glDisable(GL10.GL_CULL_FACE);
    //do alpha models after this
    renderStaticShip(gl, app);
    renderSun(gl, 70000f, -1600, 0, -4500, app);
    gl.glDisable(GL10.GL_TEXTURE_2D);
    renderHud(gl);
}

From source file:com.interakt.ar.outdoor.browsing.BrowsingRenderer.java

License:Apache License

@Override
public void render() {

    if (mode == Mode.normal) {
        mode = Mode.prepare;/*from www .  j a v  a2s.  com*/
        if (deviceCameraControl != null) {

            deviceCameraControl.prepareCameraAsync();
        }
    }

    Gdx.gl10.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
    if (mode == Mode.prepare) {
        Gdx.gl10.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        if (deviceCameraControl != null) {
            if (deviceCameraControl.isReady()) {
                deviceCameraControl.startPreviewAsync();
                mode = Mode.preview;
            }
        }
    } else if (mode == Mode.preview) {
        Gdx.gl10.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    } else { // mode = normal
        Gdx.gl10.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    }
    Gdx.gl10.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl10.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl10.glEnable(GL10.GL_TEXTURE);
    Gdx.gl10.glEnable(GL10.GL_TEXTURE_2D);
    Gdx.gl10.glEnable(GL10.GL_LINE_SMOOTH);
    Gdx.gl10.glDepthFunc(GL10.GL_LEQUAL);
    Gdx.gl10.glClearDepthf(1.0F);
    Gdx.gl10.glEnable(GL10.GL_ALPHA_TEST);
    Gdx.gl10.glDisable(GL10.GL_COLOR_MATERIAL);
    Gdx.gl10.glAlphaFunc(GL10.GL_GREATER, 0.0f);
    Gdx.gl10.glEnable(GL10.GL_BLEND);
    Gdx.gl10.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.gl10.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    if (!stopRendering) {
        if (canRender.tryAcquire()) {
            ((LibGDXPerspectiveCamera) geoMode.getCamera()).render();
            geoMode.render();
            canRender.release();

        }

        radar.draw();
    }

}

From source file:com.interakt.ar.outdoor.tagging.TaggingRenderer.java

License:Apache License

@Override
public void render() {

    if (mode == Mode.normal) {
        mode = Mode.prepare;// ww  w  . j a v a 2 s  .  c  o m
        if (deviceCameraControl != null) {

            deviceCameraControl.prepareCameraAsync();
        }
    }

    Gdx.gl10.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
    if (mode == Mode.prepare) {
        Gdx.gl10.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        if (deviceCameraControl != null) {
            if (deviceCameraControl.isReady()) {
                deviceCameraControl.startPreviewAsync();
                mode = Mode.preview;
            }
        }
    } else if (mode == Mode.preview) {
        Gdx.gl10.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    } else { // mode = normal
        Gdx.gl10.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    }
    Gdx.gl10.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl10.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl10.glEnable(GL10.GL_TEXTURE);
    Gdx.gl10.glEnable(GL10.GL_TEXTURE_2D);
    Gdx.gl10.glEnable(GL10.GL_LINE_SMOOTH);
    Gdx.gl10.glDepthFunc(GL10.GL_LEQUAL);
    Gdx.gl10.glClearDepthf(1.0F);
    Gdx.gl10.glEnable(GL10.GL_ALPHA_TEST);
    Gdx.gl10.glDisable(GL10.GL_COLOR_MATERIAL);
    Gdx.gl10.glAlphaFunc(GL10.GL_GREATER, 0.0f);
    Gdx.gl10.glEnable(GL10.GL_BLEND);
    Gdx.gl10.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.gl10.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    Gdx.gl10.glClearDepthf(1.0F);
    if (canRender.tryAcquire()) {
        ((LibGDXPerspectiveCamera) taggingMode.getCamera()).render();
        taggingMode.render();

        canRender.release();
    }

}

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

License:Apache License

/** Finishes off rendering. Enables depth writes, disables blending and texturing. Must always be called after a call to
 * {@link #begin()} *//*from  ww w.j  a v  a  2s  .  co  m*/
public void end() {
    if (!drawing)
        throw new IllegalStateException("CustomBatch.begin must be called before end.");
    if (idx > 0)
        renderMesh();
    lastTexture = null;
    idx = 0;
    drawing = false;

    GLCommon gl = Gdx.gl;
    gl.glDepthMask(true);
    if (isBlendingEnabled())
        gl.glDisable(GL10.GL_BLEND);

    if (Gdx.graphics.isGL20Available()) {
        if (customShader != null)
            customShader.end();
        else
            shader.end();
    } else {
        gl.glDisable(GL10.GL_TEXTURE_2D);
    }
}

From source file:com.kimmyj.lwp.example.LiveWallpaperProgram.java

License:Apache License

public void render() {
    update();/*w  w  w . j  a v a  2  s .  c  o m*/
    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_BLEND);
    Gdx.gl.glViewport(0, 0, width, height);
    if (triggerUpdateScreen) {
        triggerUpdateScreen = false;
        mCamera.setToOrtho(false, width, height);
        mBatch.setProjectionMatrix(mCamera.combined);
        mEffect.setPosition(width / 2, height / 2);
    }
    mCamera.update();
    mEffect.update(Gdx.graphics.getDeltaTime() / 1.6f);
    mBatch.begin();
    mEffect.draw(mBatch);
    mBatch.end();
}

From source file:com.kingx.dungeons.graphics.cube.CubeRenderer.java

License:Apache License

/**
 * Finishes off rendering. Enables depth writes, disables blending and
 * texturing. Must always be called after a call to {@link #begin()}
 *//*from w  w w .  j a va2 s.c  om*/
public void end() {
    if (!drawing)
        throw new IllegalStateException("SpriteBatch.begin must be called before end.");
    if (idx > 0)
        renderMesh();
    idx = 0;
    drawing = false;

    GLCommon gl = Gdx.gl;
    gl.glDepthMask(true);
    if (isBlendingEnabled())
        gl.glDisable(GL10.GL_BLEND);

    if (customShader != null)
        customShader.end();
    else
        shader.end();

}