summaryrefslogtreecommitdiff
path: root/src/gl_tess.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2011-03-25 19:59:39 +0300
committerAndrey Nazarov <skuller@skuller.net>2011-03-26 14:43:07 +0300
commitbc9ae76c1f5c91810cd36e5d19ccad3790b35715 (patch)
tree2c90fa2b993f10bc3924f53ea2fded0c8824d00c /src/gl_tess.c
parente7a0d43b36389b2a0304b30963b8db18517fd8e6 (diff)
Clean up and fix 32-bit color API.
Make color_t a union to work around aliasing issues. Get rid of FastColorCopy macro in favor of direct assignment. Get rid of DRAW_COLOR_* macros in favor of separate APIs for clearing and setting 32-bit color and alpha values. Rename R_DrawFill/R_DrawFillEx into R_DrawFill8/R_DrawFill32 for consistency. Remove unused fields from laser_t struct. Fix 32-bit particles fading out too soon. Fix console text drawing with software renderer. Fix possible SCR_ParseColor buffer overflow.
Diffstat (limited to 'src/gl_tess.c')
-rw-r--r--src/gl_tess.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/gl_tess.c b/src/gl_tess.c
index 2cb9e65..967a57e 100644
--- a/src/gl_tess.c
+++ b/src/gl_tess.c
@@ -119,12 +119,12 @@ void GL_DrawParticles( void ) {
scale += dist * 0.01f;
}
- if( p->color == 255 ) {
- FastColorCopy( p->rgb, color );
+ if( p->color == -1 ) {
+ color.u32 = p->rgba.u32;
} else {
- *( uint32_t * )color = d_8to24table[p->color & 255];
+ color.u32 = d_8to24table[p->color & 0xff];
+ color.u8[3] = 255 * p->alpha;
}
- color[3] = p->alpha * 255;
if( numverts + 3 > TESS_MAX_VERTICES ) {
qglDrawArrays( GL_TRIANGLES, 0, numverts );
@@ -149,9 +149,9 @@ void GL_DrawParticles( void ) {
dst_vert[13] = PARTICLE_SIZE; dst_vert[14] = 0;
dst_color = ( uint32_t * )tess.colors + numverts;
- dst_color[0] = *( uint32_t * )color;
- dst_color[1] = *( uint32_t * )color;
- dst_color[2] = *( uint32_t * )color;
+ dst_color[0] = color.u32;
+ dst_color[1] = color.u32;
+ dst_color[2] = color.u32;
numverts += 3;
}
@@ -210,12 +210,12 @@ void GL_DrawBeams( void ) {
length = VectorLength( d1 );
- if( ent->lightstyle ) {
- *( uint32_t * )color = *( uint32_t * )&ent->skinnum;
+ if( ent->skinnum == -1 ) {
+ color.u32 = ent->rgba.u32;
} else {
- *( uint32_t * )color = d_8to24table[ent->skinnum & 0xFF];
+ color.u32 = d_8to24table[ent->skinnum & 0xff];
+ color.u8[3] = 255 * ent->alpha;
}
- color[3] = 255 * ent->alpha;
if( numverts + 4 > TESS_MAX_VERTICES ||
numindices + 6 > TESS_MAX_INDICES )
@@ -237,10 +237,10 @@ void GL_DrawBeams( void ) {
dst_vert[18] = 0; dst_vert[19] = length;
dst_color = ( uint32_t * )tess.colors + numverts;
- dst_color[0] = *( uint32_t * )color;
- dst_color[1] = *( uint32_t * )color;
- dst_color[2] = *( uint32_t * )color;
- dst_color[3] = *( uint32_t * )color;
+ dst_color[0] = color.u32;
+ dst_color[1] = color.u32;
+ dst_color[2] = color.u32;
+ dst_color[3] = color.u32;
dst_indices = tess.indices + numindices;
dst_indices[0] = numverts + 0;