aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralaric <alaric@netmythos.org>2024-04-14 23:30:48 -0700
committeralaric <alaric@netmythos.org>2024-04-14 23:30:48 -0700
commit12e98a4c9224046ab546bb87befa5fff6050d3ca (patch)
tree13800b023f1430f951c9a9926eccf8856f2265ac
parentbcde32b414b7bc8b2c175d611ec818a88cb183a2 (diff)
downloadengine-12e98a4c9224046ab546bb87befa5fff6050d3ca.tar.gz
engine-12e98a4c9224046ab546bb87befa5fff6050d3ca.zip
feat!: distinguish between vec4 and trunc vec4
Some shaders call for a vec4 input attribute where you only write to the first three values, relying on opengl's behaviour of populating the W column with 1 for various types of matrix math. Other shaders will want to writ to all 4 columns. Since writing to all the columns is the more intuitive choice when specifying an input attribute as vec4, that has been made the default, while vec4_truncated is now the choice if you only want to write 3 out of the 4 values. vec4_truncated is an awful name though and when a better one occurs to me I will change it.
-rw-r--r--src/webgl.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/webgl.zig b/src/webgl.zig
index 934ae3c..fa4198c 100644
--- a/src/webgl.zig
+++ b/src/webgl.zig
@@ -30,7 +30,7 @@ const UniformInfo = struct {
const AttributeInfo = struct {
identifier: [:0]const u8,
shader_name: []const u8,
- kind: enum { f32, vec2, vec3, vec4 },
+ kind: enum { f32, vec2, vec3, vec4, vec4_truncated },
instance_divisor: ?u16 = null,
};
@@ -207,10 +207,11 @@ pub fn Program(
const size = switch (attr_info.kind) {
.f32 => 1,
.vec2 => 2,
- .vec3, .vec4 => 3,
+ .vec3, .vec4_truncated => 3,
+ .vec4 => 4,
};
const a_type = switch (attr_info.kind) {
- .f32, .vec2, .vec3, .vec4 => .f32,
+ .f32, .vec2, .vec3, .vec4, .vec4_truncated => .f32,
};
const normalize = .false;
const stride = 0;