automatically deref pointers in pyray
This commit is contained in:
parent
6854ec4a3e
commit
26e9f9cbf2
2 changed files with 6 additions and 4 deletions
|
@ -9,14 +9,16 @@ class PyRay:
|
|||
|
||||
|
||||
def makefunc(a):
|
||||
#print("makefunc ",a)
|
||||
#print("makefunc ",a, ffi.typeof(a).args)
|
||||
def func(self, *args):
|
||||
modified_args = []
|
||||
for arg in args:
|
||||
#print(arg, type(arg))
|
||||
for (c_arg, arg) in zip(ffi.typeof(a).args, args):
|
||||
#print(arg, c_arg.kind)
|
||||
if type(arg) == str:
|
||||
encoded = arg.encode('utf-8')
|
||||
modified_args.append(encoded)
|
||||
elif c_arg.kind == 'pointer':
|
||||
modified_args.append(ffi.addressof(arg))
|
||||
else:
|
||||
modified_args.append(arg)
|
||||
return a(*modified_args)
|
||||
|
|
|
@ -26,7 +26,7 @@ rayhit = pyray.get_collision_ray_ground(ray, 0)
|
|||
print(str(rayhit.position.x))
|
||||
|
||||
while not pyray.window_should_close():
|
||||
pyray.update_camera(pyray.pointer(camera))
|
||||
pyray.update_camera(camera)
|
||||
pyray.begin_drawing()
|
||||
pyray.clear_background(RAYWHITE)
|
||||
pyray.begin_mode_3d(camera)
|
||||
|
|
Reference in a new issue