Compile error with SMPEG update function in a C++ class . (__cdecl *) specifier

You’re trying to pass a ‘pointer to a member function’ as a ‘pointer to a
function’, this is simply not possible. And for a good reason if you think
about it: which instance of draw_mpeg should be used? what if there is no
instance of draw_mpeg?

If you can make a singleton of draw_mpeg, you could work around it by
implementing a function that would call on it’s turn the update_surface of
the only instance of draw_mpeg, and pass that function to
SMPEG_setdisplay…

//the function could look like :
void _update_surface( SDL_Surface *surface, Sint32 x, Sint32 y, Uint32 w,
Uint32 h )
{
draw_mpeg::get_the_instance()->update_surface(surface,x ,y, w, h);
}

// and the draw() method :
void draw_mpeg::draw( SDL_Surface* dest )
{
SMPEG_setdisplay( mpeg, myvideo, NULL, _update_surface );
}

etc…

If you don’t know how to make a singleton of draw_mpeg, read a good book
about design patterns.

D.B.

You’re trying to pass a ‘pointer to a member function’ as a ‘pointer to a
function’, this is simply not possible. And for a good reason if you think
about it: which instance of draw_mpeg should be used? what if there is no
instance of draw_mpeg?
[Idigoras Inaki]
But I do have an instance of draw_mpeg. I am calling
SMPEG_setdisplay from within a member function of an instance of the class.
Could I use “this->update_surface”? (I get the same error, though)

If you can make a singleton of draw_mpeg, you could work around it by
implementing a function that would call on it’s turn the update_surface
of
the only instance of draw_mpeg, and pass that function to
SMPEG_setdisplay…
[Idigoras Inaki]
But I want to have more than one instance of the draw_mpeg class,
i.e. I want to play more than one video at a time.> //the function could look like :
void _update_surface( SDL_Surface *surface, Sint32 x, Sint32 y, Uint32 w,
Uint32 h )
{
draw_mpeg::get_the_instance()->update_surface(surface,x ,y, w, h);
}

// and the draw() method :
void draw_mpeg::draw( SDL_Surface* dest )
{
SMPEG_setdisplay( mpeg, myvideo, NULL, _update_surface );
}

etc…

If you don’t know how to make a singleton of draw_mpeg, read a good book
about design patterns.

D.B.