libobs: Implement BorderColor sampler state value

This commit is contained in:
jp9000
2016-02-21 12:06:19 -08:00
parent 876cc94d51
commit f6728189f5
2 changed files with 22 additions and 10 deletions

View File

@@ -396,7 +396,8 @@ static int ep_parse_sampler_state_item(struct effect_parser *ep,
struct ep_sampler *eps)
{
int ret;
char *state = NULL, *value = NULL;
char *state = NULL;
struct dstr value = {0};
ret = cf_next_name(&ep->cfp, &state, "state name", ";");
if (ret != PARSE_SUCCESS) goto fail;
@@ -404,19 +405,29 @@ static int ep_parse_sampler_state_item(struct effect_parser *ep,
ret = cf_next_token_should_be(&ep->cfp, "=", ";", NULL);
if (ret != PARSE_SUCCESS) goto fail;
ret = cf_next_name(&ep->cfp, &value, "value name", ";");
if (ret != PARSE_SUCCESS) goto fail;
for (;;) {
const char *cur_str;
ret = cf_next_token_should_be(&ep->cfp, ";", ";", NULL);
if (ret != PARSE_SUCCESS) goto fail;
if (!cf_next_valid_token(&ep->cfp))
return PARSE_EOF;
cur_str = ep->cfp.cur_token->str.array;
if (*cur_str == ';')
break;
dstr_ncat(&value, cur_str, ep->cfp.cur_token->str.len);
}
if (value.len) {
da_push_back(eps->states, &state);
da_push_back(eps->values, &value.array);
}
da_push_back(eps->states, &state);
da_push_back(eps->values, &value);
return ret;
fail:
bfree(state);
bfree(value);
dstr_free(&value);
return ret;
}

View File

@@ -112,8 +112,9 @@ void shader_sampler_convert(struct shader_sampler *ss,
info->address_w = get_address_mode(value);
else if (astrcmpi(state, "MaxAnisotropy") == 0)
info->max_anisotropy = (int)strtol(value, NULL, 10);
/*else if (astrcmpi(state, "BorderColor") == 0)
// TODO */
else if (astrcmpi(state, "BorderColor") == 0)
info->border_color = (*value == '#') ?
strtol(value + 1, NULL, 16) : 0;
}
}