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

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

Introduction

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

Prototype

int GL_ONE_MINUS_SRC_ALPHA

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

Click Source Link

Usage

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

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    cam.update();/*from   w w  w  .ja v  a 2  s.c o m*/
    cam.apply(Gdx.gl10);

    drawAxes();

    if (hasNormals) {
        Gdx.gl.glEnable(GL10.GL_LIGHTING);
        Gdx.gl.glEnable(GL10.GL_COLOR_MATERIAL);
        Gdx.gl.glEnable(GL10.GL_LIGHT0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);
    }

    if (texture != null) {
        Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
        Gdx.gl.glEnable(GL10.GL_BLEND);
        Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    }

    angle += 45 * Gdx.graphics.getDeltaTime();
    Gdx.gl10.glRotatef(angle, 0, 1, 0);
    animTime += Gdx.graphics.getDeltaTime() / 10;
    if (animTime > anim.totalDuration) {
        animTime = 0;
    }
    model.setAnimation(anim.name, animTime, false);
    model.render();

    if (texture != null) {
        Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
    }

    if (hasNormals) {
        Gdx.gl.glDisable(GL10.GL_LIGHTING);
    }

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

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

@Override
public final void render(float graphicsDelta) {
    // Physics//w  w w  .  jav a 2  s.  c  om
    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.rtm.LevelRenderer.java

License:Apache License

@Override
public void render() {
    GL10 gl = Gdx.gl10;//from   www.  j  ava2  s.co  m

    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glEnable(GL10.GL_TEXTURE_2D);

    camera.update();
    camera.apply(gl);

    tiles.bind();
    gl.glColor4f(1, 1, 1, 1);
    floorMesh.render(GL10.GL_TRIANGLES);
    wallMesh.render(GL10.GL_TRIANGLES);

    batch.begin();
    batch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond() + ", delta:" + Gdx.graphics.getDeltaTime(), 10,
            25);
    batch.end();

    processInput();
}

From source file:com.badlydrawngames.veryangryrobots.WorldView.java

License:Apache License

private void drawParticles() {
    spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    for (Particle particle : particleManager.getParticles()) {
        if (particle.active) {
            spriteBatch.setColor(particle.color);
            spriteBatch.draw(Assets.pureWhiteTextureRegion, particle.x, particle.y, particle.size,
                    particle.size);//www  .  j av  a  2s  .  c om
        }
    }
    spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
}

From source file:com.badlydrawngames.veryangryrobots.WorldView.java

License:Apache License

private void drawFlyups() {
    BitmapFont font = Assets.flyupFont;/*from w w  w. j  av  a  2  s .  c  om*/
    float scale = font.getScaleX();
    font.setScale(1.0f / Assets.pixelDensity);
    spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    for (Flyup flyup : flyupManager.flyups) {
        if (flyup.active) {
            font.draw(spriteBatch, flyup.scoreString, flyup.x, flyup.y);
        }
    }
    spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    font.setScale(scale);
}

From source file:com.blindtigergames.werescrewed.graphics.particle.ParticleEmitter.java

License:Apache License

public void draw(SpriteBatch spriteBatch, Camera camera) {
    if (additive)
        spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE);

    Particle[] particles = this.particles;
    boolean[] active = this.active;
    int activeCount = this.activeCount;

    for (int i = 0, n = active.length; i < n; i++) {
        if (active[i])//&& particles[i].getBoundingRectangle( ).overlaps( camera.getBounds( ) ) )
        {//from w ww  .j  a  v  a2s . com
            particles[i].draw(spriteBatch);
        }
    }
    this.activeCount = activeCount;

    if (additive)
        spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
}

From source file:com.blindtigergames.werescrewed.graphics.particle.ParticleEmitter.java

License:Apache License

/**
 * Updates and draws the particles. This is slightly more efficient than
 * calling {@link #update(float)} and {@link #draw(SpriteBatch)} separately.
 *///from   w w  w .  j  a v  a2  s  . co  m
