Skip to content

Instantly share code, notes, and snippets.

@blackle
Last active June 17, 2019 14:44
Show Gist options
  • Save blackle/2c37f262ef9fe20a34e4b1423068fa5d to your computer and use it in GitHub Desktop.
Save blackle/2c37f262ef9fe20a34e4b1423068fa5d to your computer and use it in GitHub Desktop.
Open a shader in a window with ctypes and libclutter
#!/usr/bin/env python3
from ctypes import *
L=CDLL("libc.so.6")
C=CDLL("libclutter-1.0.so.0")
G=CDLL("libgobject-2.0.so.0")
def K(F,*V):
F.restype=c_void_p
F.argtypes=[c_void_p]*len(V)
return F(*V)
K(C.clutter_init,0)
ST=K(C.clutter_stage_new)
SH=K(C.clutter_shader_effect_new,1)
K(C.clutter_shader_effect_set_shader_source,SH,b"void main(){cogl_color_out=vec4(cogl_tex_coord_in[0].xyx,1.);}")
K(C.clutter_actor_add_effect,ST,SH)
K(G.g_signal_connect_data,ST,b"delete-event",C.clutter_main_quit,0,0,0)
K(L.signal,2,C.clutter_main_quit)
K(C.clutter_actor_show,ST)
K(C.clutter_main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment