Clean up the array copying for the new high scores list. It was way
[attac-man.git] / render_particle.c
blobc2c17cfeec8cfc15781252ba69b60f78afb47bae
1 /*
2 Pacman Arena
3 Copyright (C) 2003 Nuno Subtil
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 static const char cvsid[] =
21 "$Id: render_particle.c,v 1.2 2003/11/22 17:32:10 nsubtil Exp $";
23 #ifdef _WIN32
24 #include <windows.h>
25 #endif
27 #include <GL/gl.h>
28 #include <stdlib.h>
29 #include <stdio.h>
31 #include "game.h"
32 #include "player.h"
33 #include "object.h"
34 #include "render.h"
35 #include "gfx.h"
36 #include "m_math.h"
37 #include "map.h"
39 #include "particle.h"
40 #include "render_particle.h"
42 void particle_render_src(struct game *game, int player_no, struct particle_src *src)
44 struct camera *camera;
45 int c;
46 static struct image_rgba32 *texture = NULL;
48 /* XXX - different textures! */
49 if(texture == NULL)
51 texture = gfx_get("gfx/particle.tga");
52 gfx_alpha_from_intensity("gfx/particle.tga");
53 gfx_upload_texture("gfx/particle.tga");
56 camera = game->players[player_no].camera;
58 /* setup plane geometry */
59 render_setup_plane_geometry(camera, src->particle_size);
61 glEnable(GL_TEXTURE_2D);
62 glBindTexture(GL_TEXTURE_2D, texture->id);
63 glEnable(GL_BLEND);
64 glDepthMask(GL_FALSE);
66 #if 0
67 render_draw_colored_plane(src->position[X], src->position[Y], src->position[Z],
68 src->color, 1.0);
69 #else
70 /* XXX - display lists! */
71 for(c = 0; c < src->n_particles; c++)
73 struct particle *p;
75 p = &src->particles[c];
77 if(p->state == PARTICLE_STATE_DEAD)
78 continue;
80 if(p->time > src->particle_life)
82 float alpha;
84 alpha = 1.0 - (p->time - src->particle_life) / src->particle_fade;
85 render_draw_colored_plane(p->position[X], p->position[Y], p->position[Z],
86 p->color, alpha);
87 } else
88 render_draw_colored_plane(p->position[X], p->position[Y], p->position[Z],
89 p->color, 1.0);
91 #endif
92 glDepthMask(GL_TRUE);