1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00

Remove unused coordinate from rect shader

This commit is contained in:
M. Stoeckl 2019-02-03 16:45:09 +00:00 committed by Christian Duerr
parent 20f3198609
commit 3f0d11381d
3 changed files with 15 additions and 19 deletions

View file

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#version 330 core #version 330 core
in vec4 color;
uniform vec4 color;
out vec4 FragColor; out vec4 FragColor;

View file

@ -12,14 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#version 330 core #version 330 core
layout (location = 0) in vec3 aPos; layout (location = 0) in vec2 aPos;
out vec4 color;
uniform vec4 col;
void main() void main()
{ {
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0); gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0);
color = col;
} }

View file

@ -134,7 +134,7 @@ pub struct RectShaderProgram {
// Program id // Program id
id: GLuint, id: GLuint,
/// Rectangle color /// Rectangle color
u_col: GLint, u_color: GLint,
} }
#[derive(Copy, Debug, Clone)] #[derive(Copy, Debug, Clone)]
@ -720,7 +720,7 @@ impl QuadRenderer {
gl::BindBuffer(gl::ARRAY_BUFFER, self.rect_vbo); gl::BindBuffer(gl::ARRAY_BUFFER, self.rect_vbo);
// Position // Position
gl::VertexAttribPointer(0, 3, gl::FLOAT, gl::FALSE, (size_of::<f32>() * 3) as _, ptr::null()); gl::VertexAttribPointer(0, 2, gl::FLOAT, gl::FALSE, (size_of::<f32>() * 2) as _, ptr::null());
gl::EnableVertexAttribArray(0); gl::EnableVertexAttribArray(0);
} }
@ -876,11 +876,11 @@ impl QuadRenderer {
unsafe { unsafe {
// Setup vertices // Setup vertices
let vertices: [f32; 12] = [ let vertices: [f32; 8] = [
x + width, y , 0.0, x + width, y ,
x + width, y - height, 0.0, x + width, y - height,
x , y - height, 0.0, x , y - height,
x , y , 0.0, x , y ,
]; ];
// Load vertex data into array buffer // Load vertex data into array buffer
@ -1285,13 +1285,13 @@ impl RectShaderProgram {
} }
// get uniform locations // get uniform locations
let u_col = unsafe { let u_color = unsafe {
gl::GetUniformLocation(program, b"col\0".as_ptr() as *const _) gl::GetUniformLocation(program, b"color\0".as_ptr() as *const _)
}; };
let shader = RectShaderProgram { let shader = RectShaderProgram {
id: program, id: program,
u_col, u_color,
}; };
unsafe { gl::UseProgram(0) } unsafe { gl::UseProgram(0) }
@ -1302,7 +1302,7 @@ impl RectShaderProgram {
fn set_color(&self, color: Rgb, alpha: f32) { fn set_color(&self, color: Rgb, alpha: f32) {
unsafe { unsafe {
gl::Uniform4f( gl::Uniform4f(
self.u_col, self.u_color,
f32::from(color.r) / 255., f32::from(color.r) / 255.,
f32::from(color.g) / 255., f32::from(color.g) / 255.,
f32::from(color.b) / 255., f32::from(color.b) / 255.,