ziglibs / zgl

Zig OpenGL Wrapper
MIT License
425 stars 62 forks source link

Inability to pass null to bufferData/namedBufferData #23

Closed silversquirl closed 3 years ago

silversquirl commented 3 years ago

A null pointer can be used to create an uninitialized buffer, however zgl's wrappers do not support this. I propose changing the signatures like this:

pub fn bufferData(target: BufferTarget, comptime T: type, count: usize, items: ?[*]align(1) const T, usage: BufferUsage)

(and in the corresponding manner for namedBufferData)

This allows passing slices using bufferData(target, T, slice.len, slice.ptr, usage), and allows creating uninitialized buffers using bufferData(target, T, length, null, usage).

This has the disadvantage that the API becomes less clear for the usual case. Another alternative would be to create a separate wrapper function for creating uninitialized buffers, but this seems cluttered to me.