O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mixing the Particles with Additive Blending

When we do different effects in OpenGL, we often have to think back to the effect that we’re trying to reproduce. If we imagine our three particle streams as a fireworks fountain, like the one we’d see at a fireworks show, then we’d expect the particles to give off light; and the more of them there are, the brighter things should be. One of the ways that we can reproduce this effect is by using additive blending.

Let’s enable blending by adding the following code to ParticlesRenderer in the onSurfaceCreated method:

Particles/src/com/particles/android/ParticlesRenderer.java
 
glEnable(GL_BLEND);
 
glBlendFunc(GL_ONE, GL_ONE);

That’s it! First we enable blending, and then we set the blending mode to additive ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required