-
Notifications
You must be signed in to change notification settings - Fork 14
Added missing OpenGL 1.5 buffer functions to wrapper #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
| size: usize, | ||
| data: ?[*]u8, | ||
| ) void { | ||
| bindings.getBufferSubData( | ||
| @intFromEnum(target), | ||
| @as(Intptr, @bitCast(offset)), | ||
| @as(Sizeiptr, @bitCast(size)), | ||
| data, |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
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.
| 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, |
| pub fn getBufferParameteriv(target: BufferTarget, pname: BufferParameter, params: []i32) void { | ||
| bindings.getBufferParameteriv( | ||
| @intFromEnum(target), | ||
| @intFromEnum(pname), | ||
| @as([*c]Int, @ptrCast(params.ptr)), | ||
| ); | ||
| } |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
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.
The last of OpenGL 1.5 wrapper functions.