opengl: setting buffer data with array must get proper pointer

This finally gets the terminal compiling with the self-hosted Zig
compiler! Wow! And this was one of those things that... should've never
worked.
This commit is contained in:
Mitchell Hashimoto
2022-10-15 11:29:25 -07:00
parent c681a197d2
commit 2d10ac0a77

View File

@ -40,7 +40,7 @@ pub const Binding = struct {
data: anytype, data: anytype,
usage: Usage, usage: Usage,
) !void { ) !void {
const info = dataInfo(data); const info = dataInfo(&data);
c.glBufferData(@enumToInt(b.target), info.size, info.ptr, @enumToInt(usage)); c.glBufferData(@enumToInt(b.target), info.size, info.ptr, @enumToInt(usage));
try errors.getError(); try errors.getError();
} }
@ -84,10 +84,6 @@ pub const Binding = struct {
ptr: *const anyopaque, ptr: *const anyopaque,
} { } {
return switch (@typeInfo(@TypeOf(data))) { return switch (@typeInfo(@TypeOf(data))) {
.Array => .{
.size = @sizeOf(@TypeOf(data)),
.ptr = &data,
},
.Pointer => |ptr| switch (ptr.size) { .Pointer => |ptr| switch (ptr.size) {
.One => .{ .One => .{
.size = @sizeOf(ptr.child) * data.len, .size = @sizeOf(ptr.child) * data.len,