mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-08 19:47:28 +00:00
Allow passing null pointers to more rlgl functions (#128)
This commit is contained in:
parent
a7f25c615b
commit
da1da5a66c
@ -289,14 +289,23 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
|
||||
|
||||
single_opt = [
|
||||
("rlDrawVertexArrayElements", "buffer"),
|
||||
("rlDrawVertexArrayElementsInstanced", "buffer")
|
||||
("rlDrawVertexArrayElementsInstanced", "buffer"),
|
||||
("rlEnableStatePointer", "buffer"),
|
||||
("rlSetRenderBatchActive", "batch"),
|
||||
("rlLoadTexture", "data"),
|
||||
("rlLoadTextureCubemap", "data"),
|
||||
("rlLoadShaderBuffer", "data"),
|
||||
("rlLoadShaderCode", "vsCode"),
|
||||
("rlLoadShaderCode", "fsCode"),
|
||||
]
|
||||
|
||||
if arg_type.startswith("*") and (func_name, arg_name) in single_opt:
|
||||
arg_type = "?" + arg_type
|
||||
|
||||
zig_type = ziggify_type(arg_name, arg_type, func_name)
|
||||
|
||||
if zig_type.startswith("*") and (func_name, arg_name) in single_opt:
|
||||
if not arg_type.startswith("[*c]"):
|
||||
arg_type = "?" + arg_type
|
||||
zig_type = "?" + zig_type
|
||||
|
||||
zig_types.add(arg_type)
|
||||
zig_c_arguments.append(arg_name + ": " + add_namespace_to_type(arg_type)) # Put everything together.
|
||||
zig_arguments.append(arg_name + ": " + zig_type)
|
||||
|
@ -35,7 +35,7 @@ pub extern "c" fn rlEnableVertexBufferElement(id: c_uint) void;
|
||||
pub extern "c" fn rlDisableVertexBufferElement() void;
|
||||
pub extern "c" fn rlEnableVertexAttribute(index: c_uint) void;
|
||||
pub extern "c" fn rlDisableVertexAttribute(index: c_uint) void;
|
||||
pub extern "c" fn rlEnableStatePointer(vertexAttribType: c_int, buffer: *anyopaque) void;
|
||||
pub extern "c" fn rlEnableStatePointer(vertexAttribType: c_int, buffer: ?*anyopaque) void;
|
||||
pub extern "c" fn rlDisableStatePointer(vertexAttribType: c_int) void;
|
||||
pub extern "c" fn rlActiveTextureSlot(slot: c_int) void;
|
||||
pub extern "c" fn rlEnableTexture(id: c_uint) void;
|
||||
@ -113,9 +113,9 @@ pub extern "c" fn rlDrawVertexArray(offset: c_int, count: c_int) void;
|
||||
pub extern "c" fn rlDrawVertexArrayElements(offset: c_int, count: c_int, buffer: ?*const anyopaque) void;
|
||||
pub extern "c" fn rlDrawVertexArrayInstanced(offset: c_int, count: c_int, instances: c_int) void;
|
||||
pub extern "c" fn rlDrawVertexArrayElementsInstanced(offset: c_int, count: c_int, buffer: ?*const anyopaque, instances: c_int) void;
|
||||
pub extern "c" fn rlLoadTexture(data: *const anyopaque, width: c_int, height: c_int, format: c_int, mipmapCount: c_int) c_uint;
|
||||
pub extern "c" fn rlLoadTexture(data: ?*const anyopaque, width: c_int, height: c_int, format: c_int, mipmapCount: c_int) c_uint;
|
||||
pub extern "c" fn rlLoadTextureDepth(width: c_int, height: c_int, useRenderBuffer: bool) c_uint;
|
||||
pub extern "c" fn rlLoadTextureCubemap(data: *const anyopaque, size: c_int, format: c_int) c_uint;
|
||||
pub extern "c" fn rlLoadTextureCubemap(data: ?*const anyopaque, size: c_int, format: c_int) c_uint;
|
||||
pub extern "c" fn rlUpdateTexture(id: c_uint, offsetX: c_int, offsetY: c_int, width: c_int, height: c_int, format: c_int, data: *const anyopaque) void;
|
||||
pub extern "c" fn rlGetGlTextureFormats(format: c_int, glInternalFormat: [*c]c_uint, glFormat: [*c]c_uint, glType: [*c]c_uint) void;
|
||||
pub extern "c" fn rlGetPixelFormatName(format: c_uint) [*c]const u8;
|
||||
@ -139,7 +139,7 @@ pub extern "c" fn rlSetUniformSampler(locIndex: c_int, textureId: c_uint) void;
|
||||
pub extern "c" fn rlSetShader(id: c_uint, locs: [*c]c_int) void;
|
||||
pub extern "c" fn rlLoadComputeShaderProgram(shaderId: c_uint) c_uint;
|
||||
pub extern "c" fn rlComputeShaderDispatch(groupX: c_uint, groupY: c_uint, groupZ: c_uint) void;
|
||||
pub extern "c" fn rlLoadShaderBuffer(size: c_uint, data: *const anyopaque, usageHint: c_int) c_uint;
|
||||
pub extern "c" fn rlLoadShaderBuffer(size: c_uint, data: ?*const anyopaque, usageHint: c_int) c_uint;
|
||||
pub extern "c" fn rlUnloadShaderBuffer(ssboId: c_uint) void;
|
||||
pub extern "c" fn rlUpdateShaderBuffer(id: c_uint, data: *const anyopaque, dataSize: c_uint, offset: c_uint) void;
|
||||
pub extern "c" fn rlBindShaderBuffer(id: c_uint, index: c_uint) void;
|
||||
|
10
lib/rlgl.zig
10
lib/rlgl.zig
@ -347,7 +347,7 @@ pub fn rlDisableVertexAttribute(index: u32) void {
|
||||
}
|
||||
|
||||
/// Enable attribute state pointer
|
||||
pub fn rlEnableStatePointer(vertexAttribType: i32, buffer: *anyopaque) void {
|
||||
pub fn rlEnableStatePointer(vertexAttribType: i32, buffer: ?*anyopaque) void {
|
||||
cdef.rlEnableStatePointer(@as(c_int, vertexAttribType), buffer);
|
||||
}
|
||||
|
||||
@ -642,7 +642,7 @@ pub fn rlDrawRenderBatch(batch: *rlRenderBatch) void {
|
||||
}
|
||||
|
||||
/// Set the active render batch for rlgl (NULL for default internal)
|
||||
pub fn rlSetRenderBatchActive(batch: *rlRenderBatch) void {
|
||||
pub fn rlSetRenderBatchActive(batch: ?*rlRenderBatch) void {
|
||||
cdef.rlSetRenderBatchActive(@as([*c]rlRenderBatch, @ptrCast(batch)));
|
||||
}
|
||||
|
||||
@ -732,7 +732,7 @@ pub fn rlDrawVertexArrayElementsInstanced(offset: i32, count: i32, buffer: ?*con
|
||||
}
|
||||
|
||||
/// Load texture data
|
||||
pub fn rlLoadTexture(data: *const anyopaque, width: i32, height: i32, format: i32, mipmapCount: i32) u32 {
|
||||
pub fn rlLoadTexture(data: ?*const anyopaque, width: i32, height: i32, format: i32, mipmapCount: i32) u32 {
|
||||
return @as(u32, cdef.rlLoadTexture(data, @as(c_int, width), @as(c_int, height), @as(c_int, format), @as(c_int, mipmapCount)));
|
||||
}
|
||||
|
||||
@ -742,7 +742,7 @@ pub fn rlLoadTextureDepth(width: i32, height: i32, useRenderBuffer: bool) u32 {
|
||||
}
|
||||
|
||||
/// Load texture cubemap data
|
||||
pub fn rlLoadTextureCubemap(data: *const anyopaque, size: i32, format: i32) u32 {
|
||||
pub fn rlLoadTextureCubemap(data: ?*const anyopaque, size: i32, format: i32) u32 {
|
||||
return @as(u32, cdef.rlLoadTextureCubemap(data, @as(c_int, size), @as(c_int, format)));
|
||||
}
|
||||
|
||||
@ -862,7 +862,7 @@ pub fn rlComputeShaderDispatch(groupX: u32, groupY: u32, groupZ: u32) void {
|
||||
}
|
||||
|
||||
/// Load shader storage buffer object (SSBO)
|
||||
pub fn rlLoadShaderBuffer(size: u32, data: *const anyopaque, usageHint: i32) u32 {
|
||||
pub fn rlLoadShaderBuffer(size: u32, data: ?*const anyopaque, usageHint: i32) u32 {
|
||||
return @as(u32, cdef.rlLoadShaderBuffer(@as(c_uint, size), data, @as(c_int, usageHint)));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user