diff options
author | Andrey Nazarov <skuller@skuller.net> | 2011-03-25 19:59:39 +0300 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2011-03-26 14:43:07 +0300 |
commit | bc9ae76c1f5c91810cd36e5d19ccad3790b35715 (patch) | |
tree | 2c90fa2b993f10bc3924f53ea2fded0c8824d00c /src/q_shared.h | |
parent | e7a0d43b36389b2a0304b30963b8db18517fd8e6 (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/q_shared.h')
-rw-r--r-- | src/q_shared.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/q_shared.h b/src/q_shared.h index 9817c23..0c3d19b 100644 --- a/src/q_shared.h +++ b/src/q_shared.h @@ -174,7 +174,10 @@ typedef vec_t vec5_t[5]; typedef float mat4_t[16]; -typedef unsigned char color_t[4]; +typedef union { + uint32_t u32; + uint8_t u8[4]; +} color_t; typedef int fixed4_t; typedef int fixed8_t; @@ -284,8 +287,6 @@ static inline float Q_fabs( float f ) { #define Vector4Negate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2],(b)[3]=-(a)[3]) #define Vector4Set(v, a, b, c, d) ((v)[0]=(a),(v)[1]=(b),(v)[2]=(c),(v)[3]=(d)) -#define FastColorCopy(a,b) memcpy(b,a,4) - void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); vec_t VectorNormalize (vec3_t v); // returns vector length vec_t VectorNormalize2 (vec3_t v, vec3_t out); @@ -552,6 +553,12 @@ static inline float FloatSwap( float f ) { (b)[1]=LittleFloat((a)[1]),\ (b)[2]=LittleFloat((a)[2])) +#if USE_BGRA +#define MakeColor( r, g, b, a ) MakeRawLong( b, g, r, a ) +#else +#define MakeColor( r, g, b, a ) MakeRawLong( r, g, b, a ) +#endif + //============================================= // |