difficulty getting drawto default context name via SDK C API with jitter object


    May 29 2013 | 12:10 pm
    I have an external, and within it want to create a jit.gl.shader. I request assistance in correctly retrieving the default/auto drawto context name. All else seems to be working. Below is pseudo-code...
    I successfully create the shader with:
    x->psymDrawTo = _jit_sym_nothing;
    jitGLShader = (t_jit_object *)jit_object_new(_sym_jit_gl_shader, x->psymDrawTo);
    If I leave the context name as _jit_sym_nothing, I am hoping that the jitter object shader will take on the auto/default context name after the render has been banged; the same as I see on native box jit.gl.shader's. What I experience, is that sometimes I can retrieve the auto/default generated drawto context name and other times I continue to retrieve _jit_sym_nothing. It might relate to when I create the jitter shader object (before the 1st bang or after) but I haven't clearly seen the pattern.
    t_max_err max_myobject_drawto_get(t_max_myobject *x, t_object *attr, long *argc, t_atom **argv)
    {
    	char alloc;
    	t_symbol *psymDrawTo;
    	t_max_err memErr;
    
    	memErr = atom_alloc(argc, argv, &alloc); // allocate return atom
    	if (!memErr)
    	{
    		if (x->psymShaderName)
    		{
    			t_jit_object *jitGLShader;
    			if (jitGLShader = (t_jit_object *)jit_object_findregistered(x->psymShaderName))
    			{
    				// BUGBUG the auto default context is usually only available if I create the shader before the 1st bang
    				if (psymDrawTo = jit_attr_getsym(jitGLShader, _sym_drawto))
    				{
    					DEBUGPOST("found jit->drawto->s_name: %s", psymDrawTo->s_name);
    				}
    				else
    				{
    					DEBUGPOST("pointer to drawto sym is NULL");
    					psymDrawTo = _jit_sym_nothing;
    				}
    			}
    			else
    			{
    				DEBUGPOST("jit_object_findregistered(%s) failed", x->psymShaderName->s_name);
    				psymDrawTo = _jit_sym_nothing;
    			}
    		}
    		else
    		{
    			psymDrawTo = x->psymDrawTo;
    		}
    		atom_setsym(*argv, psymDrawTo);
    		return MAX_ERR_NONE;
    	}
    	else
    	{
    		return memErr;
    	}
    }