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

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

Introduction

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

Prototype

int GL_ONE

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

Click Source Link

Usage

From source file:com.badlogic.rtm.LevelRenderer.java

License:Apache License

@Override
public void render() {
    GL10 gl = Gdx.gl10;/* www  .  j  a va2  s  . c  o 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);/*from   w w  w .  ja va 2  s.c o  m*/
        }
    }
    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  ww  w.jav a2  s .c o m
    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( ) ) )
        {/*w ww  . jav  a  2 s  . co  m*/
            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.
 *///  w  ww.  j av  a  2  s .c o  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.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 va2s. c  o  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.davidykay.shootout.screens.GameOver.java

License:Apache License

@Override
public void render(Application app) {
    app.getGraphics().getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();/* w  ww .j a va 2s .  co  m*/
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 256, 512, 256, false, false);
    String text = "You have failed Earth.\nTouch to continue.";
    TextBounds bounds = font.getMultiLineBounds(text);
    spriteBatch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
    font.drawMultiLine(spriteBatch, text, 0, 160 + bounds.height / 2, 480, HAlignment.CENTER);
    spriteBatch.end();
}

From source file:com.davidykay.shootout.screens.MainMenu.java

License:Apache License

@Override
public void render(Application app) {
    app.getGraphics().getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();//w w w.  ja  v  a2 s.  c om
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 0, 512, 256, false, false);
    spriteBatch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
    String text = "Touch to start!";
    float width = font.getBounds(text).width;
    font.draw(spriteBatch, text, 240 - width / 2, 128);
    spriteBatch.end();
}

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

License:Open Source License

/**
 * @param simulation//ww w. ja va2  s  . c  om
 * @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);
}