You are not logged in.

#1 2009-03-13 13:11:09

RazorChrist
Member

Two Seperate Image Issues

Issue #1: I'm creating custom images for the menu selection of my game. They're saved in non-interlaced PNG format. Dimensions are 280x48. The problem is, when I run them through WiiBuilder 1.0 to convert them to *.h files, it gives me the message: Warning: not a multiple of 4. If I add the image.h file to my DevKitPro project, it will compile, but when I run the game, the new images just come out as garbled pixels. Anyone know how to fix this?

Issue #2: In an attempt to make a quick and easy way to fade images in and out (for splash/menu purposes), I made some modifications to my v3.0 GRRLIB.c and GRRLIB.h files.

Here are the mods I made to GRRLIB.c:

Code:

inline void GRRLIB_DrawImg_FadeInOut(u16 width, u16 height, u8 data[], float scaleX, f32 scaleY, u16 speed)
{
    GRRLIB_DrawImg_FadeIn(width, height, data, scaleX, scaleY, speed);
    GRRLIB_DrawImg_FadeOut(width, height, data, scaleX, scaleY, speed);
}

inline void GRRLIB_DrawImg_FadeIn(u16 width, u16 height, u8 data[], float scaleX, f32 scaleY, u16 speed)
{
    alpha=0;

    for (alpha=0 ; alpha < 255 ; )
    {
        GRRLIB_DrawImg((640-width)/2, (480-height)/2, width, height, data, 0, scaleX, scaleY, alpha );
        GRRLIB_Render();
        alpha = alpha + speed;
    }

}

inline void GRRLIB_DrawImg_FadeOut(u16 width, u16 height, u8 data[], float scaleX, f32 scaleY, u16 speed)
{
    alpha=0;

    for (alpha=255 ; alpha > 0 ; --alpha)
    {
        GRRLIB_DrawImg((640-width)/2, (480-height)/2, width, height, data, 0, scaleX, scaleY, alpha );
        GRRLIB_Render();
        alpha = alpha - speed;
    }

}

Here are the mods to GRRLIB.h:

Code:

inline void GRRLIB_DrawImg_FadeInOut(u16 width, u16 height, u8 data[], float scaleX, f32 scaleY, u16 speed);
inline void GRRLIB_DrawImg_FadeIn(u16 width, u16 height, u8 data[], float scaleX, f32 scaleY, u16 speed);
inline void GRRLIB_DrawImg_FadeOut(u16 width, u16 height, u8 data[], float scaleX, f32 scaleY, u16 speed);

Here is the code that draws my images in my Menu.cpp file:

Code:

void fade_in() {
    
    // Starts black, then fades out
    GRRLIB_DrawImg_FadeInOut(640,480,tex_black,1,1,1);
    // Fades in splash image
    GRRLIB_DrawImg_FadeInOut(640,480,tex_splash,1,1,1);
    GRRLIB_Render();
    
    // Draws title and menu images
    GRRLIB_DrawImg(0,0,640,480,tex_title,0,1,1,255);
    GRRLIB_DrawImg(212,230,216,68,tex_newgame_up,0,1,1,255);
    GRRLIB_DrawImg(212,308,216,68,tex_options_up,0,1,1,100);
    GRRLIB_DrawImg(212,286,216,68,tex_hbc_up,0,1,1,255);
    GRRLIB_Render();
}

My problem is, the Splash image only stays on the screen for approx 1-3 seconds before it loads the main title screen and menu buttons. Is there a way to display the splash for maybe 5 seconds total time before changing to the title screen? It's just changing too fast. I tried changing my speed variable from 1 to say 0.5, but when I do this, it doesn't load the image at all.

Any help is much appreciated.


PSP = Phat 5.00 m33-6 w/ 1.50 Kernel Addon
WII = Softmodded v3.3u w/ Homebrew Channel + IOS249
Wii Dev Projects: TronCycles

Offline

 

#2 2009-03-13 15:58:48

