Changed char* in ImgLoader procs to CSTRING

This commit is contained in:
Armando Rivera 2013-11-06 23:44:16 -05:00
parent 0ace1c86a9
commit e67c1ca432
2 changed files with 30 additions and 29 deletions

1
.gitignore vendored
View File

@ -3,4 +3,5 @@ test
output.txt output.txt
*.exe *.exe
*.swp *.swp
sdl_test/test

View File

@ -6,7 +6,7 @@
DIM AS CHAR string[128]; // String used by txtIt & SDL_ttf DIM AS CHAR string[128]; // String used by txtIt & SDL_ttf
// Conver Variable Argument into a string // Conver Variable Argument into a string
SUB txtIt(char *pStr , ...) BEGIN SUB txtIt(const char *pStr , ...) BEGIN
DIM AS va_list valist; // Type to hold information about variable arguments DIM AS va_list valist; // Type to hold information about variable arguments
va_start(valist, pStr); // Initialize a variable argument list va_start(valist, pStr); // Initialize a variable argument list
vsprintf( string , pStr , valist ); // Print formatted variable argument list to string vsprintf( string , pStr , valist ); // Print formatted variable argument list to string
@ -33,11 +33,11 @@ ENDSUB
// This function load a image file to a surface // This function load a image file to a surface
// Set bCKey with colorkey (R,G,B) to clear a color on the image // Set bCKey with colorkey (R,G,B) to clear a color on the image
// Set alpha value FOR transparency 0(No transparent) ~ 255(Ivisible) // Set alpha value FOR transparency 0(No transparent) ~ 255(Ivisible)
FUNCTION SDL_Surface *ImgLoader(char *file, BOOL bCKey, INT r, INT g, INT b, INT alpha) BEGIN FUNCTION SDL_Surface *ImgLoader(CSTRING file, BOOL bCKey, INT r, INT g, INT b, INT alpha) BEGIN
SDL_Surface *pic; SDL_Surface *pic;
pic = IMG_Load(file); // From SDL_image.h , load the image to pic pic = IMG_Load(file.c_str()); // From SDL_image.h , load the image to pic
IF (pic==NULL) THEN IF (pic==NULL) THEN
fprintf(stderr,"Missing image %s : %s\n",file,IMG_GetError()); fprintf(stderr,"Missing image %s : %s\n",file.c_str(),IMG_GetError());
ENDIF ENDIF
IF ( bCKey ) THEN IF ( bCKey ) THEN
SDL_SetColorKey(pic,SDL_SRCCOLORKEY|SDL_RLEACCEL,SDL_MapRGB(pic->format,r,g,b)); SDL_SetColorKey(pic,SDL_SRCCOLORKEY|SDL_RLEACCEL,SDL_MapRGB(pic->format,r,g,b));
@ -50,13 +50,13 @@ FUNCTION SDL_Surface *ImgLoader(char *file, BOOL bCKey, INT r, INT g, INT b, INT
ENDFUNCTION ENDFUNCTION
// Load a normal picture into a surface // Load a normal picture into a surface
FUNCTION SDL_Surface *ImgLoader(LPCHAR file) BEGIN FUNCTION SDL_Surface *ImgLoader(CSTRING file) BEGIN
RETURN ImgLoader(file,1,0,0,0,0) ; RETURN ImgLoader(file.c_str(),1,0,0,0,0) ;
ENDFUNCTION ENDFUNCTION
// Load a pic & set the transparent color to (255,255,255) , no alpha // Load a pic & set the transparent color to (255,255,255) , no alpha
FUNCTION SDL_Surface *ImgLoader(char *file,bool bCKey) BEGIN FUNCTION SDL_Surface *ImgLoader(CSTRING file,bool bCKey) BEGIN
RETURN ImgLoader(file,1,255,255,255,0) ; RETURN ImgLoader(file.c_str(),1,255,255,255,0) ;
ENDFUNCTION ENDFUNCTION