using jit.gl.sketch in c


    Mar 19 2007 | 6:50 pm
    I've been trying to get an instance of jit.gl.sketch to work in my c code
    without success. Is there something special about this object? Or am I
    missing something obvious? The other gl objects work fine in the same way.
    In my constructor:
    if(!(x->jit_gl_sketch =
    jit_object_new(gensym("jit_gl_sketch"),ctxt))){
    error("graph2D: couldn't instantiate jit_gl_sketch");
    return NULL;
    }
    jit_attr_setlong(x->jit_gl_sketch, gensym("transform_reset"), 1);
    jit_attr_setlong(x->jit_gl_sketch, gensym("blend_enable"), 1);
    jit_attr_setlong(x->jit_gl_sketch, gensym("automatic"), 1);
    jit_attr_setlong(x->jit_gl_sketch, gensym("depth_enable"), 0);
    jit_attr_setlong(x->jit_gl_sketch, gensym("lighting_enable"), 0);
    Then for drawing I do this: (the ps_ are cached symbol pointers)
    void *s = x->jit_gl_sketch;
    object_method(s, ps_reset, 0L);
    object_method(s, ps_lineto, 3, 0, 0);
    object_method(s, ps_lineto, 0, 3, 0);
    object_method(s, ps_cube, 0.5f);
    object_method(s, ps_draw, 0L);
    ...no errors no nothing. Btw I know you're not supposed to reset if the
    content doesn't change, but this is just a test.
    cheers, -thijs
    ps: (out of curiosity) object_method and jit_object_method is the exact same
    thing right?

    • Mar 19 2007 | 7:03 pm
      On Mar 19, 2007, at 11:50 AM, Thijs Koerselman wrote:
      > I've been trying to get an instance of jit.gl.sketch to work in my
      > c code without success. Is there something special about this
      > object? Or am I missing something obvious? The other gl objects
      > work fine in the same way.
      > Then for drawing I do this: (the ps_ are cached symbol pointers)
      > void *s = x->jit_gl_sketch;
      >
      > object_method(s, ps_reset, 0L);
      > object_method(s, ps_lineto, 3, 0, 0);
      These are all A_GIMME style methods. Which requires passing in argc/
      argv style arguments, and double symbol arguments if calling through
      the "untyped" direct C interface. In general, for typed messages you
      can use object_method_typed() to call these routines.
      e.g.
      t_atom av[MY_MAX_ATOM_SIZE];
      object_method_typed(s,ps_reset, 0, NULL, NULL); // no args
      atom_setlong(av,3);
      atom_setlong(av+1,0);
      atom_setlong(av+2,0);
      object_method_typed(s,ps_lineto, 3, av, NULL); // no args
      Kind of cumbersome, and for this I apologize, but there's a bunch of
      things we're doing to make calling methods from C *much* easier in
      Max 5. Hope this helps.
      -Joshua
    • Mar 19 2007 | 8:24 pm
      On 3/19/07, Joshua Kit Clayton wrote:
      >
      > These are all A_GIMME style methods. Which requires passing in argc/
      > argv style arguments, and double symbol arguments if calling through
      > the "untyped" direct C interface. In general, for typed messages you
      > can use object_method_typed() to call these routines.
      >
      > e.g.
      >
      > t_atom av[MY_MAX_ATOM_SIZE];
      >
      > object_method_typed(s,ps_reset, 0, NULL, NULL); // no args
      >
      > atom_setlong(av,3);
      > atom_setlong(av+1,0);
      > atom_setlong(av+2,0);
      > object_method_typed(s,ps_lineto, 3, av, NULL); // no args
      >
      > Kind of cumbersome, and for this I apologize, but there's a bunch of
      > things we're doing to make calling methods from C *much* easier in
      > Max 5. Hope this helps.
      Thanks a lot I got it. Luckily I don't need too many drawing commands. O my
      I can't wait for max5! A_GIMME A_GIMME A_PLEASE
      best, -thijs