Skip to content

Commit

Permalink
Use OpenGL's types instead of c_long, on windows these are defined as…
Browse files Browse the repository at this point in the history
… c_longlong.

Might fix some problems maybe?
  • Loading branch information
IntegratedQuantum committed Apr 18, 2024
1 parent f0d8e8e commit 22a482e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/graphics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ pub fn LargeBuffer(comptime Entry: type) type {
self.ssbo = SSBO.init();
c.glBindBuffer(c.GL_SHADER_STORAGE_BUFFER, self.ssbo.bufferID);
const flags = c.GL_MAP_WRITE_BIT | c.GL_DYNAMIC_STORAGE_BIT;
const bytes = @as(c_long, size)*@sizeOf(Entry);
const bytes = @as(c.GLsizeiptr, size)*@sizeOf(Entry);
c.glBufferStorage(c.GL_SHADER_STORAGE_BUFFER, bytes, null, flags);
self.ssbo.bind(self.binding);
self.capacity = size;
Expand Down Expand Up @@ -1299,7 +1299,7 @@ pub fn LargeBuffer(comptime Entry: type) type {

c.glBindBuffer(c.GL_COPY_READ_BUFFER, oldBuffer.bufferID);
c.glBindBuffer(c.GL_COPY_WRITE_BUFFER, self.ssbo.bufferID);
c.glCopyBufferSubData(c.GL_COPY_READ_BUFFER, c.GL_COPY_WRITE_BUFFER, 0, 0, @as(c_long, oldCapacity)*@sizeOf(Entry));
c.glCopyBufferSubData(c.GL_COPY_READ_BUFFER, c.GL_COPY_WRITE_BUFFER, 0, 0, @as(c.GLsizeiptr, oldCapacity)*@sizeOf(Entry));
return alloc(self, size);
}
}
Expand Down Expand Up @@ -1339,7 +1339,7 @@ pub fn LargeBuffer(comptime Entry: type) type {
allocation.* = self.alloc(@intCast(len));
c.glBindBuffer(c.GL_SHADER_STORAGE_BUFFER, self.ssbo.bufferID);
const ptr: [*]Entry = @ptrCast(@alignCast(
c.glMapBufferRange(c.GL_SHADER_STORAGE_BUFFER, @as(c_long, allocation.start)*@sizeOf(Entry), @as(c_long, allocation.len)*@sizeOf(Entry), c.GL_MAP_WRITE_BIT | c.GL_MAP_INVALIDATE_RANGE_BIT)
c.glMapBufferRange(c.GL_SHADER_STORAGE_BUFFER, @as(c.GLintptr, allocation.start)*@sizeOf(Entry), @as(c.GLsizeiptr, allocation.len)*@sizeOf(Entry), c.GL_MAP_WRITE_BIT | c.GL_MAP_INVALIDATE_RANGE_BIT)
));
return ptr[0..len];
}
Expand All @@ -1359,7 +1359,7 @@ pub fn LargeBuffer(comptime Entry: type) type {
allocation.* = self.alloc(@intCast(data.len));
c.glBindBuffer(c.GL_SHADER_STORAGE_BUFFER, self.ssbo.bufferID);
const ptr: [*]Entry = @ptrCast(@alignCast(
c.glMapBufferRange(c.GL_SHADER_STORAGE_BUFFER, @as(c_long, allocation.start)*@sizeOf(Entry), @as(c_long, allocation.len)*@sizeOf(Entry), c.GL_MAP_WRITE_BIT | c.GL_MAP_INVALIDATE_RANGE_BIT)
c.glMapBufferRange(c.GL_SHADER_STORAGE_BUFFER, @as(c.GLintptr, allocation.start)*@sizeOf(Entry), @as(c.GLsizeiptr, allocation.len)*@sizeOf(Entry), c.GL_MAP_WRITE_BIT | c.GL_MAP_INVALIDATE_RANGE_BIT)
));
@memcpy(ptr, data);
std.debug.assert(c.glUnmapBuffer(c.GL_SHADER_STORAGE_BUFFER) == c.GL_TRUE);
Expand Down

0 comments on commit 22a482e

Please sign in to comment.