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