From: Brian Paul Date: Thu, 4 Dec 2003 03:19:46 +0000 (+0000) Subject: Port over changes from XFree86/Mesa 5.0.2, mostly to silence compiler warnings. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b305028464f02947c0cce0476af0e35f4ed1fafa;p=mesa.git Port over changes from XFree86/Mesa 5.0.2, mostly to silence compiler warnings. --- diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 84a5f5c84cb..1bab6d91a41 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -1100,6 +1100,8 @@ static XMesaVisual choose_visual( Display *dpy, int screen, const int *list ) } } + (void) caveat; + /* * Since we're only simulating the GLX extension this function will never * find any real GL visuals. Instead, all we can do is try to find an RGB @@ -2019,6 +2021,10 @@ Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, } } + /* not used at this time */ + (void) useLargest; + (void) preserveContents; + if (width == 0 || height == 0) return 0; @@ -2373,6 +2379,10 @@ Fake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, } } + /* not used at this time */ + (void) useLargest; + (void) preserveContents; + xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height); /* A GLXPbuffer handle must be an X Drawable because that's what * glXMakeCurrent takes. diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index d800de97d5b..02c67c25cf3 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -881,6 +881,8 @@ static GLboolean setup_grayscale( int client, XMesaVisual v, static GLboolean setup_dithered_color( int client, XMesaVisual v, XMesaBuffer buffer, XMesaColormap cmap ) { + (void) DitherValues; /* silence warning */ + if (GET_VISUAL_DEPTH(v)<4 || GET_VISUAL_DEPTH(v)>16) { return GL_FALSE; } diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index d82edda7743..7d896c5d586 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -137,8 +137,8 @@ set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit ) else if (bufferBit == BACK_LEFT_BIT) { ASSERT(target->db_state); if (target->backpixmap) { - /* back buffer is a pixmape */ - target->buffer = target->backpixmap; /* incompatible types? */ + /* back buffer is a pixmap */ + target->buffer = (XMesaDrawable) target->backpixmap; } else if (target->backimage) { /* back buffer is an XImage */ @@ -413,6 +413,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, const GLubyte r = xmesa->clearcolor[0]; const GLubyte g = xmesa->clearcolor[1]; const GLubyte b = xmesa->clearcolor[2]; +#if 0 /* See below */ register GLuint clearPixel; if (xmesa->swapbytes) { clearPixel = (b << 16) | (g << 8) | r; @@ -420,6 +421,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, else { clearPixel = (r << 16) | (g << 8) | b; } +#endif if (all) { if (r==g && g==b) { diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index b7d2eeb20f9..e6b19fabd42 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -1,9 +1,8 @@ - /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 5.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -178,7 +177,7 @@ void GLAPIENTRY _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) { GLint baseFormat; - GLint i, components; + GLint i; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); @@ -215,8 +214,8 @@ _mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, G return; } - components = _mesa_components_in_format(format); - assert(components > 0); /* this should have been caught earlier */ + /* this should have been caught earlier */ + assert(_mesa_components_in_format(format)); ctx->Convolution2D.Format = format; ctx->Convolution2D.InternalFormat = internalFormat; @@ -304,22 +303,18 @@ void GLAPIENTRY _mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) { GET_CURRENT_CONTEXT(ctx); - struct gl_convolution_attrib *conv; GLuint c; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { case GL_CONVOLUTION_1D: c = 0; - conv = &ctx->Convolution1D; break; case GL_CONVOLUTION_2D: c = 1; - conv = &ctx->Convolution2D; break; case GL_SEPARABLE_2D: c = 2; - conv = &ctx->Separable2D; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(target)"); @@ -403,22 +398,18 @@ void GLAPIENTRY _mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) { GET_CURRENT_CONTEXT(ctx); - struct gl_convolution_attrib *conv; GLuint c; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { case GL_CONVOLUTION_1D: c = 0; - conv = &ctx->Convolution1D; break; case GL_CONVOLUTION_2D: c = 1; - conv = &ctx->Convolution2D; break; case GL_SEPARABLE_2D: c = 2; - conv = &ctx->Separable2D; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(target)"); diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index fa7a33e0c0d..0b512c57939 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -31,7 +31,7 @@ #include "mtypes.h" -#define F(x) (int)&(((struct gl_extensions *)0)->x) +#define F(x) (int)(unsigned long)&(((struct gl_extensions *)0)->x) #define ON GL_TRUE #define OFF GL_FALSE diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index ec08168fc02..e4579bdb6f8 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2481,7 +2481,6 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ) { struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; struct gl_texture_image *texImage; GLsizei postConvWidth = width; GET_CURRENT_CONTEXT(ctx); @@ -2498,7 +2497,6 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, return; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = _mesa_select_tex_object(ctx, texUnit, target); texImage = _mesa_select_tex_image(ctx, texUnit, target, level); ASSERT(texImage); @@ -2518,7 +2516,6 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, GLint x, GLint y, GLsizei width, GLsizei height ) { struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; struct gl_texture_image *texImage; GLsizei postConvWidth = width, postConvHeight = height; GET_CURRENT_CONTEXT(ctx); @@ -2535,7 +2532,6 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, return; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = _mesa_select_tex_object(ctx, texUnit, target); texImage = _mesa_select_tex_image(ctx, texUnit, target, level); ASSERT(texImage); @@ -2557,7 +2553,6 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, GLint x, GLint y, GLsizei width, GLsizei height ) { struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; struct gl_texture_image *texImage; GLsizei postConvWidth = width, postConvHeight = height; GET_CURRENT_CONTEXT(ctx); @@ -2574,7 +2569,6 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, return; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = _mesa_select_tex_object(ctx, texUnit, target); texImage = _mesa_select_tex_image(ctx, texUnit, target, level); ASSERT(texImage); @@ -2609,7 +2603,6 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize) { - GLboolean isProxy = GL_FALSE; GLint expectedSize, maxLevels = 0, maxTextureSize; if (dimensions == 1) { @@ -2619,7 +2612,6 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions, else if (dimensions == 2) { if (target == GL_PROXY_TEXTURE_2D) { maxLevels = ctx->Const.MaxTextureLevels; - isProxy = GL_TRUE; } else if (target == GL_TEXTURE_2D) { maxLevels = ctx->Const.MaxTextureLevels; @@ -2628,7 +2620,6 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions, if (!ctx->Extensions.ARB_texture_cube_map) return GL_INVALID_ENUM; /*target*/ maxLevels = ctx->Const.MaxCubeTextureLevels; - isProxy = GL_TRUE; } else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { @@ -2698,7 +2689,6 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize) { - GLboolean isProxy = GL_FALSE; GLint expectedSize, maxLevels = 0, maxTextureSize; if (dimensions == 1) { @@ -2708,7 +2698,6 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions, else if (dimensions == 2) { if (target == GL_PROXY_TEXTURE_2D) { maxLevels = ctx->Const.MaxTextureLevels; - isProxy = GL_TRUE; } else if (target == GL_TEXTURE_2D) { maxLevels = ctx->Const.MaxTextureLevels; @@ -2717,7 +2706,6 @@ compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions, if (!ctx->Extensions.ARB_texture_cube_map) return GL_INVALID_ENUM; /*target*/ maxLevels = ctx->Const.MaxCubeTextureLevels; - isProxy = GL_TRUE; } else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { @@ -3075,6 +3063,7 @@ _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, error = compressed_subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, width, height, 1, format, imageSize); if (error) { + /* XXX proxy target? */ _mesa_error(ctx, error, "glCompressedTexSubImage2D"); return; } diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 36d5c25ce4b..899201e6c4a 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -627,6 +627,7 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions, srcPacking, srcAddr, dstAddr); assert(b); + (void) b; } else if (dimensions == 2) { GLboolean b; @@ -638,6 +639,7 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions, srcPacking, srcAddr, dstAddr); assert(b); + (void) b; } else { GLboolean b; @@ -648,6 +650,7 @@ _mesa_transfer_teximage(GLcontext *ctx, GLuint dimensions, srcFormat, srcType, srcPacking, srcAddr, dstAddr); assert(b); + (void) b; } } else { diff --git a/src/mesa/main/texutil_tmp.h b/src/mesa/main/texutil_tmp.h index 7b2ccaa1c90..0be341c87c3 100644 --- a/src/mesa/main/texutil_tmp.h +++ b/src/mesa/main/texutil_tmp.h @@ -385,18 +385,16 @@ TAG(texsubimage2d_stride_unpack)( const struct convert_info *convert ) DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + (convert->yoffset * convert->dstImageWidth + convert->xoffset) * DST_TEXEL_BYTES); - GLint adjust; - GLint row, col = 0; - (void) col; - - adjust = convert->dstImageWidth - convert->width; + GLint row; +#ifndef CONVERT_DIRECT + GLint adjust = convert->dstImageWidth - convert->width; +#endif #if DEBUG_TEXUTIL _mesa_debug( NULL, __FUNCTION__ ":\n" ); _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n", convert->xoffset, convert->yoffset, convert->width, convert->height, convert->dstImageWidth ); - _mesa_debug( NULL, " adjust=%d\n", adjust ); #endif for ( row = 0 ; row < convert->height ; row++ ) { @@ -406,6 +404,7 @@ TAG(texsubimage2d_stride_unpack)( const struct convert_info *convert ) dst += convert->dstImageWidth; #else const GLubyte *srcRow = src; + GLint col; for ( col = 0 ; col < convert->width ; col++ ) { CONVERT_TEXEL( *dst++, src ); src += SRC_TEXEL_BYTES; @@ -437,18 +436,16 @@ TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert ) ((convert->zoffset * convert->dstImageHeight + convert->yoffset) * convert->dstImageWidth + convert->xoffset) * DST_TEXEL_BYTES); - GLint adjust; - GLint row, col = 0, img; - (void) col; - - adjust = convert->dstImageWidth - convert->width; + GLint row, img; +#ifndef CONVERT_DIRECT + GLint adjust = convert->dstImageWidth - convert->width; +#endif #if DEBUG_TEXUTIL _mesa_debug( NULL, __FUNCTION__ ":\n" ); _mesa_debug( NULL, " x=%d y=%d w=%d h=%d s=%d\n", convert->xoffset, convert->yoffset, convert->width, convert->height, convert->dstImageWidth ); - _mesa_debug( NULL, " adjust=%d\n", adjust ); #endif for ( img = 0 ; img < convert->depth ; img++ ) { @@ -460,6 +457,7 @@ TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert ) dst += convert->dstImageWidth; #else const GLubyte *srcRow = src; + GLint col; for ( col = 0 ; col < convert->width ; col++ ) { CONVERT_TEXEL( *dst++, src ); src += SRC_TEXEL_BYTES; diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 8e97b619bf2..5d4093f32c0 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -125,7 +125,6 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y, GLint skipPixels = unpack->SkipPixels; GLint skipRows = unpack->SkipRows; GLint rowLength; - GLdepth zSpan[MAX_WIDTH]; /* only used when zooming */ GLint zoomY0 = 0; if (unpack->RowLength > 0) @@ -185,13 +184,8 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y, return GL_TRUE; } else { - /* setup array of fragment Z value to pass to zoom function */ - GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMaxF); - GLint i; if (drawWidth > MAX_WIDTH) return GL_FALSE; /* fall back to general case path */ - for (i=0; iCurrent.RasterPos[1]); diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index f21f4f634dc..1ae1c946ff1 100644 --- a/src/mesa/swrast/s_pointtemp.h +++ b/src/mesa/swrast/s_pointtemp.h @@ -63,10 +63,10 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) #if FLAGS & (ATTENUATE | LARGE | SMOOTH | SPRITE) GLfloat size; #endif -#if FLAGS & ATTENUATE +#if FLAGS & RGBA +#if (FLAGS & ATTENUATE) && (FLAGS & SMOOTH) GLfloat alphaAtten; #endif -#if FLAGS & RGBA const GLchan red = vert->color[0]; const GLchan green = vert->color[1]; const GLchan blue = vert->color[2]; @@ -134,12 +134,16 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) #if FLAGS & ATTENUATE if (vert->pointSize >= ctx->Point.Threshold) { size = MIN2(vert->pointSize, ctx->Point.MaxSize); +#if (FLAGS & RGBA) && (FLAGS & SMOOTH) alphaAtten = 1.0F; +#endif } else { +#if (FLAGS & RGBA) && (FLAGS & SMOOTH) GLfloat dsize = vert->pointSize / ctx->Point.Threshold; - size = MAX2(ctx->Point.Threshold, ctx->Point.MinSize); alphaAtten = dsize * dsize; +#endif + size = MAX2(ctx->Point.Threshold, ctx->Point.MinSize); } #elif FLAGS & (LARGE | SMOOTH | SPRITE) size = ctx->Point._Size; diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index 5e40309cd0d..bfb8996c8db 100644 --- a/src/mesa/tnl/t_pipeline.c +++ b/src/mesa/tnl/t_pipeline.c @@ -123,7 +123,9 @@ void _tnl_run_pipeline( GLcontext *ctx ) GLuint changed_state = pipe->run_state_changes; GLuint changed_inputs = pipe->run_input_changes; GLboolean running = GL_TRUE; +#ifdef HAVE_FAST_MATH unsigned short __tmp; +#endif pipe->run_state_changes = 0; pipe->run_input_changes = 0; @@ -132,7 +134,9 @@ void _tnl_run_pipeline( GLcontext *ctx ) */ ASSERT(pipe->build_state_changes == 0); +#ifdef HAVE_FAST_MATH START_FAST_MATH(__tmp); +#endif /* If something changes in the pipeline, tag all subsequent stages * using this value for recalculation. Inactive stages have their @@ -155,7 +159,9 @@ void _tnl_run_pipeline( GLcontext *ctx ) } } +#ifdef HAVE_FAST_MATH END_FAST_MATH(__tmp); +#endif } diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index 167325eae83..7af1a4bfabf 100644 --- a/src/mesa/tnl/t_vb_lighttmp.h +++ b/src/mesa/tnl/t_vb_lighttmp.h @@ -1,9 +1,8 @@ - /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 5.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -61,9 +60,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; - GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].data; +#if IDX & LIGHT_TWOSIDE + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; GLfloat (*Bspec)[4] = (GLfloat (*)[4]) store->LitSecondary[1].data; +#endif const GLuint nr = VB->Count; @@ -78,11 +79,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, VB->SecondaryColorPtr[0] = &store->LitSecondary[0]; sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - if (IDX & LIGHT_TWOSIDE) { - VB->ColorPtr[1] = &store->LitColor[1]; - VB->SecondaryColorPtr[1] = &store->LitSecondary[1]; - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; - } +#if IDX & LIGHT_TWOSIDE + VB->ColorPtr[1] = &store->LitColor[1]; + VB->SecondaryColorPtr[1] = &store->LitSecondary[1]; + sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; +#endif /* Side-effects done, can we finish now? */ @@ -93,20 +94,21 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, GLfloat sum[2][3], spec[2][3]; struct gl_light *light; - if ( IDX & LIGHT_MATERIAL ) { - update_materials( ctx, store ); - sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - if (IDX & LIGHT_TWOSIDE) - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; - } +#if IDX & LIGHT_MATERIAL + update_materials( ctx, store ); + sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; +#if IDX & LIGHT_TWOSIDE + sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; +#endif +#endif COPY_3V(sum[0], base[0]); ZERO_3V(spec[0]); - if (IDX & LIGHT_TWOSIDE) { - COPY_3V(sum[1], base[1]); - ZERO_3V(spec[1]); - } +#if IDX & LIGHT_TWOSIDE + COPY_3V(sum[1], base[1]); + ZERO_3V(spec[1]); +#endif /* Add contribution from each enabled light source */ foreach (light, &ctx->Light.EnabledList) { @@ -167,17 +169,18 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, /* Which side gets the diffuse & specular terms? */ if (n_dot_VP < 0.0F) { ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); - if (!(IDX & LIGHT_TWOSIDE)) { - continue; - } +#if IDX & LIGHT_TWOSIDE side = 1; correction = -1; n_dot_VP = -n_dot_VP; +#else + continue; +#endif } else { - if (IDX & LIGHT_TWOSIDE) { - ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); - } +#if IDX & LIGHT_TWOSIDE + ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); +#endif side = 0; correction = 1; } @@ -224,11 +227,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, COPY_3V( Fspec[j], spec[0] ); Fcolor[j][3] = sumA[0]; - if (IDX & LIGHT_TWOSIDE) { - COPY_3V( Bcolor[j], sum[1] ); - COPY_3V( Bspec[j], spec[1] ); - Bcolor[j][3] = sumA[1]; - } +#if IDX & LIGHT_TWOSIDE + COPY_3V( Bcolor[j], sum[1] ); + COPY_3V( Bspec[j], spec[1] ); + Bcolor[j][3] = sumA[1]; +#endif } } @@ -268,10 +271,10 @@ static void TAG(light_rgba)( GLcontext *ctx, VB->ColorPtr[0] = &store->LitColor[0]; sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - if (IDX & LIGHT_TWOSIDE) { - VB->ColorPtr[1] = &store->LitColor[1]; - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; - } +#if IDX & LIGHT_TWOSIDE + VB->ColorPtr[1] = &store->LitColor[1]; + sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; +#endif if (stage->changed_inputs == 0) return; @@ -283,8 +286,9 @@ static void TAG(light_rgba)( GLcontext *ctx, if ( IDX & LIGHT_MATERIAL ) { update_materials( ctx, store ); sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - if (IDX & LIGHT_TWOSIDE) - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; +#if IDX & LIGHT_TWOSIDE + sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; +#endif } COPY_3V(sum[0], base[0]); @@ -353,18 +357,18 @@ static void TAG(light_rgba)( GLcontext *ctx, /* which side are we lighting? */ if (n_dot_VP < 0.0F) { ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); - - if (!(IDX & LIGHT_TWOSIDE)) - continue; - +#if IDX & LIGHT_TWOSIDE side = 1; correction = -1; n_dot_VP = -n_dot_VP; +#else + continue; +#endif } else { - if (IDX & LIGHT_TWOSIDE) { - ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); - } +#if IDX & LIGHT_TWOSIDE + ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); +#endif side = 0; correction = 1; } @@ -413,10 +417,10 @@ static void TAG(light_rgba)( GLcontext *ctx, COPY_3V( Fcolor[j], sum[0] ); Fcolor[j][3] = sumA[0]; - if (IDX & LIGHT_TWOSIDE) { - COPY_3V( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; - } +#if IDX & LIGHT_TWOSIDE + COPY_3V( Bcolor[j], sum[1] ); + Bcolor[j][3] = sumA[1]; +#endif } } @@ -435,7 +439,9 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, const GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; +#if IDX & LIGHT_TWOSIDE GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; +#endif const struct gl_light *light = ctx->Light.EnabledList.next; GLuint j = 0; GLfloat base[2][3]; @@ -450,8 +456,9 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, (void) nstride; VB->ColorPtr[0] = &store->LitColor[0]; - if (IDX & LIGHT_TWOSIDE) - VB->ColorPtr[1] = &store->LitColor[1]; +#if IDX & LIGHT_TWOSIDE + VB->ColorPtr[1] = &store->LitColor[1]; +#endif if (stage->changed_inputs == 0) return; @@ -470,29 +477,29 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, ACC_3V(base[0], ctx->Light._BaseColor[0] ); base[0][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - if (IDX & LIGHT_TWOSIDE) { - COPY_3V(base[1], light->_MatAmbient[1]); - ACC_3V(base[1], ctx->Light._BaseColor[1]); - base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; - } +#if IDX & LIGHT_TWOSIDE + COPY_3V(base[1], light->_MatAmbient[1]); + ACC_3V(base[1], ctx->Light._BaseColor[1]); + base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; +#endif } n_dot_VP = DOT3(normal, light->_VP_inf_norm); if (n_dot_VP < 0.0F) { - if (IDX & LIGHT_TWOSIDE) { - GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); - GLfloat sum[3]; - COPY_3V(sum, base[1]); - ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]); - if (n_dot_h > 0.0F) { - GLfloat spec; - GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec ); - ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]); - } - COPY_3V(Bcolor[j], sum ); - Bcolor[j][3] = base[1][3]; - } +#if IDX & LIGHT_TWOSIDE + GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); + GLfloat sum[3]; + COPY_3V(sum, base[1]); + ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]); + if (n_dot_h > 0.0F) { + GLfloat spec; + GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec ); + ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]); + } + COPY_3V(Bcolor[j], sum ); + Bcolor[j][3] = base[1][3]; +#endif COPY_4FV(Fcolor[j], base[0]); } else { @@ -508,7 +515,9 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, } COPY_3V(Fcolor[j], sum ); Fcolor[j][3] = base[0][3]; - if (IDX & LIGHT_TWOSIDE) COPY_4FV(Bcolor[j], base[1]); +#if IDX & LIGHT_TWOSIDE + COPY_4FV(Bcolor[j], base[1]); +#endif } } } @@ -526,7 +535,9 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, const GLuint nstride = VB->NormalPtr->stride; const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; +#if IDX & LIGHT_TWOSIDE GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; +#endif GLuint j = 0; const GLuint nr = VB->Count; const struct gl_light *light; @@ -543,8 +554,9 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; VB->ColorPtr[0] = &store->LitColor[0]; - if (IDX & LIGHT_TWOSIDE) - VB->ColorPtr[1] = &store->LitColor[1]; +#if IDX & LIGHT_TWOSIDE + VB->ColorPtr[1] = &store->LitColor[1]; +#endif if (stage->changed_inputs == 0) return; @@ -557,21 +569,24 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, update_materials( ctx, store ); sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; - if (IDX & LIGHT_TWOSIDE) - sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; +#if IDX & LIGHT_TWOSIDE + sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; +#endif } COPY_3V(sum[0], ctx->Light._BaseColor[0]); - if (IDX & LIGHT_TWOSIDE) - COPY_3V(sum[1], ctx->Light._BaseColor[1]); +#if IDX & LIGHT_TWOSIDE + COPY_3V(sum[1], ctx->Light._BaseColor[1]); +#endif foreach (light, &ctx->Light.EnabledList) { GLfloat n_dot_h, n_dot_VP, spec; ACC_3V(sum[0], light->_MatAmbient[0]); - if (IDX & LIGHT_TWOSIDE) - ACC_3V(sum[1], light->_MatAmbient[1]); +#if IDX & LIGHT_TWOSIDE + ACC_3V(sum[1], light->_MatAmbient[1]); +#endif n_dot_VP = DOT3(normal, light->_VP_inf_norm); @@ -584,7 +599,8 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, ACC_SCALE_SCALAR_3V( sum[0], spec, light->_MatSpecular[0]); } } - else if (IDX & LIGHT_TWOSIDE) { +#if IDX & LIGHT_TWOSIDE + else { ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]); n_dot_h = -DOT3(normal, light->_h_inf_norm); if (n_dot_h > 0.0F) { @@ -593,15 +609,16 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, ACC_SCALE_SCALAR_3V( sum[1], spec, light->_MatSpecular[1]); } } +#endif } COPY_3V( Fcolor[j], sum[0] ); Fcolor[j][3] = sumA[0]; - if (IDX & LIGHT_TWOSIDE) { - COPY_3V( Bcolor[j], sum[1] ); - Bcolor[j][3] = sumA[1]; - } +#if IDX & LIGHT_TWOSIDE + COPY_3V( Bcolor[j], sum[1] ); + Bcolor[j][3] = sumA[1]; +#endif } } @@ -640,15 +657,17 @@ static void TAG(light_ci)( GLcontext *ctx, (void) vstride; VB->IndexPtr[0] = &store->LitIndex[0]; - if (IDX & LIGHT_TWOSIDE) - VB->IndexPtr[1] = &store->LitIndex[1]; +#if IDX & LIGHT_TWOSIDE + VB->IndexPtr[1] = &store->LitIndex[1]; +#endif if (stage->changed_inputs == 0) return; indexResult[0] = (GLfloat *)VB->IndexPtr[0]->data; - if (IDX & LIGHT_TWOSIDE) - indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data; +#if IDX & LIGHT_TWOSIDE + indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data; +#endif /* loop over vertices */ for (j=0; j