remove redundant pointer casts in shader code
Browse files at this commit5fc669c2824d0101ce2d1740a2a502b6c34be54cParent: 9b78b151 changed file +19 -45
src/render_helpers/shader_element.rsmodified+19 -45
| @@ -88,26 +88,19 @@ unsafe fn compile_program( | |||
| 88 | Ok(ShaderProgram(Rc::new(ShaderProgramInner { | 88 | Ok(ShaderProgram(Rc::new(ShaderProgramInner { |
| 89 | normal: ShaderProgramInternal { | 89 | normal: ShaderProgramInternal { |
| 90 | program, | 90 | program, |
| 91 | - uniform_matrix: gl | 91 | + uniform_matrix: gl.GetUniformLocation(program, matrix.as_ptr()), |
| 92 | - .GetUniformLocation(program, matrix.as_ptr() as *const ffi::types::GLchar), | 92 | + uniform_tex_matrix: gl.GetUniformLocation(program, tex_matrix.as_ptr()), |
| 93 | - uniform_tex_matrix: gl | 93 | + uniform_size: gl.GetUniformLocation(program, size.as_ptr()), |
| 94 | - .GetUniformLocation(program, tex_matrix.as_ptr() as *const ffi::types::GLchar), | 94 | + uniform_scale: gl.GetUniformLocation(program, scale.as_ptr()), |
| 95 | - uniform_size: gl | 95 | + uniform_alpha: gl.GetUniformLocation(program, alpha.as_ptr()), |
| 96 | - .GetUniformLocation(program, size.as_ptr() as *const ffi::types::GLchar), | 96 | + attrib_vert: gl.GetAttribLocation(program, vert.as_ptr()), |
| 97 | - uniform_scale: gl | 97 | + attrib_vert_position: gl.GetAttribLocation(program, vert_position.as_ptr()), |
| 98 | - .GetUniformLocation(program, scale.as_ptr() as *const ffi::types::GLchar), | ||
| 99 | - uniform_alpha: gl | ||
| 100 | - .GetUniformLocation(program, alpha.as_ptr() as *const ffi::types::GLchar), | ||
| 101 | - attrib_vert: gl.GetAttribLocation(program, vert.as_ptr() as *const ffi::types::GLchar), | ||
| 102 | - attrib_vert_position: gl | ||
| 103 | - .GetAttribLocation(program, vert_position.as_ptr() as *const ffi::types::GLchar), | ||
| 104 | additional_uniforms: additional_uniforms | 98 | additional_uniforms: additional_uniforms |
| 105 | .iter() | 99 | .iter() |
| 106 | .map(|uniform| { | 100 | .map(|uniform| { |
| 107 | let name = | 101 | let name = |
| 108 | CString::new(uniform.name.as_bytes()).expect("Interior null in name"); | 102 | CString::new(uniform.name.as_bytes()).expect("Interior null in name"); |
| 109 | - let location = | 103 | + let location = gl.GetUniformLocation(program, name.as_ptr()); |
| 110 | - gl.GetUniformLocation(program, name.as_ptr() as *const ffi::types::GLchar); | ||
| 111 | ( | 104 | ( |
| 112 | uniform.name.clone().into_owned(), | 105 | uniform.name.clone().into_owned(), |
| 113 | UniformDesc { | 106 | UniformDesc { |
| @@ -121,41 +114,26 @@ unsafe fn compile_program( | |||
| 121 | .iter() | 114 | .iter() |
| 122 | .map(|name_| { | 115 | .map(|name_| { |
| 123 | let name = CString::new(name_.as_bytes()).expect("Interior null in name"); | 116 | let name = CString::new(name_.as_bytes()).expect("Interior null in name"); |
| 124 | - let location = | 117 | + let location = gl.GetUniformLocation(program, name.as_ptr()); |
| 125 | - gl.GetUniformLocation(program, name.as_ptr() as *const ffi::types::GLchar); | ||
| 126 | (name_.to_string(), location) | 118 | (name_.to_string(), location) |
| 127 | }) | 119 | }) |
| 128 | .collect(), | 120 | .collect(), |
| 129 | }, | 121 | }, |
| 130 | debug: ShaderProgramInternal { | 122 | debug: ShaderProgramInternal { |
| 131 | program: debug_program, | 123 | program: debug_program, |
| 132 | - uniform_matrix: gl | 124 | + uniform_matrix: gl.GetUniformLocation(debug_program, matrix.as_ptr()), |
| 133 | - .GetUniformLocation(debug_program, matrix.as_ptr() as *const ffi::types::GLchar), | 125 | + uniform_tex_matrix: gl.GetUniformLocation(debug_program, tex_matrix.as_ptr()), |
| 134 | - uniform_tex_matrix: gl.GetUniformLocation( | 126 | + uniform_size: gl.GetUniformLocation(debug_program, size.as_ptr()), |
| 135 | - debug_program, | 127 | + uniform_scale: gl.GetUniformLocation(debug_program, scale.as_ptr()), |
| 136 | - tex_matrix.as_ptr() as *const ffi::types::GLchar, | 128 | + uniform_alpha: gl.GetUniformLocation(debug_program, alpha.as_ptr()), |
| 137 | - ), | 129 | + attrib_vert: gl.GetAttribLocation(debug_program, vert.as_ptr()), |
| 138 | - uniform_size: gl | 130 | + attrib_vert_position: gl.GetAttribLocation(debug_program, vert_position.as_ptr()), |
| 139 | - .GetUniformLocation(debug_program, size.as_ptr() as *const ffi::types::GLchar), | ||
| 140 | - uniform_scale: gl | ||
| 141 | - .GetUniformLocation(debug_program, scale.as_ptr() as *const ffi::types::GLchar), | ||
| 142 | - uniform_alpha: gl | ||
| 143 | - .GetUniformLocation(debug_program, alpha.as_ptr() as *const ffi::types::GLchar), | ||
| 144 | - attrib_vert: gl | ||
| 145 | - .GetAttribLocation(debug_program, vert.as_ptr() as *const ffi::types::GLchar), | ||
| 146 | - attrib_vert_position: gl.GetAttribLocation( | ||
| 147 | - debug_program, | ||
| 148 | - vert_position.as_ptr() as *const ffi::types::GLchar, | ||
| 149 | - ), | ||
| 150 | additional_uniforms: additional_uniforms | 131 | additional_uniforms: additional_uniforms |
| 151 | .iter() | 132 | .iter() |
| 152 | .map(|uniform| { | 133 | .map(|uniform| { |
| 153 | let name = | 134 | let name = |
| 154 | CString::new(uniform.name.as_bytes()).expect("Interior null in name"); | 135 | CString::new(uniform.name.as_bytes()).expect("Interior null in name"); |
| 155 | - let location = gl.GetUniformLocation( | 136 | + let location = gl.GetUniformLocation(debug_program, name.as_ptr()); |
| 156 | - debug_program, | ||
| 157 | - name.as_ptr() as *const ffi::types::GLchar, | ||
| 158 | - ); | ||
| 159 | ( | 137 | ( |
| 160 | uniform.name.clone().into_owned(), | 138 | uniform.name.clone().into_owned(), |
| 161 | UniformDesc { | 139 | UniformDesc { |
| @@ -169,16 +147,12 @@ unsafe fn compile_program( | |||
| 169 | .iter() | 147 | .iter() |
| 170 | .map(|name_| { | 148 | .map(|name_| { |
| 171 | let name = CString::new(name_.as_bytes()).expect("Interior null in name"); | 149 | let name = CString::new(name_.as_bytes()).expect("Interior null in name"); |
| 172 | - let location = gl.GetUniformLocation( | 150 | + let location = gl.GetUniformLocation(debug_program, name.as_ptr()); |
| 173 | - debug_program, | ||
| 174 | - name.as_ptr() as *const ffi::types::GLchar, | ||
| 175 | - ); | ||
| 176 | (name_.to_string(), location) | 151 | (name_.to_string(), location) |
| 177 | }) | 152 | }) |
| 178 | .collect(), | 153 | .collect(), |
| 179 | }, | 154 | }, |
| 180 | - uniform_tint: gl | 155 | + uniform_tint: gl.GetUniformLocation(debug_program, tint.as_ptr()), |
| 181 | - .GetUniformLocation(debug_program, tint.as_ptr() as *const ffi::types::GLchar), | ||
| 182 | }))) | 156 | }))) |
| 183 | } | 157 | } |
| 184 | 158 | ||