diff --git a/etc/shaders/lovr.glsl b/etc/shaders/lovr.glsl index 79019a86..370f3b5b 100644 --- a/etc/shaders/lovr.glsl +++ b/etc/shaders/lovr.glsl @@ -80,16 +80,16 @@ layout(location = 0) out vec4 PixelColor; #ifdef GL_VERTEX_SHADER layout(location = 10) out vec3 PositionWorld; layout(location = 11) out vec3 Normal; -layout(location = 12) out vec4 Color; -layout(location = 13) out vec2 UV; +layout(location = 12) out vec2 UV; +layout(location = 13) out vec4 Color; layout(location = 14) out vec3 Tangent; #endif #ifdef GL_FRAGMENT_SHADER layout(location = 10) in vec3 PositionWorld; layout(location = 11) in vec3 Normal; -layout(location = 12) in vec4 Color; -layout(location = 13) in vec2 UV; +layout(location = 12) in vec2 UV; +layout(location = 13) in vec4 Color; layout(location = 14) in vec3 Tangent; #endif diff --git a/src/modules/graphics/graphics.c b/src/modules/graphics/graphics.c index 5e492f7c..871dacc0 100644 --- a/src/modules/graphics/graphics.c +++ b/src/modules/graphics/graphics.c @@ -2857,11 +2857,18 @@ bool lovrShaderHasStage(Shader* shader, ShaderStage stage) { } bool lovrShaderHasAttribute(Shader* shader, const char* name, uint32_t location) { - uint32_t hash = name ? (uint32_t) hash64(name, strlen(name)) : 0; - for (uint32_t i = 0; i < shader->attributeCount; i++) { - ShaderAttribute* attribute = &shader->attributes[i]; - if (name ? (attribute->hash == hash) : (attribute->location == location)) { - return true; + if (name) { + uint32_t hash = (uint32_t) hash64(name, strlen(name)); + for (uint32_t i = 0; i < shader->attributeCount; i++) { + if (shader->attributes[i].hash == hash) { + return true; + } + } + } else { + for (uint32_t i = 0; i < shader->attributeCount; i++) { + if (shader->attributes[i].location == location) { + return true; + } } } return false; diff --git a/src/modules/graphics/graphics.h b/src/modules/graphics/graphics.h index d962aaa0..653cf993 100644 --- a/src/modules/graphics/graphics.h +++ b/src/modules/graphics/graphics.h @@ -148,7 +148,8 @@ typedef enum { TYPE_MAT3, TYPE_MAT4, TYPE_INDEX16, - TYPE_INDEX32 + TYPE_INDEX32, + TYPE_COUNT } DataType; typedef enum {