- type Xenon_particle '// the type for each particle
- position as Xenon_point3d '// position of the particle
- velocity as Xenon_point3d '// velocity vector (speed) of the particle
- xcolor(3) as GLfloat '// color of the particle
- size as GLfloat '// size of the particle
- TimeToLive as integer '// how long the particle lives (from now)
- status as BYTE '// status of the particle (living or not)
- mass as single '// mass of the particle
- nextEntry as Xenon_particle PTR '// next entry in the particle-list
- end type
- type Xenon_ParticleEffect '// the type for the particle-system
- position as Xenon_point3d '// where the particles come from
- texture as Xenon_texture2d '// the texture for the particles
- particles as Xenon_particle PTR '// the pointer to the first particle
- declare sub render () '// the render-procedure for this system
- declare sub update () '// the update-procedure for this system
- declare sub add () '// add a new particle
- end type
- '// Xenon_ParticleEffect.update addiert den Geschwindigkeits-vektor zur position
- sub Xenon_ParticleEffect.render '// the render-procedure for this system
- dim currentParticle as Xenon_particle PTR '// pointer for the particles
- currentParticle = This.particles '// point to first particle
- glBindTexture (GL_TEXTURE_2D, This.texture.handle)
- glDepthMask (GL_FALSE)
- glDisable (GL_DEPTH_TEST)
- glEnable (GL_BLEND)
- glBlendFunc (GL_SRC_ALPHA, GL_ONE)
- do until currentParticle = 0
- glColor4fv @(currentParticle->xcolor(0))
- glBegin (GL_QUADS)
- glTexCoord2i (1, 1)
- glVertex3f currentParticle->position.x+currentParticle->size, currentParticle->position.y+currentParticle->size, currentParticle->position.z
- glTexCoord2i (0, 1)
- glVertex3f currentParticle->position.x-currentParticle->size, currentParticle->position.y+currentParticle->size, currentParticle->position.z
- glTexCoord2i (0, 0)
- glVertex3f currentParticle->position.x-currentParticle->size, currentParticle->position.y-currentParticle->size, currentParticle->position.z
- glTexCoord2i (1, 0)
- glVertex3f currentParticle->position.x+currentParticle->size, currentParticle->position.y-currentParticle->size, currentParticle->position.z
- glEnd
- currentParticle = currentParticle->nextEntry
- loop
- glColor3f 1, 1, 1
- glDisable (GL_BLEND)
- glEnable (GL_DEPTH_TEST)
- glDepthMask (GL_TRUE)
- end sub