You are not logged in.
Hello. It's my first post here. Too bad it's about a problem.
I'm writing a wrapper so I can easily port my apps. Here's the code that I'm using for loading graphics.
char *filename; strcpy(filename,"sd:/"); strcat(filename,_dirname); strcpy(filename,"/"); strcat(filename,file); return GRRLIB_LoadTextureFromFile (filename);
_dirname is the name of app. This function requires one parameter.
The final filename the graphic is meant to be loaded from should look like this when argument "file" is "gfx/gfx.PNG" and _dirname value is "game":
sd:/game/gfx/gfx.PNG
However, when I tested it on console, I had an error.
"Exception (DSI) occurred! ..."
I haven't got any idea where does it come from. Please help.
Offline
Jaklub wrote:
Code:
char *filename; strcpy(filename,"sd:/"); strcat(filename,_dirname); strcpy(filename,"/"); strcat(filename,file); return GRRLIB_LoadTextureFromFile (filename);
Your code is wrong, you have pointer for the file name, but you never allocate memory for it
That's very bad
Offline
Thanks, I got it working.
I had another mistake in the script, btw.
Offline
j'ai une erreur:
> "make"
template.c
c:/devkitPro/examples/wii/killer128/mp3player/source/template.c: In function 'main':
c:/devkitPro/examples/wii/killer128/mp3player/source/template.c:130:1: warning: passing argument 1 of 'GRRLIB_LoadTextureFromFile' makes pointer from integer without a cast
c:/devkitPro/libogc/include/grrlib/GRRLIB__lib.h:93:17: note: expected 'const char *' but argument is of type 'char'
c:/devkitPro/examples/wii/killer128/mp3player/source/template.c:115:9: warning: 'filename' is used uninitialized in this function
linking ... mp3player.elf
output ... mp3player.dol
> Process Exit Code: 0
> Time Taken: 00:03
char *filename ; strcpy(filename,"sd:/apps/killer128/logo.png"); GRRLIB_texImg *tex_logo = GRRLIB_LoadTextureFromFile(*filename); //<- here it loads the png, be sure to input where the file is stored in your sd ... GRRLIB_DrawImg(0, 0, tex_logo, 0, 1, 1, 0xFFFFFFFF );
Last edited by killer128 (2011-03-22 23:50:33)
Offline
C'est normal que tu ait une erreur tu ne donne pas de place en mémoire pour ta variable filename.
Essaie de faire:
char filename[512]; strcpy(filename,"sd:/apps/killer128/logo.png"); GRRLIB_texImg *tex_logo = GRRLIB_LoadTextureFromFile(filename);
Sinon encore plus simple:
GRRLIB_texImg *tex_logo = GRRLIB_LoadTextureFromFile("sd:/apps/killer128/logo.png");
Offline
char filename[512];
strcpy(filename,"sd:/apps/killer128/logo.png");
GRRLIB_texImg *tex_logo = GRRLIB_LoadTextureFromFile(filename);
>> pour la correction ,j'ai du mal a comprendre ,sa ne marche pas.
>>pour ton 2ème exemple .Oui en effet c'est tellement plus simple.^^
Offline