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 $";
40 #include "render_particle.h"
42 void particle_render_src(struct game
*game
, int player_no
, struct particle_src
*src
)
44 struct camera
*camera
;
46 static struct image_rgba32
*texture
= NULL
;
48 /* XXX - different textures! */
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
);
64 glDepthMask(GL_FALSE
);
67 render_draw_colored_plane(src
->position
[X
], src
->position
[Y
], src
->position
[Z
],
70 /* XXX - display lists! */
71 for(c
= 0; c
< src
->n_particles
; c
++)
75 p
= &src
->particles
[c
];
77 if(p
->state
== PARTICLE_STATE_DEAD
)
80 if(p
->time
> src
->particle_life
)
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
],
88 render_draw_colored_plane(p
->position
[X
], p
->position
[Y
], p
->position
[Z
],