diff options
| author | tslil clingman <> | 2021-10-27 15:37:28 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2021-10-27 15:37:28 -0400 |
| commit | 48dee0817f5fe8c09a085f0150e0c6b4a699ab7c (patch) | |
| tree | d6ab0a54f2260cb73c79e00ca1489c034f555f09 /src/sfml/graphics/BlendMode.zig | |
| parent | 486935299e4b7e097754611d9f8dd40003351ae4 (diff) | |
Update SFML wrapper
Diffstat (limited to 'src/sfml/graphics/BlendMode.zig')
| -rw-r--r-- | src/sfml/graphics/BlendMode.zig | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/sfml/graphics/BlendMode.zig b/src/sfml/graphics/BlendMode.zig new file mode 100644 index 0000000..d78d60d --- /dev/null +++ b/src/sfml/graphics/BlendMode.zig @@ -0,0 +1,92 @@ +//! Blending modes for drawing (for render states) + +// Enums +pub const Factor = enum(c_int) { + zero, + one, + srcColor, + oneMinusSrcColor, + dstColor, + oneMinusDstColor, + srcAlpha, + oneMinusSrcAlpha, + dstAlpha, + oneMinusDstAlpha +}; + +pub const Equation = enum(c_int) { + add, + subtract, + reverseSubtract +}; + +const BlendMode = @This(); + +// Preset blend modes +pub const BlendAlpha = BlendMode{ + .color_src_factor = .srcAlpha, + .color_dst_factor = .oneMinusSrcAlpha, + .color_equation = .add, + .alpha_src_factor = .one, + .alpha_dst_factor = .oneMinusSrcAlpha, + .alpha_equation = .add +}; + +pub const BlendAdd = BlendMode{ + .color_src_factor = .srcAlpha, + .color_dst_factor = .one, + .color_equation = .add, + .alpha_src_factor = .one, + .alpha_dst_factor = .one, + .alpha_equation = .add +}; + +pub const BlendMultiply = BlendMode{ + .color_src_factor = .dstColor, + .color_dst_factor = .zero, + .color_equation = .add, + .alpha_src_factor = .dstColor, + .alpha_dst_factor = .zero, + .alpha_equation = .add +}; + +pub const BlendMin = BlendMode{ + .color_src_factor = .one, + .color_dst_factor = .one, + .color_equation = .min, + .alpha_src_factor = .one, + .alpha_dst_factor = .one, + .alpha_equation = .min +}; + +pub const BlendMax = BlendMode{ + .color_src_factor = .one, + .color_dst_factor = .one, + .color_equation = .max, + .alpha_src_factor = .one, + .alpha_dst_factor = .one, + .alpha_equation = .max +}; + +pub const BlendNone = BlendMode{ + .color_src_factor = .one, + .color_dst_factor = .zero, + .color_equation = .add, + .alpha_src_factor = .one, + .alpha_dst_factor = .zero, + .alpha_equation = .add +}; + +const sfBlendMode = @import("../sfml_import.zig").c.sfBlendMode; +/// Bitcasts this blendmode to the csfml struct +/// For inner workings +pub fn _toCSFML(self: BlendMode) sfBlendMode { + return @bitCast(sfBlendMode, self); +} + +color_src_factor: Factor, +color_dst_factor: Factor, +color_equation: Equation, +alpha_src_factor: Factor, +alpha_dst_factor: Factor, +alpha_equation: Equation
\ No newline at end of file |
