1 /* sparkle2d.h 2 manage 2D sparkles (in 2D mode, of course) 3 4 Copyright (C) 2000 Mathias Broxvall 5 Yannick Perret 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 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 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 22 #ifndef SPARKLE2D_H 23 #define SPARKLE2D_H 24 25 #include "glHelp.h" 26 27 // There are typically ~30 sparkles 28 #define MAX_DRAWN_SPARKLES 64 29 30 /* structure of a sparkle */ 31 typedef struct _sparkle { 32 float pos[3]; 33 float speed[3]; 34 float color[4]; 35 float size; 36 float age; 37 float ttl; 38 struct _sparkle *next, *prev; 39 } Sparkle; 40 41 class Sparkle2D { 42 public: 43 Sparkle2D(); 44 ~Sparkle2D(); 45 46 // update sparkles 47 void tick(Real t); 48 // draw sparkles 49 void draw(); 50 // add a new sparkle 51 void add(float pos[2], float speed[2], float ttl, float size, float color[4]); 52 // remove all current sparkles (i.e. before changing screen) 53 void clear(); 54 static Sparkle2D *sparkle2D; 55 56 private: 57 // add a sparkle in the list 58 Sparkle *create_and_insert(); 59 // remove a specific sparkle 60 void remove_sparkle(Sparkle *sparkle); 61 // list of sparkles 62 Sparkle *sparkle_first; 63 int nsparkles; 64 65 GLuint vao; 66 GLuint idxs_buf; 67 GLuint data_buf; 68 69 GLfloat data[8 * 4 * MAX_DRAWN_SPARKLES]; 70 }; 71 72 #endif 73