mesa/main: replace Elements() with ARRAY_SIZE()
[mesa.git] / src / mesa / main / es1_conversion.c
1 #include <stdbool.h>
2
3 #include "api_loopback.h"
4 #include "api_exec.h"
5 #include "blend.h"
6 #include "clear.h"
7 #include "clip.h"
8 #include "context.h"
9 #include "depth.h"
10 #include "fog.h"
11 #include "imports.h"
12 #include "light.h"
13 #include "lines.h"
14 #include "matrix.h"
15 #include "multisample.h"
16 #include "pixelstore.h"
17 #include "points.h"
18 #include "polygon.h"
19 #include "readpix.h"
20 #include "texenv.h"
21 #include "texgen.h"
22 #include "texobj.h"
23 #include "texparam.h"
24 #include "mtypes.h"
25 #include "viewport.h"
26 #include "main/drawtex.h"
27 #include "vbo/vbo.h"
28
29 #include "main/es1_conversion.h"
30
31 void GL_APIENTRY
32 _mesa_AlphaFuncx(GLenum func, GLclampx ref)
33 {
34 _mesa_AlphaFunc(func, (GLclampf) (ref / 65536.0f));
35 }
36
37 void GL_APIENTRY
38 _mesa_ClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
39 {
40 _mesa_ClearColor((GLclampf) (red / 65536.0f),
41 (GLclampf) (green / 65536.0f),
42 (GLclampf) (blue / 65536.0f),
43 (GLclampf) (alpha / 65536.0f));
44 }
45
46 void GL_APIENTRY
47 _mesa_ClearDepthx(GLclampx depth)
48 {
49 _mesa_ClearDepthf((GLclampf) (depth / 65536.0f));
50 }
51
52 void GL_APIENTRY
53 _mesa_ClipPlanef(GLenum plane, const GLfloat *equation)
54 {
55 unsigned int i;
56 GLdouble converted_equation[4];
57
58 for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
59 converted_equation[i] = (GLdouble) (equation[i]);
60 }
61
62 _mesa_ClipPlane(plane, converted_equation);
63 }
64
65 void GL_APIENTRY
66 _mesa_ClipPlanex(GLenum plane, const GLfixed *equation)
67 {
68 unsigned int i;
69 GLdouble converted_equation[4];
70
71 for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
72 converted_equation[i] = (GLdouble) (equation[i] / 65536.0);
73 }
74
75 _mesa_ClipPlane(plane, converted_equation);
76 }
77
78 void GL_APIENTRY
79 _es_Color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
80 {
81 _es_Color4f((GLfloat) (red / 255.0f),
82 (GLfloat) (green / 255.0f),
83 (GLfloat) (blue / 255.0f),
84 (GLfloat) (alpha / 255.0f));
85 }
86
87 void GL_APIENTRY
88 _mesa_Color4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
89 {
90 _es_Color4f((GLfloat) (red / 65536.0f),
91 (GLfloat) (green / 65536.0f),
92 (GLfloat) (blue / 65536.0f),
93 (GLfloat) (alpha / 65536.0f));
94 }
95
96 void GL_APIENTRY
97 _mesa_DepthRangex(GLclampx zNear, GLclampx zFar)
98 {
99 _mesa_DepthRangef((GLclampf) (zNear / 65536.0f),
100 (GLclampf) (zFar / 65536.0f));
101 }
102
103 void GL_APIENTRY
104 _mesa_DrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed w, GLfixed h)
105 {
106
107 _mesa_DrawTexfOES((GLfloat) (x / 65536.0f),
108 (GLfloat) (y / 65536.0f),
109 (GLfloat) (z / 65536.0f),
110 (GLfloat) (w / 65536.0f),
111 (GLfloat) (h / 65536.0f));
112 }
113
114 void GL_APIENTRY
115 _mesa_DrawTexxvOES(const GLfixed *coords)
116 {
117 unsigned int i;
118 GLfloat converted_coords[5];
119
120 for (i = 0; i < ARRAY_SIZE(converted_coords); i++) {
121 converted_coords[i] = (GLfloat) (coords[i] / 65536.0f);
122 }
123
124 _mesa_DrawTexfvOES(converted_coords);
125 }
126
127 void GL_APIENTRY
128 _mesa_Fogx(GLenum pname, GLfixed param)
129 {
130 if (pname != GL_FOG_MODE) {
131 _mesa_Fogf(pname, (GLfloat) (param / 65536.0f));
132 } else {
133 _mesa_Fogf(pname, (GLfloat) param);
134 }
135
136 }
137
138 void GL_APIENTRY
139 _mesa_Fogxv(GLenum pname, const GLfixed *params)
140 {
141 unsigned int i;
142 unsigned int n_params = 4;
143 GLfloat converted_params[4];
144 bool convert_params_value = true;
145
146 switch(pname) {
147 case GL_FOG_MODE:
148 convert_params_value = false;
149 n_params = 1;
150 break;
151 case GL_FOG_COLOR:
152 n_params = 4;
153 break;
154 case GL_FOG_DENSITY:
155 case GL_FOG_START:
156 case GL_FOG_END:
157 n_params = 1;
158 break;
159 default:
160 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
161 "glFogxv(pname=0x%x)", pname);
162 return;
163 }
164
165 if (convert_params_value) {
166 for (i = 0; i < n_params; i++) {
167 converted_params[i] = (GLfloat) (params[i] / 65536.0f);
168 }
169 } else {
170 for (i = 0; i < n_params; i++) {
171 converted_params[i] = (GLfloat) params[i];
172 }
173 }
174
175 _mesa_Fogfv(pname, converted_params);
176 }
177
178 void GL_APIENTRY
179 _mesa_Frustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
180 GLfloat zNear, GLfloat zFar)
181 {
182 _mesa_Frustum((GLdouble) (left),
183 (GLdouble) (right),
184 (GLdouble) (bottom),
185 (GLdouble) (top),
186 (GLdouble) (zNear),
187 (GLdouble) (zFar));
188 }
189
190 void GL_APIENTRY
191 _mesa_Frustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top,
192 GLfixed zNear, GLfixed zFar)
193 {
194 _mesa_Frustum((GLdouble) (left / 65536.0),
195 (GLdouble) (right / 65536.0),
196 (GLdouble) (bottom / 65536.0),
197 (GLdouble) (top / 65536.0),
198 (GLdouble) (zNear / 65536.0),
199 (GLdouble) (zFar / 65536.0));
200 }
201
202 void GL_APIENTRY
203 _mesa_GetClipPlanef(GLenum plane, GLfloat *equation)
204 {
205 unsigned int i;
206 GLdouble converted_equation[4];
207
208 _mesa_GetClipPlane(plane, converted_equation);
209 for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
210 equation[i] = (GLfloat) (converted_equation[i]);
211 }
212 }
213
214 void GL_APIENTRY
215 _mesa_GetClipPlanex(GLenum plane, GLfixed *equation)
216 {
217 unsigned int i;
218 GLdouble converted_equation[4];
219
220 _mesa_GetClipPlane(plane, converted_equation);
221 for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
222 equation[i] = (GLfixed) (converted_equation[i] * 65536);
223 }
224 }
225
226 void GL_APIENTRY
227 _mesa_GetLightxv(GLenum light, GLenum pname, GLfixed *params)
228 {
229 unsigned int i;
230 unsigned int n_params = 4;
231 GLfloat converted_params[4];
232
233 if (light < GL_LIGHT0 || light > GL_LIGHT7) {
234 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
235 "glGetLightxv(light=0x%x)", light);
236 return;
237 }
238 switch(pname) {
239 case GL_AMBIENT:
240 case GL_DIFFUSE:
241 case GL_SPECULAR:
242 case GL_POSITION:
243 n_params = 4;
244 break;
245 case GL_SPOT_DIRECTION:
246 n_params = 3;
247 break;
248 case GL_SPOT_EXPONENT:
249 case GL_SPOT_CUTOFF:
250 case GL_CONSTANT_ATTENUATION:
251 case GL_LINEAR_ATTENUATION:
252 case GL_QUADRATIC_ATTENUATION:
253 n_params = 1;
254 break;
255 default:
256 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
257 "glGetLightxv(pname=0x%x)", pname);
258 return;
259 }
260
261 _mesa_GetLightfv(light, pname, converted_params);
262 for (i = 0; i < n_params; i++) {
263 params[i] = (GLint) (converted_params[i] * 65536);
264 }
265 }
266
267 void GL_APIENTRY
268 _mesa_GetMaterialxv(GLenum face, GLenum pname, GLfixed *params)
269 {
270 unsigned int i;
271 unsigned int n_params = 4;
272 GLfloat converted_params[4];
273
274 switch(face) {
275 case GL_FRONT:
276 case GL_BACK:
277 break;
278 default:
279 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
280 "glGetMaterialxv(face=0x%x)", face);
281 return;
282 }
283 switch(pname) {
284 case GL_SHININESS:
285 n_params = 1;
286 break;
287 case GL_AMBIENT:
288 case GL_DIFFUSE:
289 case GL_SPECULAR:
290 case GL_EMISSION:
291 n_params = 4;
292 break;
293 default:
294 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
295 "glGetMaterialxv(pname=0x%x)", pname);
296 return;
297 }
298
299 _mesa_GetMaterialfv(face, pname, converted_params);
300 for (i = 0; i < n_params; i++) {
301 params[i] = (GLint) (converted_params[i] * 65536);
302 }
303 }
304
305 void GL_APIENTRY
306 _mesa_GetTexEnvxv(GLenum target, GLenum pname, GLfixed *params)
307 {
308 unsigned int i;
309 unsigned int n_params = 4;
310 GLfloat converted_params[4];
311 bool convert_params_value = true;
312
313 switch(target) {
314 case GL_POINT_SPRITE:
315 if (pname != GL_COORD_REPLACE) {
316 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
317 "glGetTexEnvxv(target=0x%x)", target);
318 return;
319 }
320 break;
321 case GL_TEXTURE_FILTER_CONTROL_EXT:
322 if (pname != GL_TEXTURE_LOD_BIAS_EXT) {
323 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
324 "glGetTexEnvxv(target=0x%x)", target);
325 return;
326 }
327 break;
328 case GL_TEXTURE_ENV:
329 if (pname != GL_TEXTURE_ENV_COLOR && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA) {
330 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
331 "glGetTexEnvxv(target=0x%x)", target);
332 return;
333 }
334 break;
335 default:
336 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
337 "glGetTexEnvxv(target=0x%x)", target);
338 return;
339 }
340 switch(pname) {
341 case GL_COORD_REPLACE:
342 convert_params_value = false;
343 n_params = 1;
344 break;
345 case GL_TEXTURE_LOD_BIAS_EXT:
346 n_params = 1;
347 break;
348 case GL_TEXTURE_ENV_COLOR:
349 n_params = 4;
350 break;
351 case GL_RGB_SCALE:
352 case GL_ALPHA_SCALE:
353 n_params = 1;
354 break;
355 case GL_TEXTURE_ENV_MODE:
356 case GL_COMBINE_RGB:
357 case GL_COMBINE_ALPHA:
358 case GL_SRC0_RGB:
359 case GL_SRC1_RGB:
360 case GL_SRC2_RGB:
361 case GL_SRC0_ALPHA:
362 case GL_SRC1_ALPHA:
363 case GL_SRC2_ALPHA:
364 case GL_OPERAND0_RGB:
365 case GL_OPERAND1_RGB:
366 case GL_OPERAND2_RGB:
367 case GL_OPERAND0_ALPHA:
368 case GL_OPERAND1_ALPHA:
369 case GL_OPERAND2_ALPHA:
370 convert_params_value = false;
371 n_params = 1;
372 break;
373 default:
374 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
375 "glGetTexEnvxv(pname=0x%x)", pname);
376 return;
377 }
378
379 _mesa_GetTexEnvfv(target, pname, converted_params);
380 if (convert_params_value) {
381 for (i = 0; i < n_params; i++) {
382 params[i] = (GLint) (converted_params[i] * 65536);
383 }
384 } else {
385 for (i = 0; i < n_params; i++) {
386 params[i] = (GLfixed) converted_params[i];
387 }
388 }
389 }
390
391 void GL_APIENTRY
392 _check_GetTexGenivOES(GLenum coord, GLenum pname, GLint *params)
393 {
394 _mesa_GetTexGeniv(coord, pname, params);
395 }
396
397 void GL_APIENTRY
398 _mesa_GetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params)
399 {
400 _mesa_GetTexGeniv(coord, pname, (GLint *) params);
401 }
402
403 void GL_APIENTRY
404 _mesa_GetTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
405 {
406 unsigned int i;
407 unsigned int n_params = 4;
408 GLfloat converted_params[4];
409 bool convert_params_value = true;
410
411 switch(target) {
412 case GL_TEXTURE_2D:
413 case GL_TEXTURE_CUBE_MAP:
414 case GL_TEXTURE_EXTERNAL_OES:
415 break;
416 default:
417 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
418 "glGetTexParameterxv(target=0x%x)", target);
419 return;
420 }
421 switch(pname) {
422 case GL_TEXTURE_WRAP_S:
423 case GL_TEXTURE_WRAP_T:
424 case GL_TEXTURE_MIN_FILTER:
425 case GL_TEXTURE_MAG_FILTER:
426 case GL_GENERATE_MIPMAP:
427 convert_params_value = false;
428 n_params = 1;
429 break;
430 case GL_TEXTURE_CROP_RECT_OES:
431 n_params = 4;
432 break;
433 default:
434 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
435 "glGetTexParameterxv(pname=0x%x)", pname);
436 return;
437 }
438
439 _mesa_GetTexParameterfv(target, pname, converted_params);
440 if (convert_params_value) {
441 for (i = 0; i < n_params; i++) {
442 params[i] = (GLint) (converted_params[i] * 65536);
443 }
444 } else {
445 for (i = 0; i < n_params; i++) {
446 params[i] = (GLfixed) converted_params[i];
447 }
448 }
449 }
450
451 void GL_APIENTRY
452 _mesa_LightModelx(GLenum pname, GLfixed param)
453 {
454 _mesa_LightModelf(pname, (GLfloat) param);
455 }
456
457 void GL_APIENTRY
458 _mesa_LightModelxv(GLenum pname, const GLfixed *params)
459 {
460 unsigned int i;
461 unsigned int n_params = 4;
462 GLfloat converted_params[4];
463 bool convert_params_value = true;
464
465 switch(pname) {
466 case GL_LIGHT_MODEL_AMBIENT:
467 n_params = 4;
468 break;
469 case GL_LIGHT_MODEL_TWO_SIDE:
470 convert_params_value = false;
471 n_params = 1;
472 break;
473 default:
474 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
475 "glLightModelxv(pname=0x%x)", pname);
476 return;
477 }
478
479 if (convert_params_value) {
480 for (i = 0; i < n_params; i++) {
481 converted_params[i] = (GLfloat) (params[i] / 65536.0f);
482 }
483 } else {
484 for (i = 0; i < n_params; i++) {
485 converted_params[i] = (GLfloat) params[i];
486 }
487 }
488
489 _mesa_LightModelfv(pname, converted_params);
490 }
491
492 void GL_APIENTRY
493 _mesa_Lightx(GLenum light, GLenum pname, GLfixed param)
494 {
495 _mesa_Lightf(light, pname, (GLfloat) (param / 65536.0f));
496 }
497
498 void GL_APIENTRY
499 _mesa_Lightxv(GLenum light, GLenum pname, const GLfixed *params)
500 {
501 unsigned int i;
502 unsigned int n_params = 4;
503 GLfloat converted_params[4];
504
505 if (light < GL_LIGHT0 || light > GL_LIGHT7) {
506 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
507 "glLightxv(light=0x%x)", light);
508 return;
509 }
510 switch(pname) {
511 case GL_AMBIENT:
512 case GL_DIFFUSE:
513 case GL_SPECULAR:
514 case GL_POSITION:
515 n_params = 4;
516 break;
517 case GL_SPOT_DIRECTION:
518 n_params = 3;
519 break;
520 case GL_SPOT_EXPONENT:
521 case GL_SPOT_CUTOFF:
522 case GL_CONSTANT_ATTENUATION:
523 case GL_LINEAR_ATTENUATION:
524 case GL_QUADRATIC_ATTENUATION:
525 n_params = 1;
526 break;
527 default:
528 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
529 "glLightxv(pname=0x%x)", pname);
530 return;
531 }
532
533 for (i = 0; i < n_params; i++) {
534 converted_params[i] = (GLfloat) (params[i] / 65536.0f);
535 }
536
537 _mesa_Lightfv(light, pname, converted_params);
538 }
539
540 void GL_APIENTRY
541 _mesa_LineWidthx(GLfixed width)
542 {
543 _mesa_LineWidth((GLfloat) (width / 65536.0f));
544 }
545
546 void GL_APIENTRY
547 _mesa_LoadMatrixx(const GLfixed *m)
548 {
549 unsigned int i;
550 GLfloat converted_m[16];
551
552 for (i = 0; i < ARRAY_SIZE(converted_m); i++) {
553 converted_m[i] = (GLfloat) (m[i] / 65536.0f);
554 }
555
556 _mesa_LoadMatrixf(converted_m);
557 }
558
559 void GL_APIENTRY
560 _mesa_Materialx(GLenum face, GLenum pname, GLfixed param)
561 {
562 if (face != GL_FRONT_AND_BACK) {
563 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
564 "glMaterialx(face=0x%x)", face);
565 return;
566 }
567
568 if (pname != GL_SHININESS) {
569 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
570 "glMaterialx(pname=0x%x)", pname);
571 return;
572 }
573
574 _es_Materialf(face, pname, (GLfloat) (param / 65536.0f));
575 }
576
577 void GL_APIENTRY
578 _mesa_Materialxv(GLenum face, GLenum pname, const GLfixed *params)
579 {
580 unsigned int i;
581 unsigned int n_params = 4;
582 GLfloat converted_params[4];
583
584 if (face != GL_FRONT_AND_BACK) {
585 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
586 "glMaterialxv(face=0x%x)", face);
587 return;
588 }
589
590 switch(pname) {
591 case GL_AMBIENT:
592 case GL_DIFFUSE:
593 case GL_AMBIENT_AND_DIFFUSE:
594 case GL_SPECULAR:
595 case GL_EMISSION:
596 n_params = 4;
597 break;
598 case GL_SHININESS:
599 n_params = 1;
600 break;
601 default:
602 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
603 "glMaterialxv(pname=0x%x)", pname);
604 return;
605 }
606
607 for (i = 0; i < n_params; i++) {
608 converted_params[i] = (GLfloat) (params[i] / 65536.0f);
609 }
610
611 _es_Materialfv(face, pname, converted_params);
612 }
613
614 void GL_APIENTRY
615 _mesa_MultMatrixx(const GLfixed *m)
616 {
617 unsigned int i;
618 GLfloat converted_m[16];
619
620 for (i = 0; i < ARRAY_SIZE(converted_m); i++) {
621 converted_m[i] = (GLfloat) (m[i] / 65536.0f);
622 }
623
624 _mesa_MultMatrixf(converted_m);
625 }
626
627 void GL_APIENTRY
628 _mesa_MultiTexCoord4x(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
629 {
630 _es_MultiTexCoord4f(texture,
631 (GLfloat) (s / 65536.0f),
632 (GLfloat) (t / 65536.0f),
633 (GLfloat) (r / 65536.0f),
634 (GLfloat) (q / 65536.0f));
635 }
636
637 void GL_APIENTRY
638 _mesa_Normal3x(GLfixed nx, GLfixed ny, GLfixed nz)
639 {
640 _es_Normal3f((GLfloat) (nx / 65536.0f),
641 (GLfloat) (ny / 65536.0f),
642 (GLfloat) (nz / 65536.0f));
643 }
644
645 void GL_APIENTRY
646 _mesa_Orthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
647 GLfloat zNear, GLfloat zFar)
648 {
649 _mesa_Ortho((GLdouble) (left),
650 (GLdouble) (right),
651 (GLdouble) (bottom),
652 (GLdouble) (top),
653 (GLdouble) (zNear),
654 (GLdouble) (zFar));
655 }
656
657 void GL_APIENTRY
658 _mesa_Orthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top,
659 GLfixed zNear, GLfixed zFar)
660 {
661 _mesa_Ortho((GLdouble) (left / 65536.0),
662 (GLdouble) (right / 65536.0),
663 (GLdouble) (bottom / 65536.0),
664 (GLdouble) (top / 65536.0),
665 (GLdouble) (zNear / 65536.0),
666 (GLdouble) (zFar / 65536.0));
667 }
668
669 void GL_APIENTRY
670 _mesa_PointParameterx(GLenum pname, GLfixed param)
671 {
672 _mesa_PointParameterf(pname, (GLfloat) (param / 65536.0f));
673 }
674
675 void GL_APIENTRY
676 _mesa_PointParameterxv(GLenum pname, const GLfixed *params)
677 {
678 unsigned int i;
679 unsigned int n_params = 3;
680 GLfloat converted_params[3];
681
682 switch(pname) {
683 case GL_POINT_SIZE_MIN:
684 case GL_POINT_SIZE_MAX:
685 case GL_POINT_FADE_THRESHOLD_SIZE:
686 n_params = 1;
687 break;
688 case GL_POINT_DISTANCE_ATTENUATION:
689 n_params = 3;
690 break;
691 default:
692 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
693 "glPointParameterxv(pname=0x%x)", pname);
694 return;
695 }
696
697 for (i = 0; i < n_params; i++) {
698 converted_params[i] = (GLfloat) (params[i] / 65536.0f);
699 }
700
701 _mesa_PointParameterfv(pname, converted_params);
702 }
703
704 void GL_APIENTRY
705 _mesa_PointSizex(GLfixed size)
706 {
707 _mesa_PointSize((GLfloat) (size / 65536.0f));
708 }
709
710 void GL_APIENTRY
711 _mesa_PolygonOffsetx(GLfixed factor, GLfixed units)
712 {
713 _mesa_PolygonOffset((GLfloat) (factor / 65536.0f),
714 (GLfloat) (units / 65536.0f));
715 }
716
717 void GL_APIENTRY
718 _mesa_Rotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
719 {
720 _mesa_Rotatef((GLfloat) (angle / 65536.0f),
721 (GLfloat) (x / 65536.0f),
722 (GLfloat) (y / 65536.0f),
723 (GLfloat) (z / 65536.0f));
724 }
725
726 void GL_APIENTRY
727 _mesa_SampleCoveragex(GLclampx value, GLboolean invert)
728 {
729 _mesa_SampleCoverage((GLclampf) (value / 65536.0f),
730 invert);
731 }
732
733 void GL_APIENTRY
734 _mesa_Scalex(GLfixed x, GLfixed y, GLfixed z)
735 {
736 _mesa_Scalef((GLfloat) (x / 65536.0f),
737 (GLfloat) (y / 65536.0f),
738 (GLfloat) (z / 65536.0f));
739 }
740
741 void GL_APIENTRY
742 _mesa_TexEnvx(GLenum target, GLenum pname, GLfixed param)
743 {
744 switch(target) {
745 case GL_POINT_SPRITE:
746 case GL_TEXTURE_FILTER_CONTROL_EXT:
747 case GL_TEXTURE_ENV:
748 break;
749 default:
750 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
751 "glTexEnvx(target=0x%x)", target);
752 return;
753 }
754
755 switch(pname) {
756 case GL_COORD_REPLACE:
757 case GL_TEXTURE_ENV_MODE:
758 case GL_COMBINE_RGB:
759 case GL_COMBINE_ALPHA:
760 case GL_SRC0_RGB:
761 case GL_SRC1_RGB:
762 case GL_SRC2_RGB:
763 case GL_SRC0_ALPHA:
764 case GL_SRC1_ALPHA:
765 case GL_SRC2_ALPHA:
766 case GL_OPERAND0_RGB:
767 case GL_OPERAND1_RGB:
768 case GL_OPERAND2_RGB:
769 case GL_OPERAND0_ALPHA:
770 case GL_OPERAND1_ALPHA:
771 case GL_OPERAND2_ALPHA:
772 _mesa_TexEnvf(target, pname, (GLfloat) param);
773 break;
774 case GL_TEXTURE_LOD_BIAS_EXT:
775 case GL_RGB_SCALE:
776 case GL_ALPHA_SCALE:
777 _mesa_TexEnvf(target, pname, (GLfloat) (param / 65536.0f));
778 break;
779 default:
780 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
781 "glTexEnvx(pname=0x%x)", pname);
782 return;
783 }
784 }
785
786 void GL_APIENTRY
787 _mesa_TexEnvxv(GLenum target, GLenum pname, const GLfixed *params)
788 {
789 switch(target) {
790 case GL_POINT_SPRITE:
791 case GL_TEXTURE_FILTER_CONTROL_EXT:
792 case GL_TEXTURE_ENV:
793 break;
794 default:
795 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
796 "glTexEnvxv(target=0x%x)", target);
797 return;
798 }
799
800 switch(pname) {
801 case GL_COORD_REPLACE:
802 case GL_TEXTURE_ENV_MODE:
803 case GL_COMBINE_RGB:
804 case GL_COMBINE_ALPHA:
805 case GL_SRC0_RGB:
806 case GL_SRC1_RGB:
807 case GL_SRC2_RGB:
808 case GL_SRC0_ALPHA:
809 case GL_SRC1_ALPHA:
810 case GL_SRC2_ALPHA:
811 case GL_OPERAND0_RGB:
812 case GL_OPERAND1_RGB:
813 case GL_OPERAND2_RGB:
814 case GL_OPERAND0_ALPHA:
815 case GL_OPERAND1_ALPHA:
816 case GL_OPERAND2_ALPHA:
817 _mesa_TexEnvf(target, pname, (GLfloat) params[0]);
818 break;
819 case GL_TEXTURE_LOD_BIAS_EXT:
820 case GL_RGB_SCALE:
821 case GL_ALPHA_SCALE:
822 _mesa_TexEnvf(target, pname, (GLfloat) (params[0] / 65536.0f));
823 break;
824 case GL_TEXTURE_ENV_COLOR: {
825 unsigned int i;
826 GLfloat converted_params[4];
827
828 for (i = 0; i < ARRAY_SIZE(converted_params); i++) {
829 converted_params[i] = (GLfloat) (params[i] / 65536.0f);
830 }
831
832 _mesa_TexEnvfv(target, pname, converted_params);
833 break;
834 }
835 default:
836 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
837 "glTexEnvxv(pname=0x%x)", pname);
838 return;
839 }
840 }
841
842 void GL_APIENTRY
843 _check_TexGeniOES(GLenum coord, GLenum pname, GLint param)
844 {
845 _es_TexGenf(coord, pname, (GLfloat) param);
846 }
847
848 void GL_APIENTRY
849 _check_TexGenivOES(GLenum coord, GLenum pname, const GLint *params)
850 {
851 _es_TexGenf(coord, pname, (GLfloat) params[0]);
852 }
853
854 void GL_APIENTRY
855 _mesa_TexGenxOES(GLenum coord, GLenum pname, GLfixed param)
856 {
857 _es_TexGenf(coord, pname, (GLfloat) param);
858 }
859
860 void GL_APIENTRY
861 _mesa_TexGenxvOES(GLenum coord, GLenum pname, const GLfixed *params)
862 {
863 _es_TexGenf(coord, pname, (GLfloat) params[0]);
864 }
865
866 void GL_APIENTRY
867 _mesa_TexParameterx(GLenum target, GLenum pname, GLfixed param)
868 {
869 if (pname == GL_TEXTURE_MAX_ANISOTROPY_EXT) {
870 _mesa_TexParameterf(target, pname, (GLfloat) (param / 65536.0f));
871 } else {
872 _mesa_TexParameterf(target, pname, (GLfloat) param);
873 }
874 }
875
876 void GL_APIENTRY
877 _mesa_TexParameterxv(GLenum target, GLenum pname, const GLfixed *params)
878 {
879 unsigned int i;
880 unsigned int n_params = 4;
881 GLfloat converted_params[4];
882 bool convert_params_value = true;
883
884 switch(target) {
885 case GL_TEXTURE_2D:
886 case GL_TEXTURE_CUBE_MAP:
887 case GL_TEXTURE_EXTERNAL_OES:
888 break;
889 default:
890 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
891 "glTexParameterxv(target=0x%x)", target);
892 return;
893 }
894 switch(pname) {
895 case GL_TEXTURE_WRAP_S:
896 case GL_TEXTURE_WRAP_T:
897 convert_params_value = false;
898 n_params = 1;
899 break;
900 case GL_TEXTURE_MIN_FILTER:
901 case GL_TEXTURE_MAG_FILTER:
902 case GL_GENERATE_MIPMAP:
903 convert_params_value = false;
904 n_params = 1;
905 break;
906 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
907 n_params = 1;
908 break;
909 case GL_TEXTURE_CROP_RECT_OES:
910 n_params = 4;
911 break;
912 default:
913 _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
914 "glTexParameterxv(pname=0x%x)", pname);
915 return;
916 }
917
918 if (convert_params_value) {
919 for (i = 0; i < n_params; i++) {
920 converted_params[i] = (GLfloat) (params[i] / 65536.0f);
921 }
922 } else {
923 for (i = 0; i < n_params; i++) {
924 converted_params[i] = (GLfloat) params[i];
925 }
926 }
927
928 _mesa_TexParameterfv(target, pname, converted_params);
929 }
930
931 void GL_APIENTRY
932 _mesa_Translatex(GLfixed x, GLfixed y, GLfixed z)
933 {
934 _mesa_Translatef((GLfloat) (x / 65536.0f),
935 (GLfloat) (y / 65536.0f),
936 (GLfloat) (z / 65536.0f));
937 }