List of usage examples for com.badlogic.gdx.graphics GL10 GL_SRC_ALPHA
int GL_SRC_ALPHA
To view the source code for com.badlogic.gdx.graphics GL10 GL_SRC_ALPHA.
Click Source Link
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 ww . j a va2s .c om*/ 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//from w w w. java2 s . c o 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.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. j a v a 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 w w w . ja va 2s. co 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( ) ) ) {/*from w w w . jav a2 s .c o 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. *///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);/*from ww w. jav a 2 s . co m*/ 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
private void renderBlocks(GL10 gl, ArrayList<Block> blocks) { gl.glEnable(GL10.GL_BLEND);//from w w w . ja v a 2 s. c o m gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); gl.glColor4f(0.2f, 0.2f, 1, 0.7f); for (int i = 0; i < blocks.size(); i++) { Block block = blocks.get(i); gl.glPushMatrix(); gl.glTranslatef(block.position.x, block.position.y, block.position.z); blockMesh.render(GL10.GL_TRIANGLES); gl.glPopMatrix(); } gl.glColor4f(1, 1, 1, 1); gl.glDisable(GL10.GL_BLEND); }
From source file:com.davidykay.shootout.Renderer.java
License:Apache License
private void renderExplosions(GL10 gl, ArrayList<Explosion> explosions) { gl.glEnable(GL10.GL_BLEND);//ww w. j a va 2 s .co m gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); explosionTexture.bind(); for (int i = 0; i < explosions.size(); i++) { Explosion explosion = explosions.get(i); gl.glPushMatrix(); gl.glTranslatef(explosion.position.x, explosion.position.y, explosion.position.z); explosionMesh.render(GL10.GL_TRIANGLE_FAN, (int) ((explosion.aliveTime / Explosion.EXPLOSION_LIVE_TIME) * 15) * 4, 4); gl.glPopMatrix(); } gl.glDisable(GL10.GL_BLEND); }