raylib-python-cffi
raylib-python-cffi copied to clipboard
improve handling of 'out' parameters
Not sure if Raylib uses any of these, but RayGUI certainly does. Currently to use with pyray code looks like this:
import pyray as pr
char_array = pr.ffi.new("char[20]")
pointer = pr.ffi.addressof(char_array)
pr.init_window(800, 600, "raygui")
while not pr.window_should_close():
pr.begin_drawing()
pr.clear_background(pr.RAYWHITE)
pr.gui_text_input_box(pr.Rectangle(0, 0, 800, 600), "title", "message", "buttons", pointer)
string = pr.ffi.string(char_array).decode('utf-8')
pr.draw_text(f"Text entered: {string}", 10, 40, 10, pr.DARKGRAY)
pr.end_drawing()
pr.close_window()
I guess the cleanest solution might be to remove those parameters entirely and replace them with tuple return values, but not sure if that can be done in automated way and I hate to special-case anything.
https://github.com/electronstudio/raylib-python-cffi/issues/121