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