Skip to content

Conversation

@LukaTD
Copy link
Contributor

@LukaTD LukaTD commented Nov 4, 2025

The last of OpenGL 1.5 wrapper functions.

@hazeycode hazeycode requested a review from Copilot November 6, 2025 00:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds wrapper functions for OpenGL 1.5 buffer query and mapping operations. The changes introduce type-safe Zig wrappers around the low-level OpenGL buffer management APIs.

  • Adds new enum types (Access, BufferParameter, BufferPointerParameter) for buffer-related parameters
  • Implements wrapper functions for buffer queries (isBuffer, getBufferParameteriv, getBufferPointerv, getBufferSubData)
  • Implements buffer mapping functions (mapBuffer, unmapBuffer)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2702 to +2709
size: usize,
data: ?[*]u8,
) void {
bindings.getBufferSubData(
@intFromEnum(target),
@as(Intptr, @bitCast(offset)),
@as(Sizeiptr, @bitCast(size)),
data,
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter type ?[*]u8 allows null but doesn't allow the user to specify the length of the buffer, which could lead to buffer overruns. Consider changing to data: []u8 to match the pattern used in bufferSubData at line 2684, which uses bytes: []const u8. This provides length information and improves safety.

Suggested change
size: usize,
data: ?[*]u8,
) void {
bindings.getBufferSubData(
@intFromEnum(target),
@as(Intptr, @bitCast(offset)),
@as(Sizeiptr, @bitCast(size)),
data,
data: []u8,
) void {
bindings.getBufferSubData(
@intFromEnum(target),
@as(Intptr, @bitCast(offset)),
@as(Sizeiptr, @bitCast(data.len)),
data.ptr,

Copilot uses AI. Check for mistakes.
Comment on lines +2724 to +2730
pub fn getBufferParameteriv(target: BufferTarget, pname: BufferParameter, params: []i32) void {
bindings.getBufferParameteriv(
@intFromEnum(target),
@intFromEnum(pname),
@as([*c]Int, @ptrCast(params.ptr)),
);
}
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function accepts a slice params: []i32 but doesn't validate that it has sufficient length for the requested parameter. Different BufferParameter values require different numbers of elements (e.g., buffer_size needs 1 element). Consider documenting the expected slice length for each parameter or adding runtime validation to prevent buffer underruns.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant