Esempio n. 1
0
/*
=================
gl_texture_init
=================
*/
erbool gl_texture_init (void)
{
    gl_trilinear = cvar_get("gl_trilinear", "1", CVAR_FL_SAVE);
    gl_anisotropy_level = cvar_get("gl_anisotropy_level", "1", CVAR_FL_SAVE);
    gl_lod_bias = cvar_get("gl_lod_bias", "0", CVAR_FL_SAVE);
    gl_picmip = cvar_get("gl_picmip", "0", CVAR_FL_SAVE);

    cvar_set_min(gl_picmip, 0.0f);

    return true;
}
Esempio n. 2
0
int cvar_set(const char *name, const char *value)
{
    if (name == NULL)
        return 0;

    struct cvar_assoc *c = cvar_get(name);

    if (c == NULL)
        return 0;

    switch(c->type)
    {
        case CVAR_INT:
        {
            t_cvar_int *p = (t_cvar_int *) c->ptr;

            if (value != NULL)
            {
                if (value[0] == '0'
                    && (value[1] == 'x' || value[1] == 'X'))
                    *p = strtoll(value + 2, NULL, 16);
                else
                    *p = strtoll(value, NULL, 10);
            }

            xprintf("%s = %ld\n", name, *p);
            return 1;
        }
        case CVAR_BOOL:
        {
            t_cvar_bool *p = (t_cvar_bool *) c->ptr;

            if (value != NULL)
            {
                if (0 == strcasecmp(value, "true"))
                    *p = 1;
                else if (0 == strcasecmp(value, "false"))
                    *p = 0;
                else
                    *p = strtol(value, NULL, 10) ? 1 : 0;
            }

            xprintf("%s = %d\n", name, *p);
            return 1;
        }
        case CVAR_STR:
        {
            t_cvar_str *p = (t_cvar_str *) c->ptr;

            if (value != NULL)
            {
                free(*p);
                *p = get_trim(value);

                if (!*p[0])
                {
                    free(*p);
                    *p = NULL;
                }
            }

            xprintf("%s = %s\n", name, *p);
            return 1;
        }
        default:
            return 0;
    }
}