Use ShaderUniformDataType instead of int

This commit is contained in:
Not-Nik 2024-05-31 20:31:58 +02:00
parent a0126d15be
commit 674e5ada11
No known key found for this signature in database
GPG Key ID: E95F679E3CDD9784
4 changed files with 16 additions and 13 deletions

View File

@ -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,
);
//----------------------------------------------------------------------------------

View File

@ -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"

View File

@ -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;

View File

@ -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 {