Home | History | Annotate | Download | only in main

Lines Matching refs:ctx

41    GET_CURRENT_CONTEXT(ctx);
42 ASSERT_OUTSIDE_BEGIN_END(ctx);
45 _mesa_debug(ctx, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode));
48 _mesa_error(ctx, GL_INVALID_ENUM, "glShadeModel");
52 if (ctx->Light.ShadeModel == mode)
55 FLUSH_VERTICES(ctx, _NEW_LIGHT);
56 ctx->Light.ShadeModel = mode;
58 if (ctx->Driver.ShadeModel)
59 ctx->Driver.ShadeModel( ctx, mode );
71 GET_CURRENT_CONTEXT(ctx);
72 ASSERT_OUTSIDE_BEGIN_END(ctx);
75 _mesa_debug(ctx, "glProvokingVertexEXT 0x%x\n", mode);
82 _mesa_error(ctx, GL_INVALID_ENUM, "glProvokingVertexEXT(0x%x)", mode);
86 if (ctx->Light.ProvokingVertex == mode)
89 FLUSH_VERTICES(ctx, _NEW_LIGHT);
90 ctx->Light.ProvokingVertex = mode;
102 _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *params)
107 light = &ctx->Light.Light[lnum];
113 FLUSH_VERTICES(ctx, _NEW_LIGHT);
119 FLUSH_VERTICES(ctx, _NEW_LIGHT);
125 FLUSH_VERTICES(ctx, _NEW_LIGHT);
132 FLUSH_VERTICES(ctx, _NEW_LIGHT);
143 FLUSH_VERTICES(ctx, _NEW_LIGHT);
148 ASSERT(params[0] <= ctx->Const.MaxSpotExponent);
151 FLUSH_VERTICES(ctx, _NEW_LIGHT);
158 FLUSH_VERTICES(ctx, _NEW_LIGHT);
172 FLUSH_VERTICES(ctx, _NEW_LIGHT);
179 FLUSH_VERTICES(ctx, _NEW_LIGHT);
186 FLUSH_VERTICES(ctx, _NEW_LIGHT);
190 _mesa_problem(ctx, "Unexpected pname in _mesa_light()");
194 if (ctx->Driver.Lightfv)
195 ctx->Driver.Lightfv( ctx, GL_LIGHT0 + lnum, pname, params );
212 GET_CURRENT_CONTEXT(ctx);
215 ASSERT_OUTSIDE_BEGIN_END(ctx);
217 if (i < 0 || i >= (GLint) ctx->Const.MaxLights) {
218 _mesa_error( ctx, GL_INVALID_ENUM, "glLight(light=0x%x)", light );
231 TRANSFORM_POINT(temp, ctx->ModelviewMatrixStack.Top->m, params);
236 if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
237 _math_matrix_analyse(ctx->ModelviewMatrixStack.Top);
239 TRANSFORM_DIRECTION(temp, params, ctx->ModelviewMatrixStack.Top->m);
243 if (params[0] < 0.0 || params[0] > ctx->Const.MaxSpotExponent) {
244 _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
250 _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
256 _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
262 _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
268 _mesa_error(ctx, GL_INVALID_VALUE, "glLight");
273 _mesa_error(ctx, GL_INVALID_ENUM, "glLight(pname=0x%x)", pname);
277 _mesa_light(ctx, i, pname, params);
336 GET_CURRENT_CONTEXT(ctx);
338 ASSERT_OUTSIDE_BEGIN_END(ctx);
340 if (l < 0 || l >= (GLint) ctx->Const.MaxLights) {
341 _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" );
347 COPY_4V( params, ctx->Light.Light[l].Ambient );
350 COPY_4V( params, ctx->Light.Light[l].Diffuse );
353 COPY_4V( params, ctx->Light.Light[l].Specular );
356 COPY_4V( params, ctx->Light.Light[l].EyePosition );
359 COPY_3V( params, ctx->Light.Light[l].SpotDirection );
362 params[0] = ctx->Light.Light[l].SpotExponent;
365 params[0] = ctx->Light.Light[l].SpotCutoff;
368 params[0] = ctx->Light.Light[l].ConstantAttenuation;
371 params[0] = ctx->Light.Light[l].LinearAttenuation;
374 params[0] = ctx->Light.Light[l].QuadraticAttenuation;
377 _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" );
386 GET_CURRENT_CONTEXT(ctx);
388 ASSERT_OUTSIDE_BEGIN_END(ctx);
390 if (l < 0 || l >= (GLint) ctx->Const.MaxLights) {
391 _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" );
397 params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[0]);
398 params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[1]);
399 params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[2]);
400 params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[3]);
403 params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[0]);
404 params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[1]);
405 params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[2]);
406 params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[3]);
409 params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[0]);
410 params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[1]);
411 params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[2]);
412 params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[3]);
415 params[0] = (GLint) ctx->Light.Light[l].EyePosition[0];
416 params[1] = (GLint) ctx->Light.Light[l].EyePosition[1];
417 params[2] = (GLint) ctx->Light.Light[l].EyePosition[2];
418 params[3] = (GLint) ctx->Light.Light[l].EyePosition[3];
421 params[0] = (GLint) ctx->Light.Light[l].SpotDirection[0];
422 params[1] = (GLint) ctx->Light.Light[l].SpotDirection[1];
423 params[2] = (GLint) ctx->Light.Light[l].SpotDirection[2];
426 params[0] = (GLint) ctx->Light.Light[l].SpotExponent;
429 params[0] = (GLint) ctx->Light.Light[l].SpotCutoff;
432 params[0] = (GLint) ctx->Light.Light[l].ConstantAttenuation;
435 params[0] = (GLint) ctx->Light.Light[l].LinearAttenuation;
438 params[0] = (GLint) ctx->Light.Light[l].QuadraticAttenuation;
441 _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" );
458 GET_CURRENT_CONTEXT(ctx);
459 ASSERT_OUTSIDE_BEGIN_END(ctx);
463 if (TEST_EQ_4V( ctx->Light.Model.Ambient, params ))
465 FLUSH_VERTICES(ctx, _NEW_LIGHT);
466 COPY_4V( ctx->Light.Model.Ambient, params );
469 if (ctx->API != API_OPENGL)
472 if (ctx->Light.Model.LocalViewer == newbool)
474 FLUSH_VERTICES(ctx, _NEW_LIGHT);
475 ctx->Light.Model.LocalViewer = newbool;
479 if (ctx->Light.Model.TwoSide == newbool)
481 FLUSH_VERTICES(ctx, _NEW_LIGHT);
482 ctx->Light.Model.TwoSide = newbool;
483 if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
484 ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
486 ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
489 if (ctx->API != API_OPENGL)
496 _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(param=0x0%x)",
500 if (ctx->Light.Model.ColorControl == newenum)
502 FLUSH_VERTICES(ctx, _NEW_LIGHT);
503 ctx->Light.Model.ColorControl = newenum;
509 if (ctx->Driver.LightModelfv)
510 ctx->Driver.LightModelfv( ctx, pname, params );
515 _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname );
574 _mesa_material_bitmask( struct gl_context *ctx, GLenum face, GLenum pname,
604 _mesa_error( ctx, GL_INVALID_ENUM, "%s", where );
615 _mesa_error( ctx, GL_INVALID_ENUM, "%s", where );
620 _mesa_error( ctx, GL_INVALID_ENUM, "%s", where );
629 /* Update derived values following a change in ctx->Light.Material
632 _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
634 struct gl_light *light, *list = &ctx->Light.EnabledList;
635 GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
638 _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask);
660 COPY_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_EMISSION] );
661 ACC_SCALE_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_AMBIENT],
662 ctx->Light.Model.Ambient );
666 COPY_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_EMISSION] );
667 ACC_SCALE_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_AMBIENT],
668 ctx->Light.Model.Ambient );
709 _mesa_update_color_material( struct gl_context *ctx, const GLfloat color[4] )
711 const GLbitfield bitmask = ctx->Light._ColorMaterialBitmask;
712 struct gl_material *mat = &ctx->Light.Material;
719 _mesa_update_material( ctx, bitmask );
726 GET_CURRENT_CONTEXT(ctx);
732 ASSERT_OUTSIDE_BEGIN_END(ctx);
735 _mesa_debug(ctx, "glColorMaterial %s %s\n",
739 bitmask = _mesa_material_bitmask(ctx, face, mode, legal, "glColorMaterial");
743 if (ctx->Light._ColorMaterialBitmask == bitmask &&
744 ctx->Light.ColorMaterialFace == face &&
745 ctx->Light.ColorMaterialMode == mode)
748 FLUSH_VERTICES(ctx, _NEW_LIGHT);
749 ctx->Light._ColorMaterialBitmask = bitmask;
750 ctx->Light.ColorMaterialFace = face;
751 ctx->Light.ColorMaterialMode = mode;
753 if (ctx->Light.ColorMaterialEnabled) {
754 FLUSH_CURRENT( ctx, 0 );
755 _mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
758 if (ctx->Driver.ColorMaterial)
759 ctx->Driver.ColorMaterial( ctx, face, mode );
766 GET_CURRENT_CONTEXT(ctx);
768 GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
769 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
771 FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
780 _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" );
801 if (ctx->API != API_OPENGL) {
802 _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
810 _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
818 GET_CURRENT_CONTEXT(ctx);
820 GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
821 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
823 ASSERT(ctx->API == API_OPENGL);
825 FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
834 _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" );
871 _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
884 _mesa_update_lighting( struct gl_context *ctx )
888 ctx->Light._NeedEyeCoords = GL_FALSE;
890 if (!ctx->Light.Enabled)
893 foreach(light, &ctx->Light.EnabledList) {
897 ctx->Light._NeedVertices =
899 ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
900 ctx->Light.Model.LocalViewer);
902 ctx->Light._NeedEyeCoords = ((flags & LIGHT_POSITIONAL) ||
903 ctx->Light.Model.LocalViewer);
909 if (ctx->Light._NeedVertices)
910 ctx->Light._NeedEyeCoords = GL_TRUE;
917 if (ctx->Light.Model.TwoSide)
918 _mesa_update_material(ctx,
928 _mesa_update_material(ctx,
947 compute_light_positions( struct gl_context *ctx )
952 if (!ctx->Light.Enabled)
955 if (ctx->_NeedEyeCoords) {
956 COPY_3V( ctx->_EyeZDir, eye_z );
959 TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelviewMatrixStack.Top->m );
962 foreach (light, &ctx->Light.EnabledList) {
964 if (ctx->_NeedEyeCoords) {
970 TRANSFORM_POINT( light->_Position, ctx->ModelviewMatrixStack.Top->inv,
979 if (!ctx->Light.Model.LocalViewer) {
981 ADD_3V( light->_h_inf_norm, light->_VP_inf_norm, ctx->_EyeZDir);
997 if (ctx->_NeedEyeCoords) {
1007 ctx->ModelviewMatrixStack.Top->m);
1031 update_modelview_scale( struct gl_context *ctx )
1033 ctx->_ModelViewInvScale = 1.0F;
1034 if (!_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) {
1035 const GLfloat *m = ctx->ModelviewMatrixStack.Top->inv;
1038 if (ctx->_NeedEyeCoords)
1039 ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f);
1041 ctx->_ModelViewInvScale = (GLfloat) SQRTF(f);
1050 _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state )
1052 const GLuint oldneedeyecoords = ctx->_NeedEyeCoords;
1055 ctx->_NeedEyeCoords = GL_FALSE;
1057 if (ctx->_ForceEyeCoords ||
1058 (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) ||
1059 ctx->Point._Attenuated ||
1060 ctx->Light._NeedEyeCoords)
1061 ctx->_NeedEyeCoords = GL_TRUE;
1063 if (ctx->Light.Enabled &&
1064 !_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top))
1065 ctx->_NeedEyeCoords = GL_TRUE;
1070 if (oldneedeyecoords != ctx->_NeedEyeCoords) {
1073 update_modelview_scale(ctx);
1074 compute_light_positions( ctx );
1076 if (ctx->Driver.LightingSpaceChange)
1077 ctx->Driver.LightingSpaceChange( ctx );
1080 GLuint new_state2 = ctx->NewState;
1086 update_modelview_scale(ctx);
1089 compute_light_positions( ctx );
1099 _mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag )
1101 ctx->_ForceEyeCoords = !flag;
1102 ctx->NewState |= _NEW_POINT; /* one of the bits from
1189 _mesa_init_lighting( struct gl_context *ctx )
1195 init_light( &ctx->Light.Light[i], i );
1197 make_empty_list( &ctx->Light.EnabledList );
1199 init_lightmodel( &ctx->Light.Model );
1200 init_material( &ctx->Light.Material );
1201 ctx->Light.ShadeModel = GL_SMOOTH;
1202 ctx->Light.ProvokingVertex = GL_LAST_VERTEX_CONVENTION_EXT;
1203 ctx->Light.Enabled = GL_FALSE;
1204 ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK;
1205 ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE;
1206 ctx->Light._ColorMaterialBitmask = _mesa_material_bitmask( ctx,
1211 ctx->Light.ColorMaterialEnabled = GL_FALSE;
1212 ctx->Light.ClampVertexColor = GL_TRUE;
1215 ctx->Light._NeedEyeCoords = GL_FALSE;
1216 ctx->_NeedEyeCoords = GL_FALSE;
1217 ctx->_ForceEyeCoords = GL_FALSE;
1218 ctx->_ModelViewInvScale = 1.0;
1226 _mesa_free_lighting_data( struct gl_context *ctx )