Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygent_dd_imm_napi.h
Go to the documentation of this file.
00001 00002 /* 00003 * Mesa 3-D graphics library 00004 * Version: 3.5 00005 * 00006 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining a 00009 * copy of this software and associated documentation files (the "Software"), 00010 * to deal in the Software without restriction, including without limitation 00011 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00012 * and/or sell copies of the Software, and to permit persons to whom the 00013 * Software is furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be included 00016 * in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00019 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00021 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00022 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00023 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 * 00025 * Authors: 00026 * Gareth Hughes <gareth@valinux.com> 00027 * Keith Whitwell <keith_whitwell@yahoo.com> 00028 */ 00029 00030 /* Template for immediate mode normal functions. Optimize for infinite 00031 * lights when doing software lighting. 00032 */ 00033 00034 static void TAG(Normal3f_single)( GLfloat x, GLfloat y, GLfloat z ) 00035 { 00036 GET_CURRENT_VERTEX; 00037 const struct gl_light *light = ctx->Light.EnabledList.prev; 00038 GLfloat n_dot_h, n_dot_VP, spec, sum[3]; 00039 GLfloat *normal = ctx->Current.Normal; 00040 GLfloat scale = 1.0; 00041 00042 ASSIGN_3V( normal, x, y, z ); 00043 COPY_3V( sum, BASE_COLOR ); 00044 00045 if ( IND & NORM_RESCALE ) { 00046 scale = ctx->_ModelViewInvScale; 00047 } else if ( IND & NORM_NORMALIZE ) { 00048 scale = LEN_3FV( normal ); 00049 if ( scale != 0.0 ) scale = 1.0 / scale; 00050 } 00051 00052 n_dot_VP = DOT3( normal, light->_VP_inf_norm ) * scale; 00053 if ( n_dot_VP > 0.0F ) { 00054 ACC_SCALE_SCALAR_3V( sum, n_dot_VP, light->_MatDiffuse[0] ); 00055 n_dot_h = DOT3( normal, light->_h_inf_norm ) * scale; 00056 if ( n_dot_h > 0.0F ) { 00057 GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec ); 00058 ACC_SCALE_SCALAR_3V( sum, spec, light->_MatSpecular[0] ); 00059 } 00060 } 00061 00062 #ifdef LIT_COLOR_IS_FLOAT 00063 LIT_COLOR ( RCOMP ) = CLAMP(sum[0], 0.0f, 0.1f); 00064 LIT_COLOR ( GCOMP ) = CLAMP(sum[1], 0.0f, 0.1f); 00065 LIT_COLOR ( BCOMP ) = CLAMP(sum[2], 0.0f, 0.1f); 00066 #else 00067 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( RCOMP ), sum[0] ); 00068 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( GCOMP ), sum[1] ); 00069 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( BCOMP ), sum[2] ); 00070 #endif 00071 LIT_COLOR( ACOMP ) = LIT_ALPHA; 00072 } 00073 00074 static void TAG(Normal3fv_single)( const GLfloat *normal ) 00075 { 00076 GET_CURRENT_VERTEX; 00077 const struct gl_light *light = ctx->Light.EnabledList.prev; 00078 GLfloat n_dot_h, n_dot_VP, spec, sum[3]; 00079 GLfloat scale = 1.0; 00080 00081 COPY_3V( ctx->Current.Normal, normal ); 00082 COPY_3V( sum, BASE_COLOR ); 00083 00084 if ( IND & NORM_RESCALE ) { 00085 scale = ctx->_ModelViewInvScale; 00086 } else if ( IND & NORM_NORMALIZE ) { 00087 scale = LEN_3FV( normal ); 00088 if ( scale != 0.0 ) scale = 1.0 / scale; 00089 } 00090 00091 n_dot_VP = DOT3( normal, light->_VP_inf_norm ) * scale; 00092 if ( n_dot_VP > 0.0F ) { 00093 ACC_SCALE_SCALAR_3V( sum, n_dot_VP, light->_MatDiffuse[0] ); 00094 n_dot_h = DOT3( normal, light->_h_inf_norm ) * scale; 00095 if ( n_dot_h > 0.0F ) { 00096 GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec ); 00097 ACC_SCALE_SCALAR_3V( sum, spec, light->_MatSpecular[0] ); 00098 } 00099 } 00100 00101 #ifdef LIT_COLOR_IS_FLOAT 00102 LIT_COLOR ( RCOMP ) = CLAMP(sum[0], 0.0f, 0.1f); 00103 LIT_COLOR ( GCOMP ) = CLAMP(sum[1], 0.0f, 0.1f); 00104 LIT_COLOR ( BCOMP ) = CLAMP(sum[2], 0.0f, 0.1f); 00105 #else 00106 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( RCOMP ), sum[0] ); 00107 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( GCOMP ), sum[1] ); 00108 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( BCOMP ), sum[2] ); 00109 #endif 00110 LIT_COLOR( ACOMP ) = LIT_ALPHA; 00111 } 00112 00113 00114 static void TAG(Normal3f_multi)( GLfloat x, GLfloat y, GLfloat z ) 00115 { 00116 GET_CURRENT_VERTEX; 00117 struct gl_light *light; 00118 GLfloat n_dot_h, n_dot_VP, spec, sum[3], tmp[3]; 00119 GLfloat *normal; 00120 00121 ASSIGN_3V( ctx->Current.Normal, x, y, z ); 00122 COPY_3V( sum, BASE_COLOR ); 00123 00124 if ( IND & NORM_RESCALE ) { 00125 normal = tmp; 00126 ASSIGN_3V( normal, x, y, z ); 00127 SELF_SCALE_SCALAR_3V( normal, ctx->_ModelViewInvScale ); 00128 } else if ( IND & NORM_NORMALIZE ) { 00129 normal = tmp; 00130 ASSIGN_3V( normal, x, y, z ); 00131 NORMALIZE_3FV( normal ); 00132 } else { 00133 normal = ctx->Current.Normal; 00134 } 00135 00136 foreach ( light, &ctx->Light.EnabledList ) { 00137 n_dot_VP = DOT3( normal, light->_VP_inf_norm ); 00138 if ( n_dot_VP > 0.0F ) { 00139 ACC_SCALE_SCALAR_3V( sum, n_dot_VP, light->_MatDiffuse[0] ); 00140 n_dot_h = DOT3( normal, light->_h_inf_norm ); 00141 if ( n_dot_h > 0.0F ) { 00142 GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec ); 00143 ACC_SCALE_SCALAR_3V( sum, spec, light->_MatSpecular[0] ); 00144 } 00145 } 00146 } 00147 00148 #ifdef LIT_COLOR_IS_FLOAT 00149 LIT_COLOR ( RCOMP ) = CLAMP(sum[0], 0.0f, 0.1f); 00150 LIT_COLOR ( GCOMP ) = CLAMP(sum[1], 0.0f, 0.1f); 00151 LIT_COLOR ( BCOMP ) = CLAMP(sum[2], 0.0f, 0.1f); 00152 #else 00153 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( RCOMP ), sum[0] ); 00154 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( GCOMP ), sum[1] ); 00155 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( BCOMP ), sum[2] ); 00156 #endif 00157 LIT_COLOR( ACOMP ) = LIT_ALPHA; 00158 } 00159 00160 static void TAG(Normal3fv_multi)( const GLfloat *n ) 00161 { 00162 GET_CURRENT_VERTEX; 00163 struct gl_light *light; 00164 GLfloat n_dot_h, n_dot_VP, spec, sum[3], tmp[3]; 00165 GLfloat *normal; 00166 00167 COPY_3V( ctx->Current.Normal, n ); 00168 COPY_3V( sum, BASE_COLOR ); 00169 00170 if ( IND & NORM_RESCALE ) { 00171 normal = tmp; 00172 COPY_3V( normal, n ); 00173 SELF_SCALE_SCALAR_3V( normal, ctx->_ModelViewInvScale ); 00174 } else if ( IND & NORM_NORMALIZE ) { 00175 normal = tmp; 00176 COPY_3V( normal, n ); 00177 NORMALIZE_3FV( normal ); 00178 } else { 00179 normal = ctx->Current.Normal; 00180 } 00181 00182 foreach ( light, &ctx->Light.EnabledList ) { 00183 n_dot_VP = DOT3( normal, light->_VP_inf_norm ); 00184 if ( n_dot_VP > 0.0F ) { 00185 ACC_SCALE_SCALAR_3V( sum, n_dot_VP, light->_MatDiffuse[0] ); 00186 n_dot_h = DOT3( normal, light->_h_inf_norm ); 00187 if ( n_dot_h > 0.0F ) { 00188 GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec ); 00189 ACC_SCALE_SCALAR_3V( sum, spec, light->_MatSpecular[0] ); 00190 } 00191 } 00192 } 00193 00194 #ifdef LIT_COLOR_IS_FLOAT 00195 LIT_COLOR ( RCOMP ) = CLAMP(sum[0], 0.0f, 0.1f); 00196 LIT_COLOR ( GCOMP ) = CLAMP(sum[1], 0.0f, 0.1f); 00197 LIT_COLOR ( BCOMP ) = CLAMP(sum[2], 0.0f, 0.1f); 00198 #else 00199 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( RCOMP ), sum[0] ); 00200 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( GCOMP ), sum[1] ); 00201 UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( BCOMP ), sum[2] ); 00202 #endif 00203 LIT_COLOR( ACOMP ) = LIT_ALPHA; 00204 } 00205 00206 00207 00208 static void TAG(init_norm)( void ) 00209 { 00210 norm_tab[IND].normal3f_single = TAG(Normal3f_single); 00211 norm_tab[IND].normal3fv_single = TAG(Normal3fv_single); 00212 norm_tab[IND].normal3f_multi = TAG(Normal3f_multi); 00213 norm_tab[IND].normal3fv_multi = TAG(Normal3fv_multi); 00214 } 00215 00216 00217 00218 #ifndef PRESERVE_NORMAL_DEFS 00219 #undef GET_CURRENT 00220 #undef GET_CURRENT_VERTEX 00221 #undef LIT_COLOR 00222 #undef LIT_COLOR_IS_FLOAT 00223 #endif 00224 #undef PRESERVE_NORMAL_DEFS 00225 #undef IND 00226 #undef TAG Generated on Sun May 27 2012 04:20:46 for ReactOS by
1.7.6.1
|