Skip to content

Commit

Permalink
Avoid uniform location panic on Chrome OS/Android
Browse files Browse the repository at this point in the history
  • Loading branch information
asny committed Feb 5, 2024
1 parent 70563f1 commit e2c6cf3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/core/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ impl Program {
.get_active_attribute(id, i)
.filter(|a| !a.name.starts_with("gl_"))
{
let location = context.get_attrib_location(id, &name).unwrap_or_else(|| {
panic!("Could not get the location of attribute {}", name)
});
attributes.insert(name, location);
if let Some(location) = context.get_attrib_location(id, &name) {
attributes.insert(name, location);
}
}
}

Expand All @@ -115,11 +114,10 @@ impl Program {
.get_active_uniform(id, i)
.filter(|a| !a.name.starts_with("gl_"))
{
let location = context.get_uniform_location(id, &name).unwrap_or_else(|| {
panic!("Could not get the location of uniform {}", name)
});
let name = name.split('[').next().unwrap().to_string();
uniforms.insert(name, location);
if let Some(location) = context.get_uniform_location(id, &name) {
let name = name.split('[').next().unwrap().to_string();
uniforms.insert(name, location);
}
}
}

Expand Down

0 comments on commit e2c6cf3

Please sign in to comment.