OpenGL: Redo uniform loading

This commit is contained in:
Jeffrey Pfau 2015-12-17 21:58:17 -08:00
parent 36d726f3c5
commit 2edd1505ae
2 changed files with 12 additions and 12 deletions

View File

@ -15,21 +15,18 @@ fragmentShader=ags001-light.fs
width=960 width=960
height=640 height=640
[uniform.lightBrightness] [pass.1.uniform.lightBrightness]
type=float type=float
default=1 default=1
pass[0]=false
readableName=Light brightness readableName=Light brightness
[uniform.reflectionBrightness] [pass.1.uniform.reflectionBrightness]
type=float type=float
default=0.07 default=0.07
pass[0]=false
readableName=Reflection brightness readableName=Reflection brightness
[uniform.reflectionDistance] [pass.1.uniform.reflectionDistance]
type=float2 type=float2
default[0]=0 default[0]=0
default[1]=0.025 default[1]=0.025
pass[0]=false
readableName=Reflection distance readableName=Reflection distance

View File

@ -439,7 +439,9 @@ DEFINE_VECTOR(GBAGLES2UniformList, struct GBAGLES2Uniform);
static void _uniformHandler(const char* sectionName, void* user) { static void _uniformHandler(const char* sectionName, void* user) {
struct GBAGLES2UniformList* uniforms = user; struct GBAGLES2UniformList* uniforms = user;
if (strstr(sectionName, "uniform.") != sectionName) { unsigned passId;
int sentinel;
if (sscanf(sectionName, "pass.%u.uniform.%n", &passId, &sentinel) < 1) {
return; return;
} }
struct GBAGLES2Uniform* u = GBAGLES2UniformListAppend(uniforms); struct GBAGLES2Uniform* u = GBAGLES2UniformListAppend(uniforms);
@ -658,13 +660,14 @@ static void _loadValue(struct Configuration* description, const char* name, GLen
} }
static bool _loadUniform(struct Configuration* description, size_t pass, struct GBAGLES2Uniform* uniform) { static bool _loadUniform(struct Configuration* description, size_t pass, struct GBAGLES2Uniform* uniform) {
char passId[12]; unsigned passId;
snprintf(passId, sizeof(passId), "pass[%zu]", pass); if (sscanf(uniform->name, "pass.%u.uniform.", &passId) < 1 || passId != pass) {
GLboolean inPass;
if (_lookupBoolValue(description, uniform->name, passId, &inPass) && !inPass) {
return false; return false;
} }
const char* type = ConfigurationGetValue(description, uniform->name, "type"); const char* type = ConfigurationGetValue(description, uniform->name, "type");
if (!type) {
return false;
}
if (!strcmp(type, "float")) { if (!strcmp(type, "float")) {
uniform->type = GL_FLOAT; uniform->type = GL_FLOAT;
} else if (!strcmp(type, "float2")) { } else if (!strcmp(type, "float2")) {
@ -707,7 +710,7 @@ static bool _loadUniform(struct Configuration* description, size_t pass, struct
} else { } else {
uniform->readableName = 0; uniform->readableName = 0;
} }
uniform->name = strdup(uniform->name + strlen("uniform.")); uniform->name = strdup(strstr(uniform->name, "uniform.") + strlen("uniform."));
return true; return true;
} }