public void render(GLEx g, float x, float y) { if (!visible) { return; } if ((sprite == null) && (defaultImageName != null)) { loadSystemParticleImage(); } g.translate(x, y); if (blendingMode == BLEND_ADDITIVE) { GLEx.self.setBlendMode(GL.MODE_ALPHA_ONE); } if (usePoints()) { GLEx.gl10.glEnable(GL.GL_POINT_SMOOTH); g.glTex2DDisable(); } for (int emitterIdx = 0; emitterIdx < emitters.size(); emitterIdx++) { ParticleEmitter emitter = emitters.get(emitterIdx); if (!emitter.isEnabled()) { continue; } if (emitter.useAdditive()) { g.setBlendMode(GL.MODE_ALPHA_ONE); } ParticlePool pool = particlesByEmitter.get(emitter); LTexture image = emitter.getImage(); if (image == null) { image = this.sprite; } if (!emitter.isOriented() && !emitter.usePoints(this)) { image.glBegin(); } for (int i = 0; i < pool.particles.length; i++) { if (pool.particles[i].inUse()) { pool.particles[i].render(); } } if (!emitter.isOriented() && !emitter.usePoints(this)) { image.glEnd(); } if (emitter.useAdditive()) { g.setBlendMode(GL.MODE_NORMAL); } } if (usePoints()) { GLEx.gl10.glDisable(GL.GL_POINT_SMOOTH); } if (blendingMode == BLEND_ADDITIVE) { g.setBlendMode(GL.MODE_NORMAL); } g.resetColor(); g.translate(-x, -y); }
/** * Render the particles in the system * * @param x The x coordinate to render the particle system at (in the current coordinate space) * @param y The y coordinate to render the particle system at (in the current coordiante space) */ public void render(float x, float y) { if ((sprite == null) && (defaultImageName != null)) { loadSystemParticleImage(); } if (!visible) { return; } GL.glTranslatef(x, y, 0); if (blendingMode == BLEND_ADDITIVE) { GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE); } if (usePoints()) { GL.glEnable(SGL.GL_POINT_SMOOTH); TextureImpl.bindNone(); } // iterate over all emitters for (int emitterIdx = 0; emitterIdx < emitters.size(); emitterIdx++) { // get emitter ParticleEmitter emitter = (ParticleEmitter) emitters.get(emitterIdx); // check for additive override and enable when set if (emitter.useAdditive()) { GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE); } // now get the particle pool for this emitter and render all particles that are in use ParticlePool pool = (ParticlePool) particlesByEmitter.get(emitter); Image image = emitter.getImage(); if (image == null) { image = this.sprite; } if (!emitter.isOriented() && !emitter.usePoints(this)) { image.startUse(); } for (int i = 0; i < pool.particles.length; i++) { if (pool.particles[i].inUse()) pool.particles[i].render(); } if (!emitter.isOriented() && !emitter.usePoints(this)) { image.endUse(); } // reset additive blend mode if (emitter.useAdditive()) { GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE_MINUS_SRC_ALPHA); } } if (usePoints()) { GL.glDisable(SGL.GL_POINT_SMOOTH); } if (blendingMode == BLEND_ADDITIVE) { GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE_MINUS_SRC_ALPHA); } Color.white.bind(); GL.glTranslatef(-x, -y, 0); }