Textures directly from files

Post Reply
Lin
Posts: 18
Joined: Sat Feb 20, 2010 5:20 pm
Location: Salt Lake City

Textures directly from files

Post by Lin » Wed Jun 16, 2010 4:04 pm

Is there a way to load textures from a file at runtime? I tried to modify the "neheGX" example number 6 to use TPL_OpenTPLFromFile instead of TPL_OpenTPLFromMemory, but simply switching the function calls and removing the nehe-related header files produced only a black screen and inert machine. (I put the file NeHe.bmp both in the same directory as the executable and in the root of the SD card; neither worked) How are you supposed to use the function TPL_OpenTPLFromFile? Loading at compile time would be fine too, but I don't understand how the image file is converted and the header files are produced in the example.

MODIFIED:

Code: Select all

GX_InvVtxCache();
GX_InvalidateTexAll();
TPL_OpenTPLFromFile(&neheTPL, "NeHe.bmp");
TPL_GetTexture(&neheTPL,0,&texture);
// setup our camera at the origin
// looking down the -z axis with y up
guLookAt(view, &cam, &up, &look);
ORIGINAL:

Code: Select all

GX_InvVtxCache();
GX_InvalidateTexAll();
TPL_OpenTPLFromMemory(&neheTPL, (void *)NeHe_tpl,NeHe_tpl_size);
TPL_GetTexture(&neheTPL,nehe,&texture);
// setup our camera at the origin
// looking down the -z axis with y up
guLookAt(view, &cam, &up, &look);

dancinninja
Posts: 6
Joined: Thu Jun 10, 2010 3:08 am

Re: Textures directly from files

Post by dancinninja » Sat Jun 26, 2010 2:57 am

Maybe it doesn't know where to look? What if you put:

Code: Select all

sd:/whatever.bmp
Have you tried converting it to a different image format? Maybe it's the "bmp".

Lin
Posts: 18
Joined: Sat Feb 20, 2010 5:20 pm
Location: Salt Lake City

Re: Textures directly from files

Post by Lin » Tue Jul 06, 2010 6:44 am

You could be right about the file format. I don't know if that's what's really causing my problem, but after looking up about the .BMP file format I find that it's specified as little-endian. The Wii being big-endian (or at least running as such), that could pose a problem to reading the header data.

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Textures directly from files

Post by WinterMute » Wed Jul 07, 2010 4:07 pm

Slight clue in the function name, TPL_OpenTPLFromFile loads a tpl file - these are generated using gxtexconv.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Lin
Posts: 18
Joined: Sat Feb 20, 2010 5:20 pm
Location: Salt Lake City

Re: Textures directly from files

Post by Lin » Sat Jul 24, 2010 5:38 pm

That helped. I got it working at last. The filename definitely needed the path prefix "sd:", and I also needed to call fatMountSimple before the texture load call, as in

Code: Select all

__io_wiisd.startup();
fatMountSimple("sd", &__io_wiisd);

TPL_OpenTPLFromFile(&neheTPL, "sd:/NeHe.tpl")
WinterMute, are you some sort of benevolent deity? You manage the tools AND answer everybody's questions, probably over and over again. Thank you very much.

User avatar
Izhido
Posts: 107
Joined: Fri Oct 19, 2007 10:57 pm
Location: Costa Rica
Contact:

Re: Textures directly from files

Post by Izhido » Sat Jul 24, 2010 9:22 pm

Not 100% sure about the deity part... but I can assure you, he IS the author of all devkit*** toolchains. So yeah :D

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Textures directly from files

Post by WinterMute » Sun Jul 25, 2010 10:43 am

The correct code should be

Code: Select all

fatInitDefault();
TPL_OpenTPLFromFile(&neheTPL, "/NeHe.tpl");
Direct reference to the storage device should be avoided. Ideally you should also avoid explicit root paths since the launchers will set argv which leaves the working directory set to the path of the dol.
Help keep devkitPro toolchains free, Donate today

Personal Blog

DolphinG89
Posts: 28
Joined: Sat Apr 13, 2013 10:40 pm

Re: Textures directly from files

Post by DolphinG89 » Tue Apr 16, 2013 5:38 pm

I'm having a problem with this lesson aswell with a black texture but nothing seems to fix it can you show exactly how you set up the file and how to get it to show more than a black cube with dolphin through eclipse.

antidote
Posts: 17
Joined: Wed Mar 23, 2011 2:54 am

Re: Textures directly from files

Post by antidote » Sun Jul 28, 2013 8:44 pm

is the texture resolution in powers of 2?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest