Forums > Dev

tell jit.gl.render to draw (was Re: bang out from ob3d)

January 15, 2007 | 7:39 am

> > but I don’t believe I have a mop as it is a gl object. is there
> > something similar I can use?
>
> If you really want to, you can pass in your max object wrapper to
> your inner jitter class however you see fit, though it is not
> recommended so that your class is useful from within JS, Java, and
> any future language bindings. Typically we recommend this sort of
> communication via jit_object_notify. This can notify the client max
> wrapper object (or JitterListener in JS/Java), to do something like
> send data out an outlet mid-process. In the SDK this is discussed a
> bit in the context of a MOP:
>
> http://www.cycling74.com/twiki/bin/view/ProductDocumentation/
> JitterSdkRegNotify
>
> As for getting access to the outlet pointers, you can cache the
> results of outlet_new in your max wrapper object struct for things
> like the following.
>
> max_jit_obex_dumpout_set(x, outlet_new(x,NULL));
> max_jit_ob3d_attach(x, jit_ob, outlet_new(x, "jit_matrix"));
>
> // could be:
>
> x->dumpout = outlet_new(x,NULL);
> max_jit_obex_dumpout_set(x, x->dumpout);
>
> x->matrixout = outlet_new(x, "jit_matrix");
> max_jit_ob3d_attach(x, jit_ob, x->matrixout);
>
> Or you could create additional outlets if you prefer.
>
thanks. so to clarify, max_jit_ob3d_attach() caches the outlet
internally in the ob3d, and it can only be used via
jit_ob3d_draw_chunk()?

what I’d actually like to do with this bang out is to cause the
gl.render to draw. I have managed to do so by explicitly naming the
render, and then looking up that name and sending a drawswap message
to it. poking around in the header files I found jit_gl_renderer_get
() which sounds like it should return the gl.render object attached
to the drawing context being used. however, I get an undefined symbol
error during link when I try to use it.

// ideal draw call?
jit_object_method(jit_gl_renderer_get(), gensym("drawswap"));

am I heading in the right direction here? is there a better/different
way to look up objects with particular capabilities attached to a
drawing context? I see a JIT_OB3D_IS_RENDERER flag for object
creation, but I don’t see a way to filter jit_object_findregistered()
or similar.

best,
r.


January 15, 2007 | 7:53 am

Out of curiosity, why do you need your object to call jit.gl.render’s
drawswap?

To see what jit_gl_get_renderer does, check out
http://cycling74.com/download/JitterAPIReference/ :

const char * jit_gl_get_renderer ()
Retrieves OpenGL renderer string.

The only way I can think of right now to get jit.gl.render inside an
object is to name it and use jit_object_findregistered. This will
give you a pointer to the object which you can then use
jit_object_classname to verify that it is indeed a jit.gl.render
object. You would basically do this:

void *obj = jit_object_findregistered(gensym("my_renderer"));
t_symbol *obj_class = jit_object_classname(obj);

if(obj_class == gensym("jit_gl_render"))
//is a jit.gl.render object
else
//not a jit.gl.render object

JIT_OB3D_IS_RENDERER is used for setting up the ob3d object. It will
get special properties if this flag is set when the ob3d class is
setup.

wes

On 1/14/07, ritchie argue wrote:
> > > but I don’t believe I have a mop as it is a gl object. is there
> > > something similar I can use?
> >
> > If you really want to, you can pass in your max object wrapper to
> > your inner jitter class however you see fit, though it is not
> > recommended so that your class is useful from within JS, Java, and
> > any future language bindings. Typically we recommend this sort of
> > communication via jit_object_notify. This can notify the client max
> > wrapper object (or JitterListener in JS/Java), to do something like
> > send data out an outlet mid-process. In the SDK this is discussed a
> > bit in the context of a MOP:
> >
> > http://www.cycling74.com/twiki/bin/view/ProductDocumentation/
> > JitterSdkRegNotify
> >
> > As for getting access to the outlet pointers, you can cache the
> > results of outlet_new in your max wrapper object struct for things
> > like the following.
> >
> > max_jit_obex_dumpout_set(x, outlet_new(x,NULL));
> > max_jit_ob3d_attach(x, jit_ob, outlet_new(x, "jit_matrix"));
> >
> > // could be:
> >
> > x->dumpout = outlet_new(x,NULL);
> > max_jit_obex_dumpout_set(x, x->dumpout);
> >
> > x->matrixout = outlet_new(x, "jit_matrix");
> > max_jit_ob3d_attach(x, jit_ob, x->matrixout);
> >
> > Or you could create additional outlets if you prefer.
> >
> thanks. so to clarify, max_jit_ob3d_attach() caches the outlet
> internally in the ob3d, and it can only be used via
> jit_ob3d_draw_chunk()?
>
> what I’d actually like to do with this bang out is to cause the
> gl.render to draw. I have managed to do so by explicitly naming the
> render, and then looking up that name and sending a drawswap message
> to it. poking around in the header files I found jit_gl_renderer_get
> () which sounds like it should return the gl.render object attached
> to the drawing context being used. however, I get an undefined symbol
> error during link when I try to use it.
>
> // ideal draw call?
> jit_object_method(jit_gl_renderer_get(), gensym("drawswap"));
>
> am I heading in the right direction here? is there a better/different
> way to look up objects with particular capabilities attached to a
> drawing context? I see a JIT_OB3D_IS_RENDERER flag for object
> creation, but I don’t see a way to filter jit_object_findregistered()
> or similar.
>
> best,
> r.
>


January 15, 2007 | 8:12 am