public void draw(SpriteBatch spriteBatch, float delta, Camera camera) {
    accumulator += Math.min(delta * 1000, 250);
    if (accumulator < 1) {
        draw(spriteBatch, camera);
        return;
    }
    int deltaMillis = (int) accumulator;
    accumulator -= deltaMillis;

    if (additive)
        spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE);

    Particle[] particles = this.particles;
    boolean[] active = this.active;
    int activeCount = this.activeCount;
    for (int i = 0, n = active.length; i < n; i++) {
        if (active[i]) {
            Particle particle = particles[i];
            //if ( particle.getBoundingRectangle( ).overlaps( camera.getBounds( ) ) ) 
            {
                if (updateParticle(particle, delta, deltaMillis)) {
                    particle.draw(spriteBatch);
                } else {
                    active[i] = false;
                    activeCount--;
                }
            }
        }
    }
    this.activeCount = activeCount;

    if (additive)
        spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

    if (delayTimer < delay) {
        delayTimer += deltaMillis;
        return;
    }

    if (firstUpdate) {
        firstUpdate = false;
        addParticle();
    }

    if (durationTimer < duration)
        durationTimer += deltaMillis;
    else {
        if (!continuous || allowCompletion)
            return;
        restart();
    }

    emissionDelta += deltaMillis;
    float emissionTime = emission + emissionDiff * emissionValue.getScale(durationTimer / (float) duration);
    if (emissionTime > 0) {
        emissionTime = 1000 / emissionTime;
        if (emissionDelta >= emissionTime) {
            int emitCount = (int) (emissionDelta / emissionTime);
            emitCount = Math.min(emitCount, maxParticleCount - activeCount);
            emissionDelta -= emitCount * emissionTime;
            emissionDelta %= emissionTime;
            addParticles(emitCount);
        }
    }
    if (activeCount < minParticleCount)
        addParticles(minParticleCount - activeCount);
}

From source file:com.bmnb.fly_dragonfly.graphics.GameParticleEmitter.java

License:Apache License

public void draw(SpriteBatch spriteBatch) {
    if (additive)
        spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE);

    Particle[] particles = this.particles;
    boolean[] active = this.active;
    int activeCount = this.activeCount;

    for (int i = 0, n = active.length; i < n; i++)
        if (active[i])
            particles[i].draw(spriteBatch);
    this.activeCount = activeCount;

    if (additive)
        spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
}

From source file:com.bmnb.fly_dragonfly.graphics.GameParticleEmitter.java

License:Apache License

/** Updates and draws the particles. This is slightly more efficient than calling {@link #update(float)} and
 * {@link #draw(SpriteBatch)} separately. */
public void draw(SpriteBatch spriteBatch, float delta) {
    accumulator += Math.min(delta * 1000, 250);
    if (accumulator < 1) {
        draw(spriteBatch);// w  w  w.  j a  v  a2 s .com
        return;
    }

    //      com.badlogic.gdx.graphics.g2d.ParticleEmitter

    int deltaMillis = (int) accumulator;
    accumulator -= deltaMillis;

    if (additive)
        spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);

    Particle[] particles = this.particles;
    boolean[] active = this.active;
    int activeCount = this.activeCount;
    for (int i = 0, n = active.length; i < n; i++) {
        if (active[i]) {
            Particle particle = particles[i];
            if (updateParticle(particle, delta, deltaMillis) && !particle.isDead())
                particle.draw(spriteBatch);
            else {
                particle.kill();
                active[i] = false;
                activeCount--;
            }
        }
    }
    this.activeCount = activeCount;

    if (additive)
        spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

    if (delayTimer < delay) {
        delayTimer += deltaMillis;
        return;
    }

    if (firstUpdate) {
        firstUpdate = false;
        addParticle();
    }

    if (durationTimer < duration)
        durationTimer += deltaMillis;
    else {
        if (!continuous || allowCompletion)
            return;
        restart();
    }

    emissionDelta += deltaMillis;
    float emissionTime = emission + emissionDiff * emissionValue.getScale(durationTimer / (float) duration);
    if (emissionTime > 0) {
        emissionTime = 1000 / emissionTime;
        if (emissionDelta >= emissionTime) {
            int emitCount = (int) (emissionDelta / emissionTime);
            emitCount = Math.min(emitCount, maxParticleCount - activeCount);
            emissionDelta -= emitCount * emissionTime;
            emissionDelta %= emissionTime;
            addParticles(emitCount);
        }
    }
    if (activeCount < minParticleCount)
        addParticles(minParticleCount - activeCount);
}

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  w w w .j  a v  a2s  .c om
    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;
}