From pascal to c with sdl

I am not sure about this function I wrote:

int LoadBitmap( char *filename, SDL_Surface **image ){
*image = SDL_LoadBMP( filename );
if ( *image == NULL ){
fprintf(stderr, “SDL_LoadBMP failed! -> message: %s\n”, SDL_GetError());
return FALSE;
}
num_bmp++;
return TRUE;
}

I don’t know if it is necessary to use a pointer to a pointer. It seems to me
that if I use:
int LoadBitmap( char *filename, SDL_Surface *image )

the changes made to image only apply within LoadBitmap and not outside (so it
is still NULL)?

Please help me out.
Greetings,
Rob

–more code–
within global vars:
SDL_Surface *back;

function LoadBitmap as above (first with **image)

usage in main()
LoadAllBitmaps();

which calls
LoadBitmap( “img/back01.bmp”, &back );

It is.
But you can write it that way:

SDL_Surface *LoadBitmap( char *filename){
SDL_Surface *image;
image = SDL_LoadBMP( filename );
if ( image == NULL ){
fprintf(stderr, “SDL_LoadBMP failed! -> message: %s\n”, SDL_GetError());
}
else
num_bmp++;
return image;
}

and test if it’s NULL or not (instead FALSE/TRUE)On Sat, Aug 10, 2002 at 10:22:36PM +0200, Rob wrote:

int LoadBitmap( char *filename, SDL_Surface **image ){
*image = SDL_LoadBMP( filename );
if ( *image == NULL ){
fprintf(stderr, “SDL_LoadBMP failed! -> message: %s\n”, SDL_GetError());
return FALSE;
}
num_bmp++;
return TRUE;
}

I don’t know if it is necessary to use a pointer to a pointer.


http://decopter.sf.net - free unrealistic helicopter simulator

Hi Rob,
Just for your information, there are Pascal bindings for SDL. They
CVS can be grabbed @ http://www.sf.net/projects/jedi-sdl/.

Please ignore this email if you are using the move to SDL to learn C.

IHTH,

Dominique.

Rob wrote:> I am not sure about this function I wrote:

int LoadBitmap( char *filename, SDL_Surface **image ){
*image = SDL_LoadBMP( filename );
if ( *image == NULL ){
fprintf(stderr, “SDL_LoadBMP failed! -> message: %s\n”, SDL_GetError());
return FALSE;
}
num_bmp++;
return TRUE;
}

I don’t know if it is necessary to use a pointer to a pointer. It seems to me
that if I use:
int LoadBitmap( char *filename, SDL_Surface *image )

the changes made to image only apply within LoadBitmap and not outside (so it
is still NULL)?

Please help me out.
Greetings,
Rob

–more code–
within global vars:
SDL_Surface *back;

function LoadBitmap as above (first with **image)

usage in main()
LoadAllBitmaps();

which calls
LoadBitmap( “img/back01.bmp”, &back );


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


http://www.DelphiGamer.com := for all your Object Pascal game
development needs;
http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME := Home of JEDI-SDL;
Cross-platform game development with Pascal, has never been easier.