diff options
author | Jouk Jansen <[email protected]> | 2000-11-22 07:32:16 +0000 |
---|---|---|
committer | Jouk Jansen <[email protected]> | 2000-11-22 07:32:16 +0000 |
commit | 5e3bc0c2a2bcdf59949410f94c9b705fc1281ce8 (patch) | |
tree | ee6c08673fe9a228afc6960699a3dfff32e9cbab /src/mesa/main/light.c | |
parent | fbe3726050f2cd69694df9f24986e951b4c2737e (diff) |
Committing in .
Modified Files:
Mesa/macos/gli_api/gliapi1.h Mesa/macos/gli_api/gliapi2.h
Mesa/macos/gli_api/gliapiext.h Mesa/macos/src-gli/fxgli.c
Mesa/macos/src-gli/fxgli.h Mesa/macos/src-gli/fxgli2.c
Mesa/macos/src-gli/fxgli_tridebug.c Mesa/src/accum.c
Mesa/src/accum.h Mesa/src/all.h Mesa/src/alpha.c
Mesa/src/alpha.h Mesa/src/attrib.c Mesa/src/attrib.h
Mesa/src/bitmap.c Mesa/src/bitmap.h Mesa/src/blend.c
Mesa/src/blend.h Mesa/src/buffers.c Mesa/src/buffers.h
Mesa/src/clip.c Mesa/src/clip.h Mesa/src/colortab.h
Mesa/src/config.c Mesa/src/context.c Mesa/src/context.h
Mesa/src/convolve.c Mesa/src/convolve.h Mesa/src/copypix.c
Mesa/src/copypix.h Mesa/src/debug.c Mesa/src/depth.c
Mesa/src/depth.h Mesa/src/dlist.c Mesa/src/dlist.h
Mesa/src/drawpix.c Mesa/src/drawpix.h Mesa/src/enable.c
Mesa/src/enable.h Mesa/src/eval.c Mesa/src/eval.h
Mesa/src/extensions.c Mesa/src/extensions.h
Mesa/src/feedback.c Mesa/src/feedback.h Mesa/src/fog.c
Mesa/src/fog.h Mesa/src/get.c Mesa/src/get.h Mesa/src/glapi.c
Mesa/src/glthread.h Mesa/src/highpc.c Mesa/src/hint.h
Mesa/src/histogram.h Mesa/src/image.c Mesa/src/image.h
Mesa/src/imports.c Mesa/src/light.c Mesa/src/light.h
Mesa/src/lines.c Mesa/src/lines.h Mesa/src/logic.c
Mesa/src/logic.h Mesa/src/masking.c Mesa/src/masking.h
Mesa/src/matrix.c Mesa/src/matrix.h Mesa/src/pixel.c
Mesa/src/pixel.h Mesa/src/points.c Mesa/src/points.h
Mesa/src/polygon.c Mesa/src/polygon.h Mesa/src/rastpos.c
Mesa/src/readpix.c Mesa/src/scissor.c Mesa/src/scissor.h
Mesa/src/state.c Mesa/src/state.h Mesa/src/stencil.c
Mesa/src/stencil.h Mesa/src/teximage.c Mesa/src/teximage.h
Mesa/src/texobj.c Mesa/src/texobj.h Mesa/src/texstate.c
Mesa/src/texstate.h Mesa/src/texture.c Mesa/src/texture.h
Mesa/src/texutil.c Mesa/src/texutil.h Mesa/src/varray.c
Mesa/src/varray.h Mesa/src/X/fakeglx.c Mesa/src/X/xm_api.c
Mesa/src/X/xm_dd.c Mesa/src/X/xm_line.c Mesa/src/X/xm_span.c
Mesa/src/X/xm_tri.c Mesa/src/swrast/s_aaline.c
Mesa/src/swrast/s_aaline.h Mesa/src/swrast/s_aatriangle.h
Mesa/src/swrast/s_accum.h Mesa/src/swrast/s_alpha.h
Mesa/src/swrast/s_alphabuf.h Mesa/src/swrast/s_blend.h
Mesa/src/swrast/s_context.c Mesa/src/swrast/s_context.h
Mesa/src/swrast/s_depth.h Mesa/src/swrast/s_drawpix.h
Mesa/src/swrast/s_feedback.h Mesa/src/swrast/s_fog.h
Mesa/src/swrast/s_histogram.h Mesa/src/swrast/s_lines.h
Mesa/src/swrast/s_logic.h Mesa/src/swrast/s_masking.h
Mesa/src/swrast/s_pb.h Mesa/src/swrast/s_pixeltex.h
Mesa/src/swrast/s_points.h Mesa/src/swrast/s_quads.c
Mesa/src/swrast/s_quads.h Mesa/src/swrast/s_scissor.h
Mesa/src/swrast/s_span.h Mesa/src/swrast/s_stencil.h
Mesa/src/swrast/s_texture.h Mesa/src/swrast/s_triangle.h
Mesa/src/swrast/s_zoom.h Mesa/src/swrast/swrast.h
Mesa/src/swrast_setup/ss_context.h
Mesa/src/swrast_setup/ss_triangle.c
Mesa/src/swrast_setup/ss_triangle.h
Mesa/src/swrast_setup/ss_vb.h Mesa/src/tnl/t_clip.c
Mesa/src/tnl/t_clip.h Mesa/src/tnl/t_context.c
Mesa/src/tnl/t_context.h Mesa/src/tnl/t_cva.c
Mesa/src/tnl/t_cva.h Mesa/src/tnl/t_debug.c
Mesa/src/tnl/t_debug.h Mesa/src/tnl/t_dlist.h
Mesa/src/tnl/t_eval.c Mesa/src/tnl/t_eval.h
Mesa/src/tnl/t_fog.c Mesa/src/tnl/t_fog.h
Mesa/src/tnl/t_light.c Mesa/src/tnl/t_light.h
Mesa/src/tnl/t_pipeline.c Mesa/src/tnl/t_pipeline.h
Mesa/src/tnl/t_shade.c Mesa/src/tnl/t_shade.h
Mesa/src/tnl/t_stages.c Mesa/src/tnl/t_stages.h
Mesa/src/tnl/t_texture.c Mesa/src/tnl/t_texture.h
Mesa/src/tnl/t_trans_elt.c Mesa/src/tnl/t_trans_elt.h
Mesa/src/tnl/t_varray.c Mesa/src/tnl/t_varray.h
Mesa/src/tnl/t_vb.c Mesa/src/tnl/t_vb.h
Mesa/src/tnl/t_vbcull.c Mesa/src/tnl/t_vbcull.h
Mesa/src/tnl/t_vbfill.c Mesa/src/tnl/t_vbfill.h
Mesa/src/tnl/t_vbindirect.c Mesa/src/tnl/t_vbindirect.h
Mesa/src/tnl/t_vbrender.c Mesa/src/tnl/t_vbrender.h
Mesa/src/tnl/t_vbxform.c Mesa/src/tnl/t_vbxform.h
Mesa/src/tnl/tnl.h
Added Files:
Mesa/src/mtypes.h
Removed Files:
Mesa/src/types.h
Changed Mesa/src/types to Mesa/src/mtypes.h to avoid conflicts while
compiling on a VMS system.
----------------------------------------------------------------------
Diffstat (limited to 'src/mesa/main/light.c')
-rw-r--r-- | src/mesa/main/light.c | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index ef31c561ba6..a1c58f8f3cf 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,21 +1,21 @@ -/* $Id: light.c,v 1.26 2000/11/16 21:05:35 keithw Exp $ */ +/* $Id: light.c,v 1.27 2000/11/22 07:32:17 joukj Exp $ */ /* * Mesa 3-D graphics library * Version: 3.5 - * + * * Copyright (C) 1999-2000 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"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -37,7 +37,7 @@ #include "mem.h" #include "mmath.h" #include "simple_list.h" -#include "types.h" +#include "mtypes.h" #include "math/m_xform.h" #include "math/m_matrix.h" @@ -69,7 +69,7 @@ _mesa_ShadeModel( GLenum mode ) ctx->NewState |= _NEW_LIGHT; - if (ctx->Driver.ShadeModel) + if (ctx->Driver.ShadeModel) (*ctx->Driver.ShadeModel)( ctx, mode ); } } @@ -114,7 +114,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) case GL_POSITION: /* transform position by ModelView matrix */ TRANSFORM_POINT( l->EyePosition, ctx->ModelView.m, params ); - if (l->EyePosition[3] != 0.0F) + if (l->EyePosition[3] != 0.0F) l->_Flags |= LIGHT_POSITIONAL; else l->_Flags &= ~LIGHT_POSITIONAL; @@ -143,7 +143,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) } l->SpotCutoff = params[0]; l->_CosCutoff = cos(params[0]*DEG2RAD); - if (l->_CosCutoff < 0) + if (l->_CosCutoff < 0) l->_CosCutoff = 0; if (l->SpotCutoff != 180.0F) l->_Flags |= LIGHT_SPOT; @@ -372,7 +372,7 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) ctx->Light.Model.LocalViewer = GL_TRUE; break; case GL_LIGHT_MODEL_TWO_SIDE: - if (params[0]==0.0) + if (params[0]==0.0) ctx->Light.Model.TwoSide = GL_FALSE; else ctx->Light.Model.TwoSide = GL_TRUE; @@ -396,7 +396,7 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) break; } - if (ctx->Driver.LightModelfv) + if (ctx->Driver.LightModelfv) ctx->Driver.LightModelfv( ctx, pname, params ); ctx->NewState |= _NEW_LIGHT; @@ -452,7 +452,7 @@ _mesa_LightModelf( GLenum pname, GLfloat param ) * Given a face and pname value (ala glColorMaterial), compute a bitmask * of the targeted material values. */ -GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, +GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, GLuint legal, const char *where ) { @@ -497,7 +497,7 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, gl_error( ctx, GL_INVALID_ENUM, where ); return 0; } - + if (bitmask & ~legal) { gl_error( ctx, GL_INVALID_ENUM, where ); return 0; @@ -519,12 +519,12 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, * * KW: Added code here to keep the precomputed variables uptodate. * This means we can use the faster shade functions when using - * GL_COLOR_MATERIAL, and we can also now use the precomputed + * GL_COLOR_MATERIAL, and we can also now use the precomputed * values in the slower shading functions, which further offsets * the cost of doing this here. */ -void gl_update_material( GLcontext *ctx, - const struct gl_material src[2], +void gl_update_material( GLcontext *ctx, + const struct gl_material src[2], GLuint bitmask ) { struct gl_light *light, *list = &ctx->Light.EnabledList; @@ -532,10 +532,10 @@ void gl_update_material( GLcontext *ctx, if (ctx->Light.ColorMaterialEnabled) bitmask &= ~ctx->Light.ColorMaterialBitmask; - if (MESA_VERBOSE&VERBOSE_IMMEDIATE) + if (MESA_VERBOSE&VERBOSE_IMMEDIATE) fprintf(stderr, "gl_update_material, mask 0x%x\n", bitmask); - if (!bitmask) + if (!bitmask) return; /* update material emission */ @@ -605,7 +605,7 @@ void gl_update_material( GLcontext *ctx, SUB_3V( tmp, src[0].Specular, mat->Specular ); foreach (light, list) { ACC_SCALE_3V( light->_MatSpecular[0], light->Specular, tmp ); - light->_IsMatSpecular[0] = + light->_IsMatSpecular[0] = (LEN_SQUARED_3FV(light->_MatSpecular[0]) > 1e-16); } COPY_4FV( mat->Specular, src[0].Specular ); @@ -616,7 +616,7 @@ void gl_update_material( GLcontext *ctx, SUB_3V( tmp, src[1].Specular, mat->Specular ); foreach (light, list) { ACC_SCALE_3V( light->_MatSpecular[1], light->Specular, tmp ); - light->_IsMatSpecular[1] = + light->_IsMatSpecular[1] = (LEN_SQUARED_3FV(light->_MatSpecular[1]) > 1e-16); } COPY_4FV( mat->Specular, src[1].Specular ); @@ -674,7 +674,7 @@ void gl_update_material( GLcontext *ctx, * according to the bitmask in ColorMaterialBitmask, which is * set by glColorMaterial(). */ -void gl_update_color_material( GLcontext *ctx, +void gl_update_color_material( GLcontext *ctx, const GLchan rgba[4] ) { struct gl_light *light, *list = &ctx->Light.EnabledList; @@ -760,7 +760,7 @@ void gl_update_color_material( GLcontext *ctx, SUB_3V( tmp, color, mat->Specular ); foreach (light, list) { ACC_SCALE_3V( light->_MatSpecular[0], light->Specular, tmp ); - light->_IsMatSpecular[0] = + light->_IsMatSpecular[0] = (LEN_SQUARED_3FV(light->_MatSpecular[0]) > 1e-16); } COPY_4FV( mat->Specular, color ); @@ -772,7 +772,7 @@ void gl_update_color_material( GLcontext *ctx, SUB_3V( tmp, color, mat->Specular ); foreach (light, list) { ACC_SCALE_3V( light->_MatSpecular[1], light->Specular, tmp ); - light->_IsMatSpecular[1] = + light->_IsMatSpecular[1] = (LEN_SQUARED_3FV(light->_MatSpecular[1]) > 1e-16); } COPY_4FV( mat->Specular, color ); @@ -815,8 +815,8 @@ _mesa_ColorMaterial( GLenum face, GLenum mode ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorMaterial"); - if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glColorMaterial %s %s\n", + if (MESA_VERBOSE&VERBOSE_API) + fprintf(stderr, "glColorMaterial %s %s\n", gl_lookup_enum_by_nr(face), gl_lookup_enum_by_nr(mode)); @@ -1002,7 +1002,7 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) * orientation of the facet is later learned, we can determine which * color (or index) to use for rendering. * - * KW: We now know orientation in advance and only shade for + * KW: We now know orientation in advance and only shade for * the side or sides which are actually required. * * Variables: @@ -1016,7 +1016,7 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) * // light at infinity * IF local_viewer THEN * _VP_inf_norm = unit vector from V to P // Precompute - * ELSE + * ELSE * // eye at infinity * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute * ENDIF @@ -1084,7 +1084,7 @@ compute_shine_table( struct gl_shine_tab *tab, GLfloat shininess ) m[i] = t; else m[i] = 0.0; - } + } m[SHINE_TABLE_SIZE] = 1.0; } @@ -1099,12 +1099,12 @@ gl_compute_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess ) struct gl_shine_tab *list = ctx->_ShineTabList; struct gl_shine_tab *s; - foreach(s, list) - if ( DISTSQR(s->shininess, shininess) < 1e-4 ) + foreach(s, list) + if ( DISTSQR(s->shininess, shininess) < 1e-4 ) break; if (s == list) { - foreach(s, list) + foreach(s, list) if (s->refcount == 0) break; @@ -1135,8 +1135,8 @@ gl_update_lighting( GLcontext *ctx ) ctx->_NeedEyeCoords &= ~NEED_EYE_LIGHT; ctx->_NeedNormals &= ~NEED_NORMALS_LIGHT; ctx->Light._Flags = 0; - - if (!ctx->Light.Enabled) + + if (!ctx->Light.Enabled) return; ctx->_NeedNormals |= NEED_NORMALS_LIGHT; @@ -1148,23 +1148,23 @@ gl_update_lighting( GLcontext *ctx ) ctx->Light._Flags |= light->_Flags; } - ctx->Light._NeedVertices = + ctx->Light._NeedVertices = ((ctx->Light._Flags & (LIGHT_POSITIONAL|LIGHT_SPOT)) || ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR || ctx->Light.Model.LocalViewer); - - if ((ctx->Light._Flags & LIGHT_POSITIONAL) || - ctx->Light.Model.LocalViewer) + + if ((ctx->Light._Flags & LIGHT_POSITIONAL) || + ctx->Light.Model.LocalViewer) ctx->_NeedEyeCoords |= NEED_EYE_LIGHT; - - + + /* XXX: This test is overkill & needs to be fixed both for software and * hardware t&l drivers. The above should be sufficient & should - * be tested to verify this. + * be tested to verify this. */ if (ctx->Light._NeedVertices) ctx->_NeedEyeCoords |= NEED_EYE_LIGHT; - + /* Precompute some shading values. */ @@ -1175,26 +1175,26 @@ gl_update_lighting( GLcontext *ctx ) struct gl_material *mat = &ctx->Light.Material[side]; COPY_3V(ctx->Light._BaseColor[side], mat->Emission); - ACC_SCALE_3V(ctx->Light._BaseColor[side], + ACC_SCALE_3V(ctx->Light._BaseColor[side], ctx->Light.Model.Ambient, mat->Ambient); FLOAT_COLOR_TO_CHAN(ctx->Light._BaseAlpha[side], ctx->Light.Material[side].Diffuse[3] ); } - - foreach (light, &ctx->Light.EnabledList) { + + foreach (light, &ctx->Light.EnabledList) { for (side=0; side< sides; side++) { const struct gl_material *mat = &ctx->Light.Material[side]; SCALE_3V( light->_MatDiffuse[side], light->Diffuse, mat->Diffuse ); SCALE_3V( light->_MatAmbient[side], light->Ambient, mat->Ambient ); SCALE_3V( light->_MatSpecular[side], light->Specular, mat->Specular); - light->_IsMatSpecular[side] = + light->_IsMatSpecular[side] = (LEN_SQUARED_3FV(light->_MatSpecular[side]) > 1e-16); } } - } + } else { static const GLfloat ci[3] = { .30, .59, .11 }; foreach(light, &ctx->Light.EnabledList) { @@ -1227,14 +1227,14 @@ gl_compute_light_positions( GLcontext *ctx ) else { TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelView.m ); } - + foreach (light, &ctx->Light.EnabledList) { if (ctx->_NeedEyeCoords) { COPY_4FV( light->_Position, light->EyePosition ); } else { - TRANSFORM_POINT( light->_Position, ctx->ModelView.inv, + TRANSFORM_POINT( light->_Position, ctx->ModelView.inv, light->EyePosition ); } @@ -1250,13 +1250,13 @@ gl_compute_light_positions( GLcontext *ctx ) } light->_VP_inf_spot_attenuation = 1.0; } - + if (light->_Flags & LIGHT_SPOT) { if (ctx->_NeedEyeCoords) { COPY_3V( light->_NormDirection, light->EyeDirection ); } else { - TRANSFORM_NORMAL( light->_NormDirection, + TRANSFORM_NORMAL( light->_NormDirection, light->EyeDirection, ctx->ModelView.m); } @@ -1264,14 +1264,14 @@ gl_compute_light_positions( GLcontext *ctx ) NORMALIZE_3FV( light->_NormDirection ); if (!(light->_Flags & LIGHT_POSITIONAL)) { - GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm, + GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm, light->_NormDirection); if (PV_dot_dir > light->_CosCutoff) { double x = PV_dot_dir * (EXP_TABLE_SIZE-1); int k = (int) x; - light->_VP_inf_spot_attenuation = - (light->_SpotExpTable[k][0] + + light->_VP_inf_spot_attenuation = + (light->_SpotExpTable[k][0] + (x-k)*light->_SpotExpTable[k][1]); } else { |