Lines Matching refs:c
34 static void invalidate_lighting(ogles_context_t* c);
35 static void lightVertexValidate(ogles_context_t* c, vertex_t* v);
36 static void lightVertexNop(ogles_context_t* c, vertex_t* v);
37 static void lightVertex(ogles_context_t* c, vertex_t* v);
38 static void lightVertexMaterial(ogles_context_t* c, vertex_t* v);
54 static GLfixed fog_linear(ogles_context_t* c, GLfixed z);
55 static GLfixed fog_exp(ogles_context_t* c, GLfixed z);
56 static GLfixed fog_exp2(ogles_context_t* c, GLfixed z);
61 static void init_white(vec4_t& c) { in init_white() argument
62 c.r = c.g = c.b = c.a = 0x10000; in init_white()
65 void ogles_init_light(ogles_context_t* c) in ogles_init_light() argument
68 c->lighting.lights[i].ambient.a = 0x10000; in ogles_init_light()
69 c->lighting.lights[i].position.z = 0x10000; in ogles_init_light()
70 c->lighting.lights[i].spotDir.z = -0x10000; in ogles_init_light()
71 c->lighting.lights[i].spotCutoff = gglIntToFixed(180); in ogles_init_light()
72 c->lighting.lights[i].attenuation[0] = 0x10000; in ogles_init_light()
74 init_white(c->lighting.lights[0].diffuse); in ogles_init_light()
75 init_white(c->lighting.lights[0].specular); in ogles_init_light()
77 c->lighting.front.ambient.r = in ogles_init_light()
78 c->lighting.front.ambient.g = in ogles_init_light()
79 c->lighting.front.ambient.b = gglFloatToFixed(0.2f); in ogles_init_light()
80 c->lighting.front.ambient.a = 0x10000; in ogles_init_light()
81 c->lighting.front.diffuse.r = in ogles_init_light()
82 c->lighting.front.diffuse.g = in ogles_init_light()
83 c->lighting.front.diffuse.b = gglFloatToFixed(0.8f); in ogles_init_light()
84 c->lighting.front.diffuse.a = 0x10000; in ogles_init_light()
85 c->lighting.front.specular.a = 0x10000; in ogles_init_light()
86 c->lighting.front.emission.a = 0x10000; in ogles_init_light()
88 c->lighting.lightModel.ambient.r = in ogles_init_light()
89 c->lighting.lightModel.ambient.g = in ogles_init_light()
90 c->lighting.lightModel.ambient.b = gglFloatToFixed(0.2f); in ogles_init_light()
91 c->lighting.lightModel.ambient.a = 0x10000; in ogles_init_light()
93 c->lighting.colorMaterial.face = GL_FRONT_AND_BACK; in ogles_init_light()
94 c->lighting.colorMaterial.mode = GL_AMBIENT_AND_DIFFUSE; in ogles_init_light()
96 c->fog.mode = GL_EXP; in ogles_init_light()
97 c->fog.fog = fog_exp; in ogles_init_light()
98 c->fog.density = 0x10000; in ogles_init_light()
99 c->fog.end = 0x10000; in ogles_init_light()
100 c->fog.invEndMinusStart = 0x10000; in ogles_init_light()
102 invalidate_lighting(c); in ogles_init_light()
104 c->rasterizer.procs.shadeModel(c, GL_SMOOTH); in ogles_init_light()
105 c->lighting.shadeModel = GL_SMOOTH; in ogles_init_light()
108 void ogles_uninit_light(ogles_context_t* c) in ogles_uninit_light() argument
120 static GLfixed fog_linear(ogles_context_t* c, GLfixed z) { in fog_linear() argument
121 return clampF(gglMulx((c->fog.end - ((z<0)?-z:z)), c->fog.invEndMinusStart)); in fog_linear()
124 static GLfixed fog_exp(ogles_context_t* c, GLfixed z) { in fog_exp() argument
125 const float e = fixedToFloat(gglMulx(c->fog.density, ((z<0)?-z:z))); in fog_exp()
129 static GLfixed fog_exp2(ogles_context_t* c, GLfixed z) { in fog_exp2() argument
130 const float e = fixedToFloat(gglMulx(c->fog.density, z)); in fog_exp2()
203 static inline void light_picker(ogles_context_t* c) in light_picker() argument
205 if (ggl_likely(!c->lighting.enable)) { in light_picker()
206 c->lighting.lightVertex = lightVertexNop; in light_picker()
209 if (c->lighting.colorMaterial.enable) { in light_picker()
210 c->lighting.lightVertex = lightVertexMaterial; in light_picker()
212 c->lighting.lightVertex = lightVertex; in light_picker()
216 static inline void validate_light_mvi(ogles_context_t* c) in validate_light_mvi() argument
218 uint32_t en = c->lighting.enabledLights; in validate_light_mvi()
223 light_t& l = c->lighting.lights[i]; in validate_light_mvi()
225 c->transforms.mvui.point4(&c->transforms.mvui, in validate_light_mvi()
234 c->transforms.mvui.point3(&c->transforms.mvui, in validate_light_mvi()
235 &c->lighting.objViewer, &eyeViewer); in validate_light_mvi()
236 vnorm3(c->lighting.objViewer.v, c->lighting.objViewer.v); in validate_light_mvi()
238 c->lighting.objViewer = eyeViewer; in validate_light_mvi()
242 static inline void validate_light(ogles_context_t* c) in validate_light() argument
245 if (!c->lighting.colorMaterial.enable) { in validate_light()
246 material_t& material = c->lighting.front; in validate_light()
247 uint32_t en = c->lighting.enabledLights; in validate_light()
251 light_t& l = c->lighting.lights[i]; in validate_light()
267 vmla3( c->lighting.implicitSceneEmissionAndAmbient.v, in validate_light()
268 c->lighting.lightModel.ambient.v, in validate_light()
271 c->lighting.implicitSceneEmissionAndAmbient.a = material.diffuse.a; in validate_light()
273 validate_light_mvi(c); in validate_light()
276 void invalidate_lighting(ogles_context_t* c) in invalidate_lighting() argument
280 c->lighting.lightVertex = lightVertexValidate; in invalidate_lighting()
283 void ogles_invalidate_lighting_mvui(ogles_context_t* c) in ogles_invalidate_lighting_mvui() argument
285 invalidate_lighting(c); in ogles_invalidate_lighting_mvui()
293 void lightVertexValidateMVI(ogles_context_t* c, vertex_t* v) in lightVertexValidateMVI() argument
295 validate_light_mvi(c); in lightVertexValidateMVI()
296 light_picker(c); in lightVertexValidateMVI()
297 c->lighting.lightVertex(c, v); in lightVertexValidateMVI()
300 void lightVertexValidate(ogles_context_t* c, vertex_t* v) in lightVertexValidate() argument
302 validate_light(c); in lightVertexValidate()
303 light_picker(c); in lightVertexValidate()
304 c->lighting.lightVertex(c, v); in lightVertexValidate()
307 void lightVertexMaterial(ogles_context_t* c, vertex_t* v) in lightVertexMaterial() argument
310 const GLvoid* cp = c->arrays.color.element( in lightVertexMaterial()
312 c->arrays.color.fetch(c, v->color.v, cp); in lightVertexMaterial()
315 material_t& material = c->lighting.front; in lightVertexMaterial()
319 uint32_t en = c->lighting.enabledLights; in lightVertexMaterial()
323 light_t& l = c->lighting.lights[i]; in lightVertexMaterial()
334 vmla3( c->lighting.implicitSceneEmissionAndAmbient.v, in lightVertexMaterial()
335 c->lighting.lightModel.ambient.v, in lightVertexMaterial()
338 c->lighting.implicitSceneEmissionAndAmbient.a = material.diffuse.a; in lightVertexMaterial()
341 lightVertex(c, v); in lightVertexMaterial()
344 void lightVertex(ogles_context_t* c, vertex_t* v) in lightVertex() argument
347 vec4_t r = c->lighting.implicitSceneEmissionAndAmbient; in lightVertex()
348 const vec4_t objViewer = c->lighting.objViewer; in lightVertex()
350 uint32_t en = c->lighting.enabledLights; in lightVertex()
356 c->arrays.normal.fetch(c, n.v, in lightVertex()
357 c->arrays.normal.element(v->index & vertex_cache_t::INDEX_MASK)); in lightVertex()
360 c->transforms.mvui.point3(&c->transforms.mvui, &n, &n); in lightVertex()
366 if (c->transforms.rescaleNormals) in lightVertex()
369 const material_t& material = c->lighting.front; in lightVertex()
370 const int twoSide = c->lighting.lightModel.twoSide; in lightVertex()
375 const light_t& l = c->lighting.lights[i]; in lightVertex()
386 const transform_t& mv = c->transforms.modelview.transform; in lightVertex()
452 static void lightModelx(GLenum pname, GLfixed param, ogles_context_t* c) in lightModelx() argument
455 ogles_error(c, GL_INVALID_ENUM); in lightModelx()
458 c->lighting.lightModel.twoSide = param ? GL_TRUE : GL_FALSE; in lightModelx()
459 invalidate_lighting(c); in lightModelx()
462 static void lightx(GLenum i, GLenum pname, GLfixed param, ogles_context_t* c) in lightx() argument
465 ogles_error(c, GL_INVALID_ENUM); in lightx()
469 light_t& light = c->lighting.lights[i-GL_LIGHT0]; in lightx()
474 ogles_error(c, GL_INVALID_VALUE); in lightx()
481 ogles_error(c, GL_INVALID_VALUE); in lightx()
490 ogles_error(c, GL_INVALID_VALUE); in lightx()
497 ogles_error(c, GL_INVALID_VALUE); in lightx()
504 ogles_error(c, GL_INVALID_VALUE); in lightx()
510 ogles_error(c, GL_INVALID_ENUM); in lightx()
513 invalidate_lighting(c); in lightx()
516 static void lightxv(GLenum i, GLenum pname, const GLfixed *params, ogles_context_t* c) in lightxv() argument
519 ogles_error(c, GL_INVALID_ENUM); in lightxv()
524 light_t& light = c->lighting.lights[i-GL_LIGHT0]; in lightxv()
536 ogles_validate_transform(c, transform_state_t::MODELVIEW); in lightxv()
537 transform_t& mv = c->transforms.modelview.transform; in lightxv()
539 invalidate_lighting(c); in lightxv()
544 ogles_validate_transform(c, transform_state_t::MVUI); in lightxv()
545 transform_t& mvui = c->transforms.mvui; in lightxv()
551 invalidate_lighting(c); in lightxv()
555 lightx(i, pname, params[0], c); in lightxv()
562 invalidate_lighting(c); in lightxv()
565 static void materialx(GLenum face, GLenum pname, GLfixed param, ogles_context_t* c) in materialx() argument
568 ogles_error(c, GL_INVALID_ENUM); in materialx()
572 ogles_error(c, GL_INVALID_ENUM); in materialx()
575 c->lighting.front.shininess = param; in materialx()
576 invalidate_lighting(c); in materialx()
579 static void fogx(GLenum pname, GLfixed param, ogles_context_t* c) in fogx() argument
584 c->fog.density = param; in fogx()
587 ogles_error(c, GL_INVALID_VALUE); in fogx()
590 c->fog.start = param; in fogx()
591 c->fog.invEndMinusStart = gglRecip(c->fog.end - c->fog.start); in fogx()
594 c->fog.end = param; in fogx()
595 c->fog.invEndMinusStart = gglRecip(c->fog.end - c->fog.start); in fogx()
600 c->fog.mode = param; in fogx()
601 c->fog.fog = fog_linear; in fogx()
604 c->fog.mode = param; in fogx()
605 c->fog.fog = fog_exp; in fogx()
608 c->fog.mode = param; in fogx()
609 c->fog.fog = fog_exp2; in fogx()
612 ogles_error(c, GL_INVALID_ENUM); in fogx()
617 ogles_error(c, GL_INVALID_ENUM); in fogx()
635 ogles_context_t* c = ogles_context_t::get(); in glShadeModel() local
637 ogles_error(c, GL_INVALID_ENUM); in glShadeModel()
640 c->lighting.shadeModel = mode; in glShadeModel()
645 ogles_context_t* c = ogles_context_t::get(); in glLightModelf() local
646 lightModelx(pname, gglFloatToFixed(param), c); in glLightModelf()
651 ogles_context_t* c = ogles_context_t::get(); in glLightModelx() local
652 lightModelx(pname, param, c); in glLightModelx()
657 ogles_context_t* c = ogles_context_t::get(); in glLightModelfv() local
659 lightModelx(pname, gglFloatToFixed(params[0]), c); in glLightModelfv()
664 ogles_error(c, GL_INVALID_ENUM); in glLightModelfv()
668 c->lighting.lightModel.ambient.r = gglFloatToFixed(params[0]); in glLightModelfv()
669 c->lighting.lightModel.ambient.g = gglFloatToFixed(params[1]); in glLightModelfv()
670 c->lighting.lightModel.ambient.b = gglFloatToFixed(params[2]); in glLightModelfv()
671 c->lighting.lightModel.ambient.a = gglFloatToFixed(params[3]); in glLightModelfv()
672 invalidate_lighting(c); in glLightModelfv()
677 ogles_context_t* c = ogles_context_t::get(); in glLightModelxv() local
679 lightModelx(pname, params[0], c); in glLightModelxv()
684 ogles_error(c, GL_INVALID_ENUM); in glLightModelxv()
688 c->lighting.lightModel.ambient.r = params[0]; in glLightModelxv()
689 c->lighting.lightModel.ambient.g = params[1]; in glLightModelxv()
690 c->lighting.lightModel.ambient.b = params[2]; in glLightModelxv()
691 c->lighting.lightModel.ambient.a = params[3]; in glLightModelxv()
692 invalidate_lighting(c); in glLightModelxv()
702 ogles_context_t* c = ogles_context_t::get(); in glLightf() local
703 lightx(i, pname, gglFloatToFixed(param), c); in glLightf()
708 ogles_context_t* c = ogles_context_t::get(); in glLightx() local
709 lightx(i, pname, param, c); in glLightx()
714 ogles_context_t* c = ogles_context_t::get(); in glLightfv() local
721 lightx(i, pname, gglFloatToFixed(params[0]), c); in glLightfv()
732 lightxv(i, pname, paramsx, c); in glLightfv()
737 ogles_context_t* c = ogles_context_t::get(); in glLightxv() local
738 lightxv(i, pname, params, c); in glLightxv()
748 ogles_context_t* c = ogles_context_t::get(); in glMaterialf() local
749 materialx(face, pname, gglFloatToFixed(param), c); in glMaterialf()
754 ogles_context_t* c = ogles_context_t::get(); in glMaterialx() local
755 materialx(face, pname, param, c); in glMaterialx()
761 ogles_context_t* c = ogles_context_t::get(); in glMaterialfv() local
763 ogles_error(c, GL_INVALID_ENUM); in glMaterialfv()
769 case GL_AMBIENT: what = c->lighting.front.ambient.v; break; in glMaterialfv()
770 case GL_DIFFUSE: what = c->lighting.front.diffuse.v; break; in glMaterialfv()
771 case GL_SPECULAR: what = c->lighting.front.specular.v; break; in glMaterialfv()
772 case GL_EMISSION: what = c->lighting.front.emission.v; break; in glMaterialfv()
774 what = c->lighting.front.ambient.v; in glMaterialfv()
775 other = c->lighting.front.diffuse.v; in glMaterialfv()
778 c->lighting.front.shininess = gglFloatToFixed(params[0]); in glMaterialfv()
779 invalidate_lighting(c); in glMaterialfv()
782 ogles_error(c, GL_INVALID_ENUM); in glMaterialfv()
795 invalidate_lighting(c); in glMaterialfv()
801 ogles_context_t* c = ogles_context_t::get(); in glMaterialxv() local
803 ogles_error(c, GL_INVALID_ENUM); in glMaterialxv()
809 case GL_AMBIENT: what = c->lighting.front.ambient.v; break; in glMaterialxv()
810 case GL_DIFFUSE: what = c->lighting.front.diffuse.v; break; in glMaterialxv()
811 case GL_SPECULAR: what = c->lighting.front.specular.v; break; in glMaterialxv()
812 case GL_EMISSION: what = c->lighting.front.emission.v; break; in glMaterialxv()
814 what = c->lighting.front.ambient.v; in glMaterialxv()
815 other = c->lighting.front.diffuse.v; in glMaterialxv()
818 c->lighting.front.shininess = gglFloatToFixed(params[0]); in glMaterialxv()
819 invalidate_lighting(c); in glMaterialxv()
822 ogles_error(c, GL_INVALID_ENUM); in glMaterialxv()
835 invalidate_lighting(c); in glMaterialxv()
845 ogles_context_t* c = ogles_context_t::get(); in glFogf() local
849 fogx(pname, paramx, c); in glFogf()
853 ogles_context_t* c = ogles_context_t::get(); in glFogx() local
854 fogx(pname, param, c); in glFogx()
859 ogles_context_t* c = ogles_context_t::get(); in glFogfv() local
864 fogx(pname, paramx, c); in glFogfv()
872 c->rasterizer.procs.fogColor3xv(c, paramsx); in glFogfv()
877 ogles_context_t* c = ogles_context_t::get(); in glFogxv() local
879 fogx(pname, params[0], c); in glFogxv()
882 c->rasterizer.procs.fogColor3xv(c, params); in glFogxv()