Good question. I guess there are no examples in the SDK for how to do this. One object that does this in the standard Max distribution is the nslider object (it includes svg resources for the clefs and notes).
In the main function your external will receive a pointer like this (whee g_moduleref is a global/static):
int main(void *moduleRef)
{
g_moduleref = moduleRef;
nslider_initclass();
return 0;
}
In the call to slider_initclass() we fetch the SVG resources with a series of calls for each resource:
g_xml_treble = nslider_xml_from_resource(g_moduleref,"nslider-gclef");
g_xml_bass = nslider_xml_from_resource(g_moduleref,"nslider-fclef");
g_xml_note = nslider_xml_from_resource(g_moduleref,"nslider-notehead");
g_xml_sharp = nslider_xml_from_resource(g_moduleref,"nslider-sharp");
g_xml_flat = nslider_xml_from_resource(g_moduleref,"nslider-flat");
Where we've defined nslider_xml_from_resource() as:
const char* nslider_xml_from_resource(const void *moduleRef, const char *resname)
{
t_max_err err;
void *data = NULL;
unsigned long datasize = 0;
char *str;
t_atom ext;
atom_setsym(&ext,gensym("svg"));
err = jgraphics_get_resource_data(moduleRef, resname, 1, &ext, &data, &datasize);
if (data && datasize) {
// we do stuff with the data -- basically just copying it and making sure it is NULL-terminated.
return str; // str is a pointer to the memory we alloc'd and copied to just above
}
return NULL;
}