You are not logged in.

#1 2010-11-21 22:04:28

Jaklub
Member

[RESOLVED] Loading textures from SD / SDHC card

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.

Code:

   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

 

#2 2010-11-22 17:38:59

Crayon
Bad Mother Fucker

Re: [RESOLVED] Loading textures from SD / SDHC card

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 sad

That's very bad

Offline

 

#3 2010-11-22 19:01:51

Jaklub
Member

Re: [RESOLVED] Loading textures from SD / SDHC card

Thanks, I got it working.

I had another mistake in the script, btw.

Offline

 

#4 2011-03-22 23:49:09

killer128
Member

Re: [RESOLVED] Loading textures from SD / SDHC card

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



Code:

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

 

#5 2011-03-22 23:55:48

Crayon
Bad Mother Fucker

Re: [RESOLVED] Loading textures from SD / SDHC card

C'est normal que tu ait une erreur tu ne donne pas de place en mémoire pour ta variable filename.

Essaie de faire:

Code:

char filename[512];
strcpy(filename,"sd:/apps/killer128/logo.png");
GRRLIB_texImg *tex_logo = GRRLIB_LoadTextureFromFile(filename);

Sinon encore plus simple:

Code:

GRRLIB_texImg *tex_logo = GRRLIB_LoadTextureFromFile("sd:/apps/killer128/logo.png");

Offline

 

#6 2011-03-23 00:13:00

killer128
Member

Re: [RESOLVED] Loading textures from SD / SDHC card

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

 

Board footer

Powered by FluxBB