Hello all,
I'm trying to build a PD method for this SDL function:
SDL_Surface *IMG_Load(const char *file);
problem is I can't figure out how to pass the symbol argument as a filename which IMG_Load expects. Here is my current method:
void load_images(mystruct *x, t_symbol* image1_src, t_symbol* image2_src) { /* Symbol pointer stuff */
image1 = IMG_Load( (char *) image1_src ); if (image1_src == NULL) { post("Image 1 could not be opened"); } image2 = IMG_Load( (char *) image2_src ); if (image2_src == NULL) { post("Image 2 could not be opened"); } SDL_Flip(screen); } Which results in a segfault. I tried it without typecasting but gcc just complains that its the wrong pointer type.
class_addmethod(myclass, (t_method)load_images, gensym("open"), A_DEFSYM, A_DEFSYM, 0);
I also tried using argv and atom_getsymbol() with the same pointer-type porblem.
What am I doing wrong?
Thanks Ben
B. Bogart ---------
hi Ben,
use image1_src->s_name (but only after making sure image1_src is not null, because you have declared it as A_DEFSYM).
Krzysztof
Ben Bogart - FMPM/F1999 wrote: ...
I'm trying to build a PD method for this SDL function:
SDL_Surface *IMG_Load(const char *file);
problem is I can't figure out how to pass the symbol argument as a filename which IMG_Load expects. Here is my current method:
void load_images(mystruct *x, t_symbol* image1_src, t_symbol* image2_src) { /* Symbol pointer stuff */
image1 = IMG_Load( (char *) image1_src );
meaning:
if (image1_src != &s_) /* use image1_src->s_name */
but some superstitious coders (like myself) would write:
if (image1_src && image1_src != &s_)...
rzsz
Krzysztof Czaja wrote: ...
use image1_src->s_name (but only after making sure image1_src is not null, because you have declared it as A_DEFSYM).