Skip to content

Commit

Permalink
Merge pull request #1955 from wez/master
Browse files Browse the repository at this point in the history
Add support for Dual Source Blending
  • Loading branch information
est31 committed Aug 10, 2021
2 parents 2c6caf9 + aed9527 commit a4e0b55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/main.rs
Expand Up @@ -30,6 +30,7 @@ where
"GL_AMD_depth_clamp_separate",
"GL_APPLE_vertex_array_object",
"GL_ARB_bindless_texture",
"GL_ARB_blend_func_extended",
"GL_ARB_buffer_storage",
"GL_ARB_compute_shader",
"GL_ARB_copy_buffer",
Expand Down
21 changes: 21 additions & 0 deletions src/draw_parameters/blend.rs
Expand Up @@ -178,6 +178,22 @@ pub enum LinearBlendingFactor {
/// Multiply the source or destination component by `1.0` minus the alpha value of
/// `Blend::const_value`.
OneMinusConstantAlpha,

/// Multiply the source or destination component by its corresponding value
/// in source index one (you need to explicitly specify `layout(location=0, index=1)`
/// to bind it in your shader.
/// This is useful in Dual Source Blending
/// <https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_blend_func_extended.txt>
SourceOneColor,

/// Equivalent to `1 - SourceOneColor`.
OneMinusSourceOneColor,

/// Multiply the source or destination component by the alpha value of source index 1.
SourceOneAlpha,

/// Multiply the source or destination component by `1.0` minus the alpha value of source index 1.
OneMinusSourceOneAlpha,
}

impl LinearBlendingFactor {
Expand All @@ -198,6 +214,11 @@ impl LinearBlendingFactor {
LinearBlendingFactor::OneMinusConstantColor => gl::ONE_MINUS_CONSTANT_COLOR,
LinearBlendingFactor::ConstantAlpha => gl::CONSTANT_ALPHA,
LinearBlendingFactor::OneMinusConstantAlpha => gl::ONE_MINUS_CONSTANT_ALPHA,
LinearBlendingFactor::SourceOneColor => gl::SRC1_COLOR,
LinearBlendingFactor::OneMinusSourceOneColor => gl::ONE_MINUS_SRC1_COLOR,
LinearBlendingFactor::SourceOneAlpha => gl::SRC1_ALPHA,
LinearBlendingFactor::OneMinusSourceOneAlpha => gl::ONE_MINUS_SRC1_ALPHA,

}
}
}
Expand Down

0 comments on commit a4e0b55

Please sign in to comment.