2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef __CAIRO_DOCK_PARTICLE_SYSTEM__
22
#define __CAIRO_DOCK_PARTICLE_SYSTEM__
27
*@file cairo-dock-particle-system.h A particle system is a set of particles that evolve according to a given model. Each particle will see its parameters change with time : direction, speed, oscillation, color, size, etc.
28
* Particle Systems fully take advantage of OpenGL and are able to render many thousand of particles at a high frequency refresh.
32
/// A particle of a particle system.
33
typedef struct _CairoParticle {
34
/// horizontal position, in fraction of the particle system's width, and relatively to the center of the particle system. So it is comprised between -1 and 1.
36
/// vertical position, in fraction of the particle system's height, and relatively to the bottom of the particle system. So it is comprised between 0 and 1.
38
/// depth of the particle, negative to be "behind". 0 means it is at the same depth as icons.
45
GLfloat fWidth, fHeight;
48
/// phase of the oscillations.
50
/// oscillation variation speed.
52
/// current size factor
54
/// size variation speed.
56
/// current life time, decreased by 1 at each step.
62
/// A particle system.
63
typedef struct _CairoParticleSystem {
64
CairoParticle *pParticles;
70
GLfloat fWidth, fHeight;
72
gboolean bDirectionUp;
73
gboolean bAddLuminance;
75
} CairoParticleSystem;
77
/// Function that re-initializes a particle when its life is over.
78
typedef void (CairoDockRewindParticleFunc) (CairoParticle *pParticle, double dt);
80
/** Render all the particles of a particle system with a given depth.
81
*@param pParticleSystem the particle system.
82
*@param iDepth depth of the particles that will be rendered. If set to -1, only particles with a negative z will be rendered, if set to 1, only particles with a positive z will be rendered, if set to 0, all the particles will be rendered.
84
void cairo_dock_render_particles_full (CairoParticleSystem *pParticleSystem, int iDepth);
85
/** Render all the particles of a particle system.
86
*@param pParticleSystem the particle system.
88
#define cairo_dock_render_particles(pParticleSystem) cairo_dock_render_particles_full (pParticleSystem, 0)
90
/** Create a particle system.
91
*@param iNbParticles number of particles of the system.
92
*@param iTexture texture to map on each particle.
93
*@param fWidth width of the system.
94
*@param fHeight height of the system.
95
*@return a newly allocated particle system.
97
CairoParticleSystem *cairo_dock_create_particle_system (int iNbParticles, GLuint iTexture, double fWidth, double fHeight);
99
/** Destroy a particle system, freeing all the ressources it was using.
100
*@param pParticleSystem the particle system.
102
void cairo_dock_free_particle_system (CairoParticleSystem *pParticleSystem);
104
/** Update a particle system to the next step with a generic particle behavior model. You can write your own model depending on your needs.
105
*@param pParticleSystem the particle system.
106
*@param pRewindParticle function called on a particle when its life is over.
107
*@return TRUE if some particles are still alive.
109
gboolean cairo_dock_update_default_particle_system (CairoParticleSystem *pParticleSystem, CairoDockRewindParticleFunc pRewindParticle);