From d9873c59ef4d14b5e3137cb2d7c765797f82ac56 Mon Sep 17 00:00:00 2001 From: Daniel Borca Date: Fri, 24 Sep 2004 07:03:53 +0000 Subject: added (back!) option to use non-packedcolor --- src/mesa/drivers/glide/fxdrv.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/mesa/drivers/glide/fxdrv.h') diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index c246444d1c..9cc6d15e0b 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -731,6 +731,28 @@ void fxSetupStencil (GLcontext *ctx); extern GLuint fx_check_IsInHardware(GLcontext *ctx); +/*** + *** CNORM: clamp float to [0,1] and map to float in [0,255] + ***/ +#if defined(USE_IEEE) && !defined(DEBUG) +#define IEEE_0996 0x3f7f0000 /* 0.996 or so */ +#define CNORM(N, F) \ + do { \ + fi_type __tmp; \ + __tmp.f = (F); \ + if (__tmp.i < 0) \ + N = 0; \ + else if (__tmp.i >= IEEE_0996) \ + N = 255.0f; \ + else { \ + N = (F) * 255.0f; \ + } \ + } while (0) +#else +#define CNORM(n, f) \ + n = (CLAMP((f), 0.0F, 1.0F) * 255.0F) +#endif + /* run-time debugging */ #ifndef FX_DEBUG #define FX_DEBUG 0 -- cgit v1.2.3