diff options
author | 2020-05-22 05:52:11 +0200 | |
---|---|---|
committer | 2020-05-22 05:55:28 +0200 | |
commit | 6f71a8e3d5e47ab05653315b0d44b35af6a20338 (patch) | |
tree | 57cbc1f7aa836b021da7ec1e1a05f86b63c35148 /glow/src/triangle.rs | |
parent | 1b287cddaf1951bbd65e60996eea6d356c131c1f (diff) | |
download | iced-6f71a8e3d5e47ab05653315b0d44b35af6a20338.tar.gz iced-6f71a8e3d5e47ab05653315b0d44b35af6a20338.tar.bz2 iced-6f71a8e3d5e47ab05653315b0d44b35af6a20338.zip |
Use `get_uniform_location` for wider compatibility
Diffstat (limited to '')
-rw-r--r-- | glow/src/triangle.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/glow/src/triangle.rs b/glow/src/triangle.rs index f350db98..8bafa9c6 100644 --- a/glow/src/triangle.rs +++ b/glow/src/triangle.rs @@ -18,6 +18,7 @@ pub(crate) struct Pipeline { vertex_array: <glow::Context as HasContext>::VertexArray, vertices: Buffer<Vertex2D>, indices: Buffer<u32>, + transform_location: <glow::Context as HasContext>::UniformLocation, current_transform: Transformation, antialias: Antialias, } @@ -40,11 +41,19 @@ impl Pipeline { ) }; + let transform_location = + unsafe { gl.get_uniform_location(program, "u_Transform") } + .expect("Get transform location"); + unsafe { gl.use_program(Some(program)); let transform: [f32; 16] = Transformation::identity().into(); - gl.uniform_matrix_4_f32_slice(Some(&0), false, &transform); + gl.uniform_matrix_4_f32_slice( + Some(&transform_location), + false, + &transform, + ); gl.use_program(None); } @@ -98,6 +107,7 @@ impl Pipeline { vertex_array, vertices, indices, + transform_location, current_transform: Transformation::identity(), antialias: Antialias::new(antialiasing), } @@ -163,6 +173,7 @@ impl Pipeline { let Self { antialias, current_transform, + transform_location, .. } = self; @@ -185,7 +196,11 @@ impl Pipeline { unsafe { if *current_transform != transform { let matrix: [f32; 16] = transform.into(); - gl.uniform_matrix_4_f32_slice(Some(&0), false, &matrix); + gl.uniform_matrix_4_f32_slice( + Some(transform_location), + false, + &matrix, + ); *current_transform = transform; } |