<commit_before>#include "texgen.h"
#include "init.h"
#include "matrix.h"
#include "../glx/hardext.h"

//extern void* eglGetProcAddress(const char*);

void gl4es_glTexGeni(GLenum coord, GLenum pname, GLint param) {
    GLfloat params[4] = {0,0,0,0};
    params[0]=param;
    gl4es_glTexGenfv(coord, pname, params);
}

void gl4es_glTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) {
    
    /*
    If pname is GL_TEXTURE_GEN_MODE, then the array must contain
    a single symbolic constant, one of
    GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_MAP, GL_NORMAL_MAP,
    or GL_REFLECTION_MAP.
    Otherwise, params holds the coefficients for the texture-coordinate
    generation function specified by pname.
    */

    //printf("glTexGenf(%s, %s, %s/%f), texture=%i\n", PrintEnum(coord), PrintEnum(pname), PrintEnum(param[0]), param[0], glstate->texture.active);
    ERROR_IN_BEGIN
    if (glstate->list.active)
        if (glstate->list.compiling || glstate->gl_batch) {
            NewStage(glstate->list.active, STAGE_TEXGEN);
            rlTexGenfv(glstate->list.active, coord, pname, param);
            noerrorShim();
            return;
        } else flush();

    // pname is in: GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, GL_EYE_PLANE
    noerrorShim();
    switch(pname) {
        case GL_TEXTURE_GEN_MODE: {
            int mode = -1;
            int n;
            if(glstate->fpe_state) {
                int p = param[0];
                switch (p) {
                    case GL_OBJECT_LINEAR: mode = FPE_TG_OBJLINEAR; break;
                    case GL_EYE_LINEAR: mode = FPE_TG_EYELINEAR; break;
                    case GL_SPHERE_MAP: mode = FPE_TG_SPHEREMAP; break;
                    case GL_NORMAL_MAP: mode = FPE_TG_NORMALMAP; break;
                    case GL_REFLECTION_MAP: mode = FPE_TG_REFLECMAP; break;
                }
                n = glstate->texture.active*3;
            }
            switch (coord) {
                case GL_S: glstate->texgen[glstate->texture.active].S = param[0]; if(mode!=-1) { glstate->fpe_state->texgen_s_mode&=~(7<<n); glstate->fpe_state->texgen_s_mode|=(mode<<n); } break;
                case GL_T: glstate->texgen[glstate->texture.active].T = param[0]; if(mode!=-1) { glstate->fpe_state->texgen_t_mode&=~(7<<n); glstate->fpe_state->texgen_t_mode|=(mode<<n); } break;
                case GL_R: glstate->texgen[glstate->texture.active].R = param[0]; if(mode!=-1) { glstate->fpe_state->texgen_r_mode&=~(7<<n); glstate->fpe_state->texgen_r_mode|=(mode<<n); } break;
                case GL_Q: 
                    if(param[0]==GL_REFLECTION_MAP || param[0]==GL_NORMAL_MAP) {
                        errorShim(GL_INVALID_ENUM);
                        return;
                    }
                    glstate->texgen[glstate->texture.active].Q = param[0]; if(mode!=-1) { glstate->fpe_state->texgen_q_mode&=~(7<<n); glstate->fpe_state->texgen_q_mode|=(mode<<n); } break;
                default:
                    errorShim(GL_INVALID_ENUM);
            }
            return;
        }
        case GL_OBJECT_PLANE:
            switch (coord) {
                case GL_S:
                    memcpy(glstate->texgen[glstate->texture.active].S_O, param, 4 * sizeof(GLfloat));
                    break;
                case GL_T:
                    memcpy(glstate->texgen[glstate->texture.active].T_O, param, 4 * sizeof(GLfloat));
                    break;
                case GL_R:
                    memcpy(glstate->texgen[glstate->texture.active].R_O, param, 4 * sizeof(GLfloat));
                    break;
                case GL_Q:
                    memcpy(glstate->texgen[glstate->texture.active].Q_O, param, 4 * sizeof(GLfloat));
                    break;<commit_msg>More sanity check on TexGen<commit_after>#include "texgen.h"
#include "init.h"
#include "matrix.h"
#include "../glx/hardext.h"

//extern void* eglGetProcAddress(const char*);

void gl4es_glTexGeni(GLenum coord, GLenum pname, GLint param) {
    GLfloat params[4] = {0,0,0,0};
    params[0]=param;
    gl4es_glTexGenfv(coord, pname, params);
}

void gl4es_glTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) {
    
    /*
    If pname is GL_TEXTURE_GEN_MODE, then the array must contain
    a single symbolic constant, one of
    GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_MAP, GL_NORMAL_MAP,
    or GL_REFLECTION_MAP.
    Otherwise, params holds the coefficients for the texture-coordinate
    generation function specified by pname.
    */

    //printf("glTexGenf(%s, %s, %s/%f), texture=%i\n", PrintEnum(coord), PrintEnum(pname), PrintEnum(param[0]), param[0], glstate->texture.active);
    ERROR_IN_BEGIN
    if (glstate->list.active)
        if (glstate->list.compiling || glstate->gl_batch) {
            NewStage(glstate->list.active, STAGE_TEXGEN);
            rlTexGenfv(glstate->list.active, coord, pname, param);
            noerrorShim();
            return;
        } else flush();

    // pname is in: GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, GL_EYE_PLANE
    noerrorShim();
    switch(pname) {
        case GL_TEXTURE_GEN_MODE: {
            int mode = -1;
            int n;
            if(glstate->fpe_state) {
                int p = param[0];
                switch (p) {
                    case GL_OBJECT_LINEAR: mode = FPE_TG_OBJLINEAR; break;
                    case GL_EYE_LINEAR: mode = FPE_TG_EYELINEAR; break;
                    case GL_SPHERE_MAP: mode = FPE_TG_SPHEREMAP; break;
                    case GL_NORMAL_MAP: mode = FPE_TG_NORMALMAP; break;
                    case GL_REFLECTION_MAP: mode = FPE_TG_REFLECMAP; break;
                }
                n = glstate->texture.active*3;
            }
            switch (coord) {
                case GL_S: glstate->texgen[glstate->texture.active].S = param[0]; if(mode!=-1) { glstate->fpe_state->texgen_s_mode&=~(7<<n); glstate->fpe_state->texgen_s_mode|=(mode<<n); } break;
                case GL_T: glstate->texgen[glstate->texture.active].T = param[0]; if(mode!=-1) { glstate->fpe_state->texgen_t_mode&=~(7<<n); glstate->fpe_state->texgen_t_mode|=(mode<<n); } break;
                case GL_R: 
                    if(param[0]==GL_SPHERE_MAP) {
                        errorShim(GL_INVALID_ENUM);
                        return;
                    }
                    glstate->texgen[glstate->texture.active].R = param[0]; if(mode!=-1) { glstate->fpe_state->texgen_r_mode&=~(7<<n); glstate->fpe_state->texgen_r_mode|=(mode<<n); } break;
                case GL_Q: 
                    if(param[0]==GL_REFLECTION_MAP || param[0]==GL_NORMAL_MAP || param[0]==GL_SPHERE_MAP) {
                        errorShim(GL_INVALID_ENUM);
                        return;
                    }
                    glstate->texgen[glstate->texture.active].Q = param[0]; if(mode!=-1) { glstate->fpe_state->texgen_q_mode&=~(7<<n); glstate->fpe_state->texgen_q_mode|=(mode<<n); } break;
                default:
                    errorShim(GL_INVALID_ENUM);
            }
            return;
        }
        case GL_OBJECT_PLANE:
            switch (coord) {
                case GL_S:
                    memcpy(glstate->texgen[glstate->texture.active].S_O, param, 4 * sizeof(GLfloat));
                    break;
                case GL_T:
                    memcpy(glstate->texgen[glstate->texture.active].T_O, param, 4 * sizeof(GLfloat));
                    break;
                case GL_R:
                    memcpy(glstate->texgen[glstate->texture.active].R_O, param, 4 * sizeof(GLfloat));
                    break;
                case GL_Q:
                    memcpy(glstate->texgen[glstate->texture.active].Q_O, param, 4 * sizeof(GLfloat));
                    break;
{'fraction_non_alphanumeric': 0.12885662431941924, 'fraction_numerical': 0.00855587243971999, 'mean_word_length': 2.0433925049309667, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3659184', 'n_tokens_mistral': 2623, 'n_tokens_neox': 2509, 'n_words': 435}