Fix gldemo

The GL program needs to be used before accessing its attributes.

#minor-release

PiperOrigin-RevId: 410768017
This commit is contained in:
andrewlewis 2021-11-18 12:31:25 +00:00 committed by Ian Baker
parent 4ebe046b5e
commit d49b39bf37

View File

@ -88,6 +88,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
program.use();
GlUtil.Attribute[] attributes = program.getAttributes(); GlUtil.Attribute[] attributes = program.getAttributes();
for (GlUtil.Attribute attribute : attributes) { for (GlUtil.Attribute attribute : attributes) {
if (attribute.name.equals("a_position")) { if (attribute.name.equals("a_position")) {
@ -142,7 +143,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Run the shader program. // Run the shader program.
GlUtil.Uniform[] uniforms = checkNotNull(this.uniforms); GlUtil.Uniform[] uniforms = checkNotNull(this.uniforms);
GlUtil.Attribute[] attributes = checkNotNull(this.attributes); GlUtil.Attribute[] attributes = checkNotNull(this.attributes);
checkNotNull(program).use();
for (GlUtil.Uniform uniform : uniforms) { for (GlUtil.Uniform uniform : uniforms) {
switch (uniform.name) { switch (uniform.name) {
case "tex_sampler_0": case "tex_sampler_0":