light.h revision 4a49301e
17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 34a49301eSmrg * Version: 7.5 47117f1b4Smrg * 54a49301eSmrg * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 64a49301eSmrg * Copyright (C) 2009 VMware, Inc. All Rights Reserved. 77117f1b4Smrg * 87117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 97117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 107117f1b4Smrg * to deal in the Software without restriction, including without limitation 117117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 127117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 137117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 147117f1b4Smrg * 157117f1b4Smrg * The above copyright notice and this permission notice shall be included 167117f1b4Smrg * in all copies or substantial portions of the Software. 177117f1b4Smrg * 187117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 197117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 207117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 217117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 227117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 237117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 247117f1b4Smrg */ 257117f1b4Smrg 267117f1b4Smrg 277117f1b4Smrg#ifndef LIGHT_H 287117f1b4Smrg#define LIGHT_H 297117f1b4Smrg 307117f1b4Smrg 317117f1b4Smrg#include "mtypes.h" 327117f1b4Smrg 337117f1b4Smrgextern void GLAPIENTRY 347117f1b4Smrg_mesa_ShadeModel( GLenum mode ); 357117f1b4Smrg 364a49301eSmrgextern void GLAPIENTRY 374a49301eSmrg_mesa_ProvokingVertexEXT(GLenum mode); 384a49301eSmrg 394a49301eSmrg 407117f1b4Smrg#if _HAVE_FULL_GL 417117f1b4Smrgextern void GLAPIENTRY 427117f1b4Smrg_mesa_ColorMaterial( GLenum face, GLenum mode ); 437117f1b4Smrg 447117f1b4Smrgextern void GLAPIENTRY 457117f1b4Smrg_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ); 467117f1b4Smrg 477117f1b4Smrgextern void GLAPIENTRY 487117f1b4Smrg_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ); 497117f1b4Smrg 507117f1b4Smrgextern void GLAPIENTRY 517117f1b4Smrg_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ); 527117f1b4Smrg 537117f1b4Smrgextern void GLAPIENTRY 547117f1b4Smrg_mesa_Lighti( GLenum light, GLenum pname, GLint param ); 557117f1b4Smrg 567117f1b4Smrgextern void GLAPIENTRY 577117f1b4Smrg_mesa_LightModelf( GLenum pname, GLfloat param ); 587117f1b4Smrg 597117f1b4Smrgextern void GLAPIENTRY 607117f1b4Smrg_mesa_LightModelfv( GLenum pname, const GLfloat *params ); 617117f1b4Smrg 627117f1b4Smrgextern void GLAPIENTRY 637117f1b4Smrg_mesa_LightModeli( GLenum pname, GLint param ); 647117f1b4Smrg 657117f1b4Smrgextern void GLAPIENTRY 667117f1b4Smrg_mesa_LightModeliv( GLenum pname, const GLint *params ); 677117f1b4Smrg 687117f1b4Smrgextern void GLAPIENTRY 697117f1b4Smrg_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ); 707117f1b4Smrg 717117f1b4Smrgextern void GLAPIENTRY 727117f1b4Smrg_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ); 737117f1b4Smrg 747117f1b4Smrgextern void GLAPIENTRY 757117f1b4Smrg_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); 767117f1b4Smrg 777117f1b4Smrgextern void GLAPIENTRY 787117f1b4Smrg_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ); 797117f1b4Smrg 807117f1b4Smrg 817117f1b4Smrgextern void 827117f1b4Smrg_mesa_light(GLcontext *ctx, GLuint lnum, GLenum pname, const GLfloat *params); 837117f1b4Smrg 847117f1b4Smrg 857117f1b4Smrg/* Lerp between adjacent values in the f(x) lookup table, giving a 867117f1b4Smrg * continuous function, with adequeate overall accuracy. (Though 877117f1b4Smrg * still pretty good compared to a straight lookup). 887117f1b4Smrg * Result should be a GLfloat. 897117f1b4Smrg */ 907117f1b4Smrg#define GET_SHINE_TAB_ENTRY( table, dp, result ) \ 917117f1b4Smrgdo { \ 927117f1b4Smrg struct gl_shine_tab *_tab = table; \ 937117f1b4Smrg float f = (dp * (SHINE_TABLE_SIZE-1)); \ 947117f1b4Smrg int k = (int) f; \ 957117f1b4Smrg if (k < 0 /* gcc may cast an overflow float value to negative int value*/ \ 967117f1b4Smrg || k > SHINE_TABLE_SIZE-2) \ 977117f1b4Smrg result = (GLfloat) _mesa_pow( dp, _tab->shininess ); \ 987117f1b4Smrg else \ 997117f1b4Smrg result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \ 1007117f1b4Smrg} while (0) 1017117f1b4Smrg 1027117f1b4Smrg 1037117f1b4Smrgextern GLuint _mesa_material_bitmask( GLcontext *ctx, 1047117f1b4Smrg GLenum face, GLenum pname, 1057117f1b4Smrg GLuint legal, 1067117f1b4Smrg const char * ); 1077117f1b4Smrg 1087117f1b4Smrgextern void _mesa_invalidate_spot_exp_table( struct gl_light *l ); 1097117f1b4Smrg 1107117f1b4Smrgextern void _mesa_invalidate_shine_table( GLcontext *ctx, GLuint i ); 1117117f1b4Smrg 1127117f1b4Smrgextern void _mesa_validate_all_lighting_tables( GLcontext *ctx ); 1137117f1b4Smrg 1147117f1b4Smrgextern void _mesa_update_lighting( GLcontext *ctx ); 1157117f1b4Smrg 1167117f1b4Smrgextern void _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state ); 1177117f1b4Smrg 1187117f1b4Smrgextern void _mesa_update_material( GLcontext *ctx, 1197117f1b4Smrg GLuint bitmask ); 1207117f1b4Smrg 1217117f1b4Smrgextern void _mesa_copy_materials( struct gl_material *dst, 1227117f1b4Smrg const struct gl_material *src, 1237117f1b4Smrg GLuint bitmask ); 1247117f1b4Smrg 1257117f1b4Smrgextern void _mesa_update_color_material( GLcontext *ctx, 1267117f1b4Smrg const GLfloat rgba[4] ); 1277117f1b4Smrg 1287117f1b4Smrgextern void _mesa_init_lighting( GLcontext *ctx ); 1297117f1b4Smrg 1307117f1b4Smrgextern void _mesa_free_lighting_data( GLcontext *ctx ); 1317117f1b4Smrg 1327117f1b4Smrgextern void _mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag ); 1337117f1b4Smrg 1347117f1b4Smrg#else 1357117f1b4Smrg#define _mesa_update_color_material( c, r ) ((void)0) 1367117f1b4Smrg#define _mesa_validate_all_lighting_tables( c ) ((void)0) 1377117f1b4Smrg#define _mesa_invalidate_spot_exp_table( l ) ((void)0) 1387117f1b4Smrg#define _mesa_material_bitmask( c, f, p, l, s ) 0 1397117f1b4Smrg#define _mesa_init_lighting( c ) ((void)0) 1407117f1b4Smrg#define _mesa_free_lighting_data( c ) ((void)0) 1417117f1b4Smrg#define _mesa_update_lighting( c ) ((void)0) 1427117f1b4Smrg#define _mesa_update_tnl_spaces( c, n ) ((void)0) 1437117f1b4Smrg#define GET_SHINE_TAB_ENTRY( table, dp, result ) ((result)=0) 1447117f1b4Smrg#endif 1457117f1b4Smrg 1467117f1b4Smrg#endif 147