diff options
author | 2021-11-11 01:10:47 -0300 | |
---|---|---|
committer | 2022-01-19 17:40:17 -0300 | |
commit | e31566d430093fb084da2e7f4f4ed1b66326edef (patch) | |
tree | 328c599dd2d62a32e17e95e792c74054d822537e /glow/src/quad | |
parent | afdf3e799a7610444208c9568a7cf7531d0c2ef3 (diff) | |
download | iced-e31566d430093fb084da2e7f4f4ed1b66326edef.tar.gz iced-e31566d430093fb084da2e7f4f4ed1b66326edef.tar.bz2 iced-e31566d430093fb084da2e7f4f4ed1b66326edef.zip |
Improve shader version selection
Diffstat (limited to 'glow/src/quad')
-rw-r--r-- | glow/src/quad/compatibility.rs | 25 | ||||
-rw-r--r-- | glow/src/quad/core.rs | 25 |
2 files changed, 44 insertions, 6 deletions
diff --git a/glow/src/quad/compatibility.rs b/glow/src/quad/compatibility.rs index e083dcf1..28ad214d 100644 --- a/glow/src/quad/compatibility.rs +++ b/glow/src/quad/compatibility.rs @@ -25,20 +25,39 @@ pub struct Pipeline { } impl Pipeline { - pub fn new(gl: &glow::Context) -> Pipeline { + pub fn new( + gl: &glow::Context, + (vertex_version, fragment_version): &(String, String), + ) -> Pipeline { let program = unsafe { program::create( gl, &[ ( glow::VERTEX_SHADER, - include_str!("../shader/compatibility/quad.vert"), + &format!( + "{}\n{}", + vertex_version, + include_str!("../shader/compatibility/quad.vert") + ), ), ( glow::FRAGMENT_SHADER, - include_str!("../shader/compatibility/quad.frag"), + &format!( + "{}\n{}", + fragment_version, + include_str!("../shader/compatibility/quad.frag") + ), ), ], + &[ + (0, "i_Pos"), + (1, "i_Scale"), + (2, "i_Color"), + (3, "i_BorderColor"), + (4, "i_BorderRadius"), + (5, "i_BorderWidth"), + ], ) }; diff --git a/glow/src/quad/core.rs b/glow/src/quad/core.rs index c843e8c7..274ade67 100644 --- a/glow/src/quad/core.rs +++ b/glow/src/quad/core.rs @@ -20,20 +20,39 @@ pub struct Pipeline { } impl Pipeline { - pub fn new(gl: &glow::Context) -> Pipeline { + pub fn new( + gl: &glow::Context, + (vertex_version, fragment_version): &(String, String), + ) -> Pipeline { let program = unsafe { program::create( gl, &[ ( glow::VERTEX_SHADER, - include_str!("../shader/core/quad.vert"), + &format!( + "{}\n{}", + vertex_version, + include_str!("../shader/core/quad.vert") + ), ), ( glow::FRAGMENT_SHADER, - include_str!("../shader/core/quad.frag"), + &format!( + "{}\n{}", + fragment_version, + include_str!("../shader/core/quad.frag") + ), ), ], + &[ + (0, "i_Pos"), + (1, "i_Scale"), + (2, "i_Color"), + (3, "i_BorderColor"), + (4, "i_BorderRadius"), + (5, "i_BorderWidth"), + ], ) }; |