Fix ctypes binding for load_shader.

This commit is contained in:
Roz K 2022-12-04 03:16:01 +01:00
parent 7e015fda86
commit af25548752
Signed by: roz
GPG Key ID: 51FBF4E483E1C822

View File

@ -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 = (