Hi,
I want to set the update function for the MPEG playback (SMPEG library) as a
member of a C++ class:
header file (.h):___________
class draw_mpeg: public draw_resource
{
private:
void update_surface( SDL_Surface surface, Sint32 x, Sint32 y,
Uint32 w, Uint32 h );
protected:
SMPEG mpeg;
SDL_Surface* myvideo;
public:
void draw( SDL_Surface* dest );
}
implementation file (.cpp)
void draw_mpeg::update_surface( SDL_Surface *surface, Sint32 x, Sint32 y,
Uint32 w, Uint32 h )
{
SDL_Rect r = { x, y, w, h };
SDL_BlitSurface( surface, &r, dest_surface, &rect );
r.x = rect.x;
r.y = rect.y;
SDL_UpdateRects( dest_surface, 1, &r );
}
void draw_mpeg::draw( SDL_Surface* dest )
{
…
SMPEG_setdisplay( mpeg, myvideo, NULL, update_surface );
...
}
But I get a compiler error (VisualC/C++ 6.0):
error C2664: ‘SMPEG_setdisplay’ : cannot convert parameter 4 from ‘void
(struct SDL_Surface *,int,int,unsigned int,unsigned int)’ to ‘void (__cdecl
*)(struct SDL_Surface *,int,int,unsigned int,unsigned int)’
The difference is in the (__cdecl *) specifier required by SMPEG_setdisplay
What do I need to specify? I tried extern “C” and DECLSPEC with no success.
From SMPEG.H:
#ifdef __cplusplus
extern “C” {
#endif
/* Matches the declaration of SDL_UpdateRect() */
typedef void(SMPEG_DisplayCallback)(SDL_Surface dst, int x, int y,
unsigned int w, unsigned int h);
/* Set the destination surface for MPEG video playback
’surfLock’ is a mutex used to synchronize access to ‘dst’, and can be
NULL.
‘callback’ is a function called when an area of ‘dst’ needs to be
updated.
If ‘callback’ is NULL, the default function (SDL_UpdateRect) will be
used.
/
extern DECLSPEC void SMPEG_setdisplay(SMPEG mpeg, SDL_Surface* dst,
SDL_mutex* surfLock,
SMPEG_DisplayCallback callback);
#ifdef __cplusplus
};
#endif
I?aki Idigoras Igartua <@Idigoras_Inaki>
IKERLAN - E&K Dpt. (http://www.ikerlan.es)
P.Box 146, 20500 Arrasate - Gipuzkoa
Phone +34 943 712400 - Fax. +34 943 796944