Crayon
Bad Mother Fucker

Re: Two Seperate Image Issues

Issue #1: Are you really sure the width and height of your image is 280x48? Because if WiiBuilder is reporting this warning that's strange and the effect on the screen seems like the size not being a multiple of 4.

Issue #2:
    // Starts black, then fades out
    GRRLIB_DrawImg_FadeInOut(640,480,tex_black,1,1,1);
    // Fades in splash image
    GRRLIB_DrawImg_FadeInOut(640,480,tex_splash,1,1,1);
    GRRLIB_Render(); // YOU DON'T NEED TO CALL RENDER HERE, LAST COMMAND IN FADE WAS RENDER

Just put that block of code in a loop to make it stay on the screen longer:

Code:

    // Draws title and menu images
    GRRLIB_DrawImg(0,0,640,480,tex_title,0,1,1,255);
    GRRLIB_DrawImg(212,230,216,68,tex_newgame_up,0,1,1,255);
    GRRLIB_DrawImg(212,308,216,68,tex_options_up,0,1,1,100);
    GRRLIB_DrawImg(212,286,216,68,tex_hbc_up,0,1,1,255);
    GRRLIB_Render();

Offline

 

#3 2009-03-14 11:23:01

RazorChrist
Member

Re: Two Seperate Image Issues

Thanks for the help, Crayon. The warning I was getting in WiiBuilder has been fixed. I just had to redo my images until their dimensions were multiples of 4. So they're working now.

As for the fading image issue, I was able to get it to display pretty close to the timing I wanted by changing the code to this:

Code:

// Starts black, then fades out
GRRLIB_DrawImg(0,0,640,480,tex_black,0,1,1,255);
GRRLIB_Render();
    
// Fades in splash image
GRRLIB_FillScreen(0xFF000000);
GRRLIB_DrawImg_FadeInOut(640,480,tex_splash,1,1,1);

The fade is apparently alot slower when viewed on the actual Wii, as opposed to testing it in the Dolphin emulator.


PSP = Phat 5.00 m33-6 w/ 1.50 Kernel Addon
WII = Softmodded v3.3u w/ Homebrew Channel + IOS249
Wii Dev Projects: TronCycles

Offline

 

#4 2009-03-14 15:45:54

NoNameNo
Administrator

Re: Two Seperate Image Issues

what what what ?? you says that is possible to run GRRLIB_stuff in dolphin ??? please post a little howto from downloading dolphin to run homebrew wink
thx

Offline

 

#5 2009-04-09 12:20:29

RazorChrist
Member

Re: Two Seperate Image Issues

NoNameNo wrote:

what what what ?? you says that is possible to run GRRLIB_stuff in dolphin ??? please post a little howto from downloading dolphin to run homebrew wink
thx

There's really nothing special to it. I probably forgot to mention you have no input control, unless you're using an XBOX360 pad, in which case I've not tested, cus I'm not cool enough to own a 360. Really, the only thing I use Dolphin for is to make sure a project will even load. Makes it easier/faster when testing something or trying out tutorials.

Other than that, I've noticed I have better luck loading GRRLIB stuff when using Dolphin_r2276 instead of Dolphin_r2630. I uploaded a copy of the version I use, if anyone wants it (link below). One other thing, sometimes you'll get an error when loading a .dol that says: Failed to grab 1 GB of contiguous memory!

Don't worry about it, just reload Dolphin and load your .dol again and it should be fine. The screenshot below was taken after compiling the xane01 example source that comes with GRRLIB 4.0, then ran in Dolphin_r2276. Below the screenshot is a link to download Dolphin from my megaupload.

Screenshot of Dolphin
Download: http://www.megaupload.com/?d=8JJ1ZUSW


PSP = Phat 5.00 m33-6 w/ 1.50 Kernel Addon
WII = Softmodded v3.3u w/ Homebrew Channel + IOS249
Wii Dev Projects: TronCycles

Offline

 

Board footer

Powered by FluxBB