Set sampler uniform only once

This commit is contained in:
Héctor Ramón Jiménez 2020-05-23 03:23:41 +02:00
parent 2401161d52
commit 7d5021ca82
1 changed files with 2 additions and 3 deletions

View File

@ -11,7 +11,6 @@ pub struct Pipeline {
vertex_array: <glow::Context as HasContext>::VertexArray, vertex_array: <glow::Context as HasContext>::VertexArray,
instances: <glow::Context as HasContext>::Buffer, instances: <glow::Context as HasContext>::Buffer,
transform: <glow::Context as HasContext>::UniformLocation, transform: <glow::Context as HasContext>::UniformLocation,
sampler: <glow::Context as HasContext>::UniformLocation,
cache: Cache, cache: Cache,
current_instances: usize, current_instances: usize,
supported_instances: usize, supported_instances: usize,
@ -55,6 +54,8 @@ impl Pipeline {
unsafe { unsafe {
gl.use_program(Some(program)); gl.use_program(Some(program));
gl.uniform_1_i32(Some(sampler), 0);
gl.uniform_matrix_4_f32_slice( gl.uniform_matrix_4_f32_slice(
Some(transform), Some(transform),
false, false,
@ -70,7 +71,6 @@ impl Pipeline {
vertex_array, vertex_array,
instances, instances,
transform, transform,
sampler,
current_instances: 0, current_instances: 0,
supported_instances: Instance::INITIAL_AMOUNT, supported_instances: Instance::INITIAL_AMOUNT,
current_transform: IDENTITY_MATRIX, current_transform: IDENTITY_MATRIX,
@ -112,7 +112,6 @@ impl Pipeline {
gl.active_texture(glow::TEXTURE0); gl.active_texture(glow::TEXTURE0);
gl.bind_texture(glow::TEXTURE_2D, Some(self.cache.texture)); gl.bind_texture(glow::TEXTURE_2D, Some(self.cache.texture));
gl.uniform_1_i32(Some(self.sampler), 0);
gl.bind_vertex_array(Some(self.vertex_array)); gl.bind_vertex_array(Some(self.vertex_array));