From 674e5ada11c116e1eb0313c9121ba1d44797eab7 Mon Sep 17 00:00:00 2001 From: Not-Nik Date: Fri, 31 May 2024 20:31:58 +0200 Subject: [PATCH] Use ShaderUniformDataType instead of int --- examples/shaders/texture_outline.zig | 8 ++++---- lib/generate_functions.py | 9 ++++++--- lib/raylib-ext.zig | 4 ++-- lib/raylib.zig | 8 ++++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/examples/shaders/texture_outline.zig b/examples/shaders/texture_outline.zig index b682b74..0fc97c7 100644 --- a/examples/shaders/texture_outline.zig +++ b/examples/shaders/texture_outline.zig @@ -38,19 +38,19 @@ pub fn main() anyerror!void { shdrOutline, outlineSizeLoc, &outlineSize, - @intFromEnum(rl.ShaderUniformDataType.shader_uniform_float), + rl.ShaderUniformDataType.shader_uniform_float, ); rl.setShaderValue( shdrOutline, outlineColorLoc, &outlineColor, - @intFromEnum(rl.ShaderUniformDataType.shader_uniform_vec4), + rl.ShaderUniformDataType.shader_uniform_vec4, ); rl.setShaderValue( shdrOutline, textureSizeLoc, &textureSize, - @intFromEnum(rl.ShaderUniformDataType.shader_uniform_vec2), + rl.ShaderUniformDataType.shader_uniform_vec2, ); rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second @@ -67,7 +67,7 @@ pub fn main() anyerror!void { shdrOutline, outlineSizeLoc, &outlineSize, - @intFromEnum(rl.ShaderUniformDataType.shader_uniform_float), + rl.ShaderUniformDataType.shader_uniform_float, ); //---------------------------------------------------------------------------------- diff --git a/lib/generate_functions.py b/lib/generate_functions.py index 74328a6..6d26076 100644 --- a/lib/generate_functions.py +++ b/lib/generate_functions.py @@ -148,6 +148,9 @@ def fix_pointer(name: str, t: str): def fix_enums(arg_name, arg_type, func_name): + if func_name.startswith("rl"): + return arg_type + # Hacking specific enums in here. # Raylib doesn't use the enums but rather the resulting ints. if arg_type == "int" or arg_type == "unsigned int": @@ -174,9 +177,9 @@ def fix_enums(arg_name, arg_type, func_name): arg_type = "Gesture" elif arg_name == "logLevel": arg_type = "TraceLogLevel" - elif arg_name == "ty" and not func_name.startswith("rl"): + elif arg_name == "ty": arg_type = "FontType" - elif arg_name == "UniformType": + elif arg_name == "uniformType": arg_type = "ShaderUniformDataType" elif arg_name == "Cursor": arg_type = "MouseCursor" @@ -188,7 +191,7 @@ def fix_enums(arg_name, arg_type, func_name): arg_type = "TextureFilter" elif arg_name == "TextureWrap": arg_type = "TextureWrap" - elif arg_name == "format" and not func_name.startswith("rl"): + elif arg_name == "format": arg_type = "PixelFormat" elif arg_name == "mapType": arg_type = "MaterialMapIndex" diff --git a/lib/raylib-ext.zig b/lib/raylib-ext.zig index b7dc1d3..1061140 100644 --- a/lib/raylib-ext.zig +++ b/lib/raylib-ext.zig @@ -80,8 +80,8 @@ pub extern "c" fn LoadShaderFromMemory(vsCode: [*c]const u8, fsCode: [*c]const u pub extern "c" fn IsShaderReady(shader: rl.Shader) bool; pub extern "c" fn GetShaderLocation(shader: rl.Shader, uniformName: [*c]const u8) c_int; pub extern "c" fn GetShaderLocationAttrib(shader: rl.Shader, attribName: [*c]const u8) c_int; -pub extern "c" fn SetShaderValue(shader: rl.Shader, locIndex: c_int, value: *const anyopaque, uniformType: c_int) void; -pub extern "c" fn SetShaderValueV(shader: rl.Shader, locIndex: c_int, value: *const anyopaque, uniformType: c_int, count: c_int) void; +pub extern "c" fn SetShaderValue(shader: rl.Shader, locIndex: c_int, value: *const anyopaque, uniformType: rl.ShaderUniformDataType) void; +pub extern "c" fn SetShaderValueV(shader: rl.Shader, locIndex: c_int, value: *const anyopaque, uniformType: rl.ShaderUniformDataType, count: c_int) void; pub extern "c" fn SetShaderValueMatrix(shader: rl.Shader, locIndex: c_int, mat: rl.Matrix) void; pub extern "c" fn SetShaderValueTexture(shader: rl.Shader, locIndex: c_int, texture: rl.Texture2D) void; pub extern "c" fn UnloadShader(shader: rl.Shader) void; diff --git a/lib/raylib.zig b/lib/raylib.zig index c883ba1..5ec94fc 100644 --- a/lib/raylib.zig +++ b/lib/raylib.zig @@ -1775,12 +1775,12 @@ pub fn getShaderLocationAttrib(shader: Shader, attribName: [:0]const u8) i32 { return @as(i32, cdef.GetShaderLocationAttrib(shader, @as([*c]const u8, @ptrCast(attribName)))); } -pub fn setShaderValue(shader: Shader, locIndex: i32, value: *const anyopaque, uniformType: i32) void { - cdef.SetShaderValue(shader, @as(c_int, locIndex), value, @as(c_int, uniformType)); +pub fn setShaderValue(shader: Shader, locIndex: i32, value: *const anyopaque, uniformType: ShaderUniformDataType) void { + cdef.SetShaderValue(shader, @as(c_int, locIndex), value, uniformType); } -pub fn setShaderValueV(shader: Shader, locIndex: i32, value: *const anyopaque, uniformType: i32, count: i32) void { - cdef.SetShaderValueV(shader, @as(c_int, locIndex), value, @as(c_int, uniformType), @as(c_int, count)); +pub fn setShaderValueV(shader: Shader, locIndex: i32, value: *const anyopaque, uniformType: ShaderUniformDataType, count: i32) void { + cdef.SetShaderValueV(shader, @as(c_int, locIndex), value, uniformType, @as(c_int, count)); } pub fn setShaderValueMatrix(shader: Shader, locIndex: i32, mat: Matrix) void {