SMPEG_setdisplay

Hello,

I’d like to use the function
SMPEG_setdisplay(SMPEG*, SDL_Surface*, SDL_mutex*,
void()(SDL_Surface, int, int, unsigned int, unsigned int))

which takes a function for its fourth argument.

e.g.

void update(SDL_Surface*, int, int, unsigned int, unsigned int)
{

}

int main(…)
{

SMPEG_setdisplay( …,…,…,update);

}

this works fine

but i’d like to keep the design OO, so i’d like to use

class Foo
{
public:
Foo();
Update();
}

int main(…)
{

Foo* foo = new Foo();
SMPEG_setdisplay( …,…,…,foo->update);

}

this code doesn’t compile and gives an error like:

argument of type void (Foo::)(SDL_Surface*, int, int, unsigned int, unsigned int)' does not matchvoid ()(SDL_Surface, int, int, unsigned
int, unsigned int)’

How can I solve this? I’m sorry if this question is more C++ oriented
then SDL oriented. But perhaps it can be solved with a typedef or a
cast?

Thank you,
Maarten

Make the Update() function static.On Mon, Aug 11, 2003 at 10:03:22PM +0200, Maarten Peeters wrote:

this code doesn’t compile and gives an error like:

argument of type void (Foo::)(SDL_Surface*, int, int, unsigned int, unsigned int)' does not matchvoid ()(SDL_Surface, int, int, unsigned
int, unsigned int)’

How can I solve this? I’m sorry if this question is more C++ oriented
then SDL oriented. But perhaps it can be solved with a typedef or a
cast?


Ivan Stankovic, @Ivan_Stankovic

SMPEG_setdisplay( …,…,…,foo->update);

How can I solve this? I’m sorry if this question is more C++ oriented
then SDL oriented. But perhaps it can be solved with a typedef or a
cast?

This is a C++ thing, but “Update” needs to be static:

class Foo
{
public:
Foo();
static void Update(SDL_Surface *, int, int, unsigned int, unsigned int);
}

This will fix the problem, but you no longer have a “this” pointer, which
means you can’t reference any part of Foo that isn’t also static inside
the Update method.

–ryan.

Ivan Stankovic wrote:

this code doesn’t compile and gives an error like:

argument of type void (Foo::)(SDL_Surface*, int, int, unsigned int, unsigned int)' does not matchvoid ()(SDL_Surface, int, int, unsigned
int, unsigned int)’

How can I solve this? I’m sorry if this question is more C++ oriented
then SDL oriented. But perhaps it can be solved with a typedef or a
cast?

Make the Update() function static.

You can also type the function argument as a method of an
object rather than just a function (maybe it even has to be
of that particular object - don’t remember). I don’t rember the
types / syntax for this and I don’t have any C++ books / docs right
here but I know you can do this.

Cheers> On Mon, Aug 11, 2003 at 10:03:22PM +0200, Maarten Peeters wrote:

http://www.HardcoreProcessing.com