2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the 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 // d_part.c: software driver module for drawing particles
31 void D_EndParticles (void)
33 // not used by software driver
42 void D_StartParticles (void)
44 // not used by software driver
55 void D_DrawParticle (particle_t
*pparticle
)
57 vec3_t local
, transformed
;
61 int i
, izi
, pix
, count
, u
, v
;
64 VectorSubtract (pparticle
->org
, r_origin
, local
);
66 transformed
[0] = DotProduct(local
, r_pright
);
67 transformed
[1] = DotProduct(local
, r_pup
);
68 transformed
[2] = DotProduct(local
, r_ppn
);
70 if (transformed
[2] < PARTICLE_Z_CLIP
)
74 // FIXME: preadjust xcenter and ycenter
75 zi
= 1.0 / transformed
[2];
76 u
= (int)(xcenter
+ zi
* transformed
[0] + 0.5);
77 v
= (int)(ycenter
- zi
* transformed
[1] + 0.5);
79 if ((v
> d_vrectbottom_particle
) ||
80 (u
> d_vrectright_particle
) ||
87 pz
= d_pzbuffer
+ (d_zwidth
* v
) + u
;
88 pdest
= d_viewbuffer
+ d_scantable
[v
] + u
;
89 izi
= (int)(zi
* 0x8000);
91 pix
= izi
>> d_pix_shift
;
95 else if (pix
> d_pix_max
)
101 count
= 1 << d_y_aspect_shift
;
103 for ( ; count
; count
--, pz
+= d_zwidth
, pdest
+= screenwidth
)
108 pdest
[0] = pparticle
->color
;
114 count
= 2 << d_y_aspect_shift
;
116 for ( ; count
; count
--, pz
+= d_zwidth
, pdest
+= screenwidth
)
121 pdest
[0] = pparticle
->color
;
127 pdest
[1] = pparticle
->color
;
133 count
= 3 << d_y_aspect_shift
;
135 for ( ; count
; count
--, pz
+= d_zwidth
, pdest
+= screenwidth
)
140 pdest
[0] = pparticle
->color
;
146 pdest
[1] = pparticle
->color
;
152 pdest
[2] = pparticle
->color
;
158 count
= 4 << d_y_aspect_shift
;
160 for ( ; count
; count
--, pz
+= d_zwidth
, pdest
+= screenwidth
)
165 pdest
[0] = pparticle
->color
;
171 pdest
[1] = pparticle
->color
;
177 pdest
[2] = pparticle
->color
;
183 pdest
[3] = pparticle
->color
;
189 count
= pix
<< d_y_aspect_shift
;
191 for ( ; count
; count
--, pz
+= d_zwidth
, pdest
+= screenwidth
)
193 for (i
=0 ; i
<pix
; i
++)
198 pdest
[i
] = pparticle
->color
;