-
-
Save koljakube/2712be82e38561c56f358bccbd21b1e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Vec3(T) = packed union { Array: [3]T } | |
pub fn cPtr(self: *Self) [*c]f32 { | |
return @ptrCast([*c]f32, @alignCast(@alignOf([*c]f32), self)); | |
} | |
pub fn constCPtr(self: *const Self) [*c]const f32 { | |
return @ptrCast([*c]const f32, @alignCast(@alignOf([*c]const f32), self)); | |
} | |
pub const translate = @ptrCast(fn ([*c][4]f32, [*c]const f32) callconv(.C) void, cc.glmc_translate); | |
pub fn Mat4(comptime T: anytype) type { | |
return packed union { | |
const Self = @This(); | |
const Dimension = 4; | |
const ValueType = T; | |
const Vec3Type = Vec3(T); | |
const Vec4Type = Vec4(T); | |
Array: [Dimension * Dimension]T, | |
Columns: [Dimension]Vec4Type, | |
Vectors: [Dimension]std.meta.Vector(Dimension, T), | |
pub fn translate(self: *Self, v: Vec3Type) void { | |
// @compileLog(@typeName(@TypeOf(cglm_call.translate))); | |
// @compileLog(@typeInfo(@TypeOf(&v)).Pointer.is_const); | |
translate(self.cPtr(), @intToPtr([*c]const f32, @ptrToInt(Vec3Type.constCPtr(&v)))); | |
} | |
pub inline fn cPtr(self: *Self) [*c][4]T { | |
return @ptrCast([*c][4]T, @alignCast(@alignOf([*c][4]T), self)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/src/math/mat4.zig:60:46: error: cast discards const qualifier | |
cglm_call.translate(self.cPtr(), @intToPtr([*c]const f32, @ptrToInt(Vec3Type.constCPtr(&v)))); | |
^ | |
./src/math/mat4.zig:60:32: note: referenced here | |
cglm_call.translate(self.cPtr(), @intToPtr([*c]const f32, @ptrToInt(Vec3Type.constCPtr(&v)))); | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment