Skip to content

Commit

Permalink
arealights: don't hardcode attribute locations.
Browse files Browse the repository at this point in the history
This is why the example was broken basically since the 2020.06 release,
which changed the normal attribute location from 2 to 5. Sigh.
  • Loading branch information
mosra committed Oct 2, 2024
1 parent 5f771f1 commit dd0327e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/arealights/AreaLights.vert
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

layout(location = 0) in vec4 position;
layout(location = 2) in vec3 normal;
layout(location = POSITION_ATTRIBUTE_LOCATION) in vec4 position;
layout(location = NORMAL_ATTRIBUTE_LOCATION) in vec3 normal;

out vec4 v_position;
out vec3 v_normal;
Expand Down
7 changes: 6 additions & 1 deletion src/arealights/AreaLightsExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ class AreaLightShader: public GL::AbstractShaderProgram {
GL::Shader vert{GL::Version::GL430, GL::Shader::Type::Vertex};
GL::Shader frag{GL::Version::GL430, GL::Shader::Type::Fragment};

vert.addSource(rs.getString("AreaLights.vert"));
vert.addSource(Utility::format(
"#define POSITION_ATTRIBUTE_LOCATION {}\n"
"#define NORMAL_ATTRIBUTE_LOCATION {}\n",
Shaders::GenericGL3D::Position::Location,
Shaders::GenericGL3D::Normal::Location))
.addSource(rs.getString("AreaLights.vert"));
frag.addSource(rs.getString("AreaLights.frag"));

CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile() && frag.compile());
Expand Down

0 comments on commit dd0327e

Please sign in to comment.