use typedefs when constructing structs

This commit is contained in:
Richard Smith 2025-05-27 14:53:20 +01:00
parent d3fcb40408
commit 11c5b1a728
2 changed files with 3 additions and 1 deletions

View file

@ -126,7 +126,7 @@ def _make_struct_constructor_function(struct):
or isinstance(arg, (array, bytes, bytearray, memoryview)))): or isinstance(arg, (array, bytes, bytearray, memoryview)))):
arg = ffi.from_buffer(field[1].type, arg) arg = ffi.from_buffer(field[1].type, arg)
modified_args.append(arg) modified_args.append(arg)
s = ffi.new(f"struct {struct} *", modified_args)[0] s = ffi.new(f"{struct} *", modified_args)[0]
global_weakkeydict[s] = modified_args global_weakkeydict[s] = modified_args
return s return s

View file

@ -7,6 +7,8 @@ import pyray as pr
pr.init_window(800, 450, "Raylib texture test") pr.init_window(800, 450, "Raylib texture test")
pr.set_target_fps(60) pr.set_target_fps(60)
test_typedef_init = pr.Texture2D() # Texture2D is typedef for Texture
image = pr.gen_image_color(800, 400, (0,0,0,255) ) image = pr.gen_image_color(800, 400, (0,0,0,255) )
texture = pr.load_texture_from_image(image) texture = pr.load_texture_from_image(image)
pr.update_texture(texture, image.data) pr.update_texture(texture, image.data)