t_jit_err jit_gl_hap_dest_changed(t_jit_gl_hap *x) { t_symbol *dest_name = _jit_sym_nothing; t_jit_gl_drawinfo drawinfo; dest_name = jit_attr_getsym(x, gensym("drawto")); if(x->hapglsl) { jit_attr_setsym(x->hapglsl, gensym("drawto"), dest_name); jit_object_method(x->hapglsl, gensym("readbuffer"), jit_gl_hap_glsl_jxs); } if(x->texoutput) jit_attr_setsym(x->texoutput, gensym("drawto"), dest_name); if(x->fboid != 0) { glDeleteFramebuffersEXT(1, &x->fboid); x->fboid = 0; } jit_object_method(x->texoutput, gensym("set_rebuild")); // our texture has to be bound in the new context before we can use it // http://cycling74.com/forums/topic.php?id=29197 jit_gl_drawinfo_setup(x, &drawinfo); jit_gl_bindtexture(&drawinfo, jit_attr_getsym(x->texoutput, _jit_sym_name), 0); jit_gl_unbindtexture(&drawinfo, jit_attr_getsym(x->texoutput, _jit_sym_name), 0); return JIT_ERR_NONE; }
t_jit_err max_jit_gradient_outputmatrix(t_max_jit_gradient *x) { void *mop,*o,*p; long err=JIT_ERR_NONE; t_atom a; if (!(mop=max_jit_obex_adornment_get(x,_jit_sym_jit_mop))) return JIT_ERR_GENERIC; if (jit_attr_getlong(mop,_jit_sym_outputmode)) { if (err=(t_jit_err) jit_object_method( max_jit_obex_jitob_get(x), _jit_sym_matrix_calc, jit_object_method(mop,_jit_sym_getinputlist), jit_object_method(mop,_jit_sym_getoutputlist))) { jit_error_code(x,err); } else { if ((p=jit_object_method(mop,_jit_sym_getoutput,1)) && (o=max_jit_mop_io_getoutlet(p))) { jit_atom_setsym(&a,jit_attr_getsym(p,_jit_sym_matrixname)); outlet_anything(o,_jit_sym_jit_matrix,1,&a); } } } return err; }
void max_jit_str_op_mproc(t_max_jit_str_op *x, void *mop) { long err; void *o; long ac = 1; t_atom a[2]; t_symbol *s; o = max_jit_obex_jitob_get(x); jit_attr_setlong(o, gensym("adaptflag"), jit_attr_getlong(mop, _jit_sym_adapt)); if (err=(t_jit_err) jit_object_method( max_jit_obex_jitob_get(x), _jit_sym_matrix_calc, jit_object_method(mop,_jit_sym_getinputlist), jit_object_method(mop,_jit_sym_getoutputlist))) { jit_error_code(x,err); } else { s = jit_attr_getsym(o, gensym("op")); switch(jit_attr_getlong(o, gensym("outmode"))) { case 0: max_jit_mop_outputmatrix(x); break; case 2: ac = 2; jit_atom_setlong(&a[1], jit_attr_getlong(o, gensym("outlong2"))); case 1: jit_atom_setlong(&a[0], jit_attr_getlong(o, gensym("outlong"))); max_jit_obex_dumpout(x, s, ac, a); break; } } }
t_jit_tml_gl_videoplane *jit_gl_videoplane_new(t_symbol * dest_name) { t_jit_tml_gl_videoplane *x; t_atom rav[4]; t_atom *av=rav; // make jit object if (x = (t_jit_tml_gl_videoplane *)jit_object_alloc(_jit_tml_gl_videoplane_class)) { // create and attach ob3d jit_ob3d_new(x, dest_name); // set instance variable defaults x->dim[0] = 20; x->dim[1] = 20; x->chunk = jit_glchunk_grid_new(_jit_sym_gl_quad_grid, 12, x->dim[0], x->dim[1]); x->recalc = 1; x->displaylist = 0; x->dlref = 0; x->gridmode = 0; x->interp = 1; x->tex_offset_x = 0.; x->tex_offset_y = 0.; x->tex_scale_x = 1.; x->tex_scale_y = 1.; x->nudge = 0.0001; // hack for edges x->rect_tex = 1; x->client_storage = PLATFORM_DYNAMIC_TEX; x->colormode = gensym("argb"); jit_atom_setfloat(av,1.); jit_atom_setfloat(av+1,1.); jit_atom_setfloat(av+2,1.); jit_atom_setfloat(av+3,1.); jit_object_method(x,gensym("color"),4,av); x->texture = jit_object_new(ps_jit_gl_texture,jit_attr_getsym(x,ps_drawto)); if (x->texture) { x->texturename = jit_symbol_unique(); jit_attr_setsym(x->texture,_jit_sym_name,x->texturename); jit_attr_setsym(x->texture,gensym("defaultimage"),gensym("black")); jit_attr_setlong(x->texture,ps_rectangle,x->rect_tex); jit_attr_setsym(x->texture,ps_mode,x->client_storage?ps_dynamic:ps_static); jit_attr_setsym(x,ps_texture,x->texturename); } else { error("jit.tml.gl.videoplane: could not create texture"); x->texturename = _jit_sym_nothing; } } else { error("jit.tml.gl.videoplane: Failed at jit_object_alloc"); x = NULL; } return x; }
t_jit_err jit_gl_videoplane_dest_changed(t_jit_gl_videoplane *x) { // destination has changed, requires rebuilding context dependent resources if (x->displaylist) x->recalc=1; // set our internal texture's drawing destination, too if (x->texture) jit_attr_setsym(x->texture,ps_drawto,jit_attr_getsym(x,ps_drawto)); return JIT_ERR_NONE; }
t_jit_err jit_gl_hap_getattr_out_name(t_jit_gl_hap *x, void *attr, long *ac, t_atom **av) { if ((*ac)&&(*av)) { //memory passed in, use it } else { //otherwise allocate memory *ac = 1; if (!(*av = jit_getbytes(sizeof(t_atom)*(*ac)))) { *ac = 0; return JIT_ERR_OUT_OF_MEM; } } jit_atom_setsym(*av,jit_attr_getsym(x->texoutput,_jit_sym_name)); return JIT_ERR_NONE; }
void max_jit_gl_spout_receiver_draw(t_max_jit_gl_spout_receiver *x, t_symbol *s, long argc, t_atom *argv) { t_atom a; // get the jitter object t_jit_object *jitob = (t_jit_object*)max_jit_obex_jitob_get(x); // call the jitter object's draw method jit_object_method(jitob, s, s, argc, argv); // query the texture name and send out the texture output jit_atom_setsym(&a,jit_attr_getsym(jitob, ps_out_name)); outlet_anything(x->texout, ps_jit_gl_texture, 1, &a); }
void max_jit_gl_spout_receiver_draw(t_max_jit_gl_spout_receiver *x, t_symbol *s, long argc, t_atom *argv) { UNREFERENCED_PARAMETER(s); UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argv); t_atom a; // get the jitter object t_jit_object *jitob = (t_jit_object*)max_jit_obex_jitob_get(x); // Call the jitter object's draw method (from Syphon code) // LJ - This causes an error with corrupted texture received in draw // but does not affect the output. Seem to be not needed - needs tracing // t_symbol *attr = gensym("draw"); // jit_object_method(jitob, attr, s, argc, argv); // query the texture name and send out the texture output jit_atom_setsym(&a, jit_attr_getsym(jitob, ps_out_name)); outlet_anything(x->texout, ps_out_texture, 1, &a); }