[Cogl] Cogl in Python

Artur Skawina art.08.09 at gmail.com
Tue Apr 10 17:01:29 PDT 2012


On 04/10/12 23:25, Martin Owens wrote:
> On Tue, 2012-04-10 at 22:52 +0200, Artur Skawina wrote:
>> PS. I don't think i've ever used cogl.Material - if there exists some
>> simple
>> self-contained example that uses it i could try it from D using my
>> bindings.
>> But these parts of GI indeed look sane, so the problem may be
>> elsewhere. 
> 
> Try over-riding Clutter, in python it would be (see attached). Also
> added the image for completeness.
> 
> Can you convert this to D?

Well, not properly, not w/o a little more complete gobject bindings,
something that i have not needed yet...

Still, the Q&D hack below works, or at least does not crash:

clutter_container_add_actor(0x8232000, 0x82361a8, 0, 0xf6c6fd6c, 28) = 3
clutter_actor_show_all(0x8232000, 0x82361a8, 0, 0xf6c6fd6c, 28) = 3
clutter_main(0x8232000, 0x82361a8, 0, 0xf6c6fd6c, 28 <unfinished ...>
clutter_texture_get_cogl_material(0x82361a8, 0xf77a3ff4, 0xf77815a0, -763148, -763216) = 0x81de3b8
cogl_material_set_color4ub(0x81de3b8, 0xf77a3fff, 0xf7781500, -763392, -763264) = 1
cogl_set_source(0x81de3b8, 0xf77a3fff, 0xf7781500, -763392, -763264) = 2
clutter_texture_get_cogl_material(0x82361a8, 0xc008646a, -763352, 0xf6509b60, 0x8156608) = 0x81de3b8
cogl_material_set_color4ub(0x81de3b8, 0xc00864ff, -763392, 0xf6509b00, 0x8156680) = 1
cogl_set_source(0x81de3b8, 0xc00864ff, -763392, 0xf6509b00, 0x8156680) = 1
[...]

so the clutter and cogl GI parts seem ok, at least here.

artur


import clut = gtk2.clutter;
import cogl = gtk2.cogl;

typeof(clut.ActorClass.paint) supaint;

struct MyActor {
   clut.Texture* texture;
   alias texture this;
   extern (C) static void do_paint(clut.Actor* this_) nothrow {
      auto t = cast(clut.Texture*)this_;
      auto material = cast(cogl.Material*)t.get_cogl_material();
      material.set_color4ub(cast(ubyte)255, cast(ubyte)0, cast(ubyte)0, cast(ubyte)128);
      cogl.set_source(material);
      supaint(this_);
   }
   this(...) {
      texture = clut.Texture();
      auto c = cast(clut.ActorClass*)*cast(void**)texture;
      supaint = c.paint;
      c.paint = &do_paint;
   }
}

void main(string argv[]) {
   argv = clut.init(argv);
   auto stage = clut.Stage.get_default();
   auto actor = MyActor(1);
   actor.set_from_file("/tmp/add.png", null);
   stage.add_actor(actor);
   stage.show_all();
   clut.main_();
}


More information about the Cogl mailing list