Skip to content

Instantly share code, notes, and snippets.

@PoroCYon
Forked from blackle/clutter.py
Last active June 17, 2019 15:02
Show Gist options
  • Save PoroCYon/705f77c5636a8650d3ceb19df5b0e142 to your computer and use it in GitHub Desktop.
Save PoroCYon/705f77c5636a8650d3ceb19df5b0e142 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*
u=CDLL("libc.so.6")
c=CDLL("libclutter-1.0.so.0")
l=CDLL("libgobject-2.0.so.0")
def t(i,*b):i.restype=c_void_p;i.argtypes=[c_void_p]*len(b);return i(*b)
t(c.clutter_init)
g=t(c.clutter_stage_new)
_=t(c.clutter_shader_effect_new,1)
t(c.clutter_shader_effect_set_shader_source,_,b"void main(){cogl_color_out=vec4(cogl_tex_coord_in[0].xyx,1.);}")
t(c.clutter_actor_add_effect,g,_)
t(l.g_signal_connect_data,g,b"delete-event",c.clutter_main_quit)
t(u.signal,2,c.clutter_main_quit)
t(c.clutter_actor_show,g)
t(c.clutter_main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment