From af25548752d7ae7004a937307e06bd4810e46cc7 Mon Sep 17 00:00:00 2001 From: Roz K Date: Sun, 4 Dec 2022 03:16:01 +0100 Subject: [PATCH] Fix ctypes binding for load_shader. --- __init__.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index d1899f0..c8d791f 100644 --- a/__init__.py +++ b/__init__.py @@ -222,11 +222,21 @@ initialize.argtypes = ( _load_shader = _lib.rk_load_shader _load_shader.restype = ctypes.c_void_p _load_shader.argtypes = ( - ctypes.c_char_p,) # name + ctypes.c_uint, # vert_nlines + ctypes.c_void_p, # vert_lines + ctypes.c_uint, # frag_nlines + ctypes.c_void_p) # frag_lines -def load_shader(name): - print("Loading shader", str(name, 'utf-8')); - return _load_shader(name) +def load_shader(vert_lines, frag_lines): + vert_nlines = len(vert_lines) + vert_type = ctypes.c_char_p * vert_nlines + vert_lines = vert_type(*map(ctypes.c_char_p, vert_lines)) + frag_nlines = len(frag_lines) + frag_type = ctypes.c_char_p * frag_nlines + frag_lines = frag_type(*map(ctypes.c_char_p, frag_lines)) + return _load_shader( + vert_nlines, ctypes.addressof(vert_lines), + frag_nlines, ctypes.addressof(frag_lines)) select_shader = _lib.rk_select_shader select_shader.argtypes = (