> Out of curiosity, why do you need your object to call jit.gl.render’s
> drawswap?
>
I am trying to add displaylink capabilities to jit.gl*, to tightly
synchronize drawing with the video card. this should (hopefully) give
more stable framerates and less jitter than the current metro-driven
method.

speaking of framerates, jit.gl.render does not output a bang on
render completion if the render is triggered via drawswap instead of
just bang. is this the intended behaviour? it still _looks like it’s
rendering to me..

> To see what jit_gl_get_renderer does, check out
> http://cycling74.com/download/JitterAPIReference/ :
>
> const char * jit_gl_get_renderer ()
> Retrieves OpenGL renderer string.
>
true, but I was looking at:

// utility methods
void * jit_gl_renderer_get();

not quite the same thing as:
// query methods
const char* jit_gl_get_renderer();

> The only way I can think of right now to get jit.gl.render inside an
> object is to name it and use jit_object_findregistered. This will
> give you a pointer to the object which you can then use
> jit_object_classname to verify that it is indeed a jit.gl.render
> object. You would basically do this:
>
> void *obj = jit_object_findregistered(gensym("my_renderer"));
> t_symbol *obj_class = jit_object_classname(obj);
>
> if(obj_class == gensym("jit_gl_render"))
> //is a jit.gl.render object
> else
> //not a jit.gl.render object
>
this is what I’m doing now, though I didn’t think to safety check for
a jit_gl_render classname. good suggestion.

> JIT_OB3D_IS_RENDERER is used for setting up the ob3d object. It will
> get special properties if this flag is set when the ob3d class is
> setup.
>
right. so I guess what I was wondering is if there was any way to
query the symbol table for objects with special properties.

r.


January 15, 2007 | 8:24 am

On 1/15/07, ritchie argue wrote:
> > Out of curiosity, why do you need your object to call jit.gl.render’s
> > drawswap?
> >
> I am trying to add displaylink capabilities to jit.gl*, to tightly
> synchronize drawing with the video card. this should (hopefully) give
> more stable framerates and less jitter than the current metro-driven
> method.
>

Ah. Makes sense.

> speaking of framerates, jit.gl.render does not output a bang on
> render completion if the render is triggered via drawswap instead of
> just bang. is this the intended behaviour? it still _looks like it’s
> rendering to me..
>

The 2 aren’t necessarily correlated. The bang comes because the swap
was triggered by a bang into the max wrapper, not from the Jitter
object swapping. Try doing this to your render object:

jit_object_notify(render_obj, gensym("swap"), NULL);

> true, but I was looking at:
>
> // utility methods
> void * jit_gl_renderer_get();

What source file and line number is this on?

wes


January 15, 2007 | 8:57 am

> > speaking of framerates, jit.gl.render does not output a bang on
> > render completion if the render is triggered via drawswap instead of
> > just bang. is this the intended behaviour? it still _looks like it’s
> > rendering to me..
> >
>
> The 2 aren’t necessarily correlated. The bang comes because the swap
> was triggered by a bang into the max wrapper, not from the Jitter
> object swapping. Try doing this to your render object:
>
> jit_object_notify(render_obj, gensym("swap"), NULL);
>
I tested a bunch of permutations from max, and couldn’t get it to go:

#P window setfont "Sans Serif" 9.;
#P user jit.fpsgui 167 294 60 196617 0;
#P user gswitch2 135 172 39 32 1 0;
#P toggle 135 144 15 0;
#P window linecount 1;
#P newex 61 217 94 196617 t swap draw erase;
#P newex 194 217 50 196617 t b erase;
#P newex 164 134 45 196617 jit.qball;
#P newex 324 118 153 196617 jit.gl.handle foo @auto_rotate 1;
#P newex 324 142 99 196617 jit.gl.videoplane foo;
#P newex 167 267 82 196617 jit.gl.render foo;
#P user jit.pwindow 330 224 82 62 0 1 0 0 1 0;
#X name foo;
#P toggle 164 92 15 0;
#P newex 164 112 52 196617 metro 20;
#P connect 10 0 8 0;
#P connect 8 2 3 0;
#P connect 8 1 3 0;
#P connect 8 0 3 0;
#P connect 3 0 11 0;
#P connect 10 1 7 0;
#P connect 9 0 10 0;
#P connect 6 0 10 1;
#P connect 7 1 3 0;
#P connect 7 0 3 0;
#P connect 1 0 0 0;
#P connect 0 0 6 0;
#P connect 5 0 4 0;

I just tested jit_object_notify(render_obj, gensym("swap"), NULL); as
well, with no difference. and sending a gensym("bang") doesn’t do
anything, either. presumably because the internal jitter object does
not respond to bangs, only the max wrapper does?

> > true, but I was looking at:
> >
> > // utility methods
> > void * jit_gl_renderer_get();
>
> What source file and line number is this on?
>
jit.gl.h, line 81. I just re-downloaded the 1.6 sdk to make sure my
file wasn’t out of date, and it’s still there.

best,

r.


January 15, 2007 | 9:02 am

I’m afraid you’re out of luck then with the bang thing. Somehow you
need to trigger the max wrapper’s bang method and I don’t think it’s
possible the way things are right now.

> jit.gl.h, line 81. I just re-downloaded the 1.6 sdk to make sure my
> file wasn’t out of date, and it’s still there.
>

I see it in the header, but I don’t see where it’s defined, so I can’t
tell you what it does. Wierd.

wes


March 29, 2010 | 3:57 pm

it maight be really old this post, but i just found a solution for the rendering in the draw-swap mode:

– Pasted Max Patch, click to expand. –

Viewing 7 posts - 1 through 7 (of 7 total)