Search
lxdream.org :: lxdream :: r200:c3bdcd373b6d
lxdream 0.9.1
released Jun 29
Download Now
changeset200:c3bdcd373b6d
parent199:4433d9c1638c
child201:65183b9b0641
authornkeynes
dateSun Aug 06 04:01:37 2006 +0000 (17 years ago)
Fix parse_float_colour for values <= 0 and qNaN
src/pvr2/tacore.c
1.1 --- a/src/pvr2/tacore.c Sun Aug 06 03:50:36 2006 +0000
1.2 +++ b/src/pvr2/tacore.c Sun Aug 06 04:01:37 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: tacore.c,v 1.5 2006-08-06 03:50:36 nkeynes Exp $
1.6 + * $Id: tacore.c,v 1.6 2006-08-06 04:01:37 nkeynes Exp $
1.7 *
1.8 * PVR2 Tile Accelerator implementation
1.9 *
1.10 @@ -213,11 +213,33 @@
1.11 }
1.12
1.13 static uint32_t parse_float_colour( float a, float r, float g, float b ) {
1.14 - return
1.15 - (((unsigned int)((256 * CLAMP(a,0.0,1.0))-1))<<24) |
1.16 - (((unsigned int)((256 * CLAMP(r,0.0,1.0))-1))<<16) |
1.17 - (((unsigned int)((256 * CLAMP(g,0.0,1.0))-1))<<8) |
1.18 - (((unsigned int)((256 * CLAMP(b,0.0,1.0))-1)));
1.19 + int ai,ri,gi,bi;
1.20 +
1.21 + if( TA_IS_INF(a) ) {
1.22 + ai = 255;
1.23 + } else {
1.24 + ai = 256 * CLAMP(a,0.0,1.0) - 1;
1.25 + if( ai < 0 ) ai = 0;
1.26 + }
1.27 + if( TA_IS_INF(r) ) {
1.28 + ri = 255;
1.29 + } else {
1.30 + ri = 256 * CLAMP(r,0.0,1.0) - 1;
1.31 + if( ri < 0 ) ri = 0;
1.32 + }
1.33 + if( TA_IS_INF(g) ) {
1.34 + gi = 255;
1.35 + } else {
1.36 + gi = 256 * CLAMP(g,0.0,1.0) - 1;
1.37 + if( gi < 0 ) gi = 0;
1.38 + }
1.39 + if( TA_IS_INF(b) ) {
1.40 + bi = 255;
1.41 + } else {
1.42 + bi = 256 * CLAMP(b,0.0,1.0) - 1;
1.43 + if( bi < 0 ) bi = 0;
1.44 + }
1.45 + return (ai << 24) | (ri << 16) | (gi << 8) | bi;
1.46 }
1.47
1.48 static uint32_t parse_intensity_colour( uint32_t base, float intensity )
.