You are not logged in.

#1 2009-07-30 14:31:35

Pajn
Member

Documentation? PNG images and more...

I will start developing for the wii but have a few questions.
Sometimes people initialising video, sometimes they don't. How should I do?

How do I display png images? I have tried looking at your examples but the code looks unnecessary complicated, probably because you do a lot of other stuff too (blur). How should I do to just display a simple image?

Is there any documentation on the GRRLIB?


Sorry for my bad English I usually don't speak English.

Offline

 

#2 2009-07-30 18:11:53

Crayon
Bad Mother Fucker

Re: Documentation? PNG images and more...

Documentation could be found here: http://grrlib.googlecode.com/files/doc%204.0.0.zip

The minimum required to use GRRLIB is in the template file, check this file at http://code.google.com/p/grrlib/source/ … rce/main.c

To load a PNG you may want to check this code: http://code.google.com/p/grrlib/source/ … rce/main.c
You need:
* GRRLIB_LoadTexture
* GRRLIB_DrawImg
* GRRLIB_FreeTexture

Offline

 

#3 2009-07-30 19:41:26

Pajn
Member

Re: Documentation? PNG images and more...

Thanks, now an ir problem:

Code:

#include "../../GRRLIB/GRRLIB/GRRLIB.h"

#include <math.h>
#include <wiiuse/wpad.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ogcsys.h>
#include <gccore.h>
#include <unistd.h>

#include "gfx/font.h"
#include "gfx/generic_point.h"
#include "gfx/pirate.h"

ir_t ir;

int main() {

    GRRLIB_texImg *tex_pointer   = GRRLIB_LoadTexture(generic_point);

    GRRLIB_texImg *tex_pirate   = GRRLIB_LoadTexture(pirate);

    GRRLIB_texImg *text_font = GRRLIB_LoadTexture(font);
    GRRLIB_InitTileSet(text_font, 32, 36, 32);

    GRRLIB_Init();
    WPAD_Init();

    while(1) {

        WPAD_ScanPads();
        u32 pressed = WPAD_ButtonsDown(0);
        WPAD_IR(0, &ir);

        GRRLIB_FillScreen(0xFF0000FF);

        GRRLIB_Printf(10, 10, text_font, 0X000000FF, 1, "Press the pirate!");

        GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);

        if (pressed & WPAD_BUTTON_A) {
            if (ir.x >= 10 && ir.x <= 160 && ir.y >= 60 && ir.y <= 210) { 
                GRRLIB_Printf(10, 40, text_font, 0X000000FF, 1, "You pressed the pirate, yarr");
                usleep(500000);
            }
        }

        if( pressed & WPAD_BUTTON_B ) {
            GRRLIB_Printf(10, 300, text_font, 0X000000FF, 1, "x = %d. y = %d\n", ir.x, ir.y);
            usleep(500000);
        }

        if (pressed & WPAD_BUTTON_HOME) {
            break;
        }

        GRRLIB_DrawImg(ir.x, ir.y, tex_pointer, 0, 1, 1, 0xFFFFFFFF);

        GRRLIB_Render();
    }

    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    GRRLIB_FreeTexture(tex_pirate);
    GRRLIB_FreeTexture(tex_pointer);

    return 0;

}

It boots and shows the images but I can't move the pointer, nothing happens. Any idea?

The code comes from the png example and codemii tutorial 4&6

Last edited by Pajn (2009-07-30 19:43:48)

Offline

 

#4 2009-07-30 20:12:34

BlueChip
Moderator

Re: Documentation? PNG images and more...

remove the sleep() calls

BC


I can be found on efnet, freenode, msn, gtalk, aim, ychat & icq ...PM me for details

Offline

 

#5 2009-07-30 20:30:05

Pajn
Member

Re: Documentation? PNG images and more...

Done, but i can't still move the pointer. I don't think those was the problem because they were in if statements.

EDIT: If I press B it says x = 0 y = 1

Last edited by Pajn (2009-07-30 20:32:29)

Offline

 

#6 2009-07-30 21:06:20

Crayon
Bad Mother Fucker

Re: Documentation? PNG images and more...

You forgot to tell the Wii Remote to enable IR for Wiimote 1.

So after WPAD_Init(); do this:

Code:

WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);

Offline

 

#7 2009-07-30 21:30:38

Pajn
Member

Re: Documentation? PNG images and more...

Thanks.
But there are some little problems left, only the bottom half of the text Press the pirate! is visible. It seams like it uses too big resolution. I have a pal wii and five cable connection (3 video + 2 sound) (don't know the English name for that cable).
The pointer can not go off-screen, i uses this pointer http://wiibrew.org/wiki/Wii_Homebrew_Cursors and because the click is in the middle it can't move to the corners.

EDIT: another question, I want a background how big should it be? 640 x 480?

Last edited by Pajn (2009-07-30 21:34:30)

Offline

 

#8 2009-07-30 21:33:51

Crayon
Bad Mother Fucker

Offline

 

#9 2009-07-30 21:48:18

Pajn
Member

Re: Documentation? PNG images and more...

Great! I could not try it because my sister uses the wii but the other guy was happy.

I have someproblem whit the hotspot function

Code:

    GRRLIB_texImg tex_pointer = GRRLIB_LoadTexture(generic_point);
    tex_pointer.offsetx = 49; // This value needs to change
    tex_pointer.offsety = 49; // This value needs to change
    GRRLIB_SetHandle(tex_pointer, tex_pointer.offsetx, tex_pointer.offsety);

Code:

rasmus@rasmus-desktop:~/wii/test$ make
main.c
/home/rasmus/wii/test/source/main.c: In function 'main':
/home/rasmus/wii/test/source/main.c:21: error: invalid initializer
/home/rasmus/wii/test/source/main.c:24: error: incompatible type for argument 1 of 'GRRLIB_SetHandle'
/home/rasmus/wii/test/source/main.c:34: warning: implicit declaration of function 'AD_SetVRes'
/home/rasmus/wii/test/source/main.c:65: error: incompatible type for argument 3 of 'GRRLIB_DrawImg'
/home/rasmus/wii/test/source/main.c:78: error: incompatible type for argument 1 of 'GRRLIB_FreeTexture'
make[1]: *** [main.o] Error 1
make: *** [build] Error 2

Offline

 

#10 2009-07-30 21:54:59

Crayon
Bad Mother Fucker

Re: Documentation? PNG images and more...

Be careful a lot of people are using the svn version of the code and some not. So the code might be different. In your case your suppose to use a pointer:

GRRLIB_texImg *tex_pointer = GRRLIB_LoadTexture(generic_point);

Offline

 

#11 2009-07-30 21:58:29

Pajn
Member

Re: Documentation? PNG images and more...

I tried that to (that is what i use on the other pictures) but it gives more problems

Code:

rasmus@rasmus-desktop:~/wii/test$ make
main.c
/home/rasmus/wii/test/source/main.c: In function 'main':
/home/rasmus/wii/test/source/main.c:24: error: request for member 'offsetx' in something not a structure or union
/home/rasmus/wii/test/source/main.c:25: error: request for member 'offsety' in something not a structure or union
/home/rasmus/wii/test/source/main.c:26: error: request for member 'offsetx' in something not a structure or union
/home/rasmus/wii/test/source/main.c:26: error: request for member 'offsety' in something not a structure or union
/home/rasmus/wii/test/source/main.c:36: warning: implicit declaration of function 'AD_SetVRes'
/home/rasmus/wii/test/source/main.c:65: error: request for member 'w' in something not a structure or union
/home/rasmus/wii/test/source/main.c:65: error: request for member 'w' in something not a structure or union
/home/rasmus/wii/test/source/main.c:66: error: request for member 'h' in something not a structure or union
/home/rasmus/wii/test/source/main.c:66: error: request for member 'h' in something not a structure or union
make[1]: *** [main.o] Error 1
make: *** [build] Error 2

Offline

 

#12 2009-07-30 21:59:16

Crayon
Bad Mother Fucker

Re: Documentation? PNG images and more...

And use this like that:
tex_pointer->offsetx = 49; // This value needs to change
tex_pointer->offsety = 49; // This value needs to change

Offline

 

#13 2009-07-30 22:03:37

Crayon
Bad Mother Fucker

Re: Documentation? PNG images and more...

Just before you ask, you need to change this too:
GRRLIB_SetHandle(tex_pointer, tex_pointer->offsetx, tex_pointer->offsety);

And learn how to use pointers wink

Offline

 

#14 2009-07-30 22:15:05

Pajn
Member

Re: Documentation? PNG images and more...

Thanks! Works great.

Still learning, didn't now you can do anything whit pointers after you ha declared them.

Now just the screen problem, top left should be 0, 0 right? Then why is only the bottom half of the text "Press the pirate!" visible? I think top left is 0, 20 or something like that...

Last edited by Pajn (2009-07-30 22:16:35)

Offline

 

#15 2009-07-30 23:07:41

Crayon
Bad Mother Fucker

Re: Documentation? PNG images and more...

I don't know where that problem comes from. But it's something that append with certain TV/Cable/Wii settings.

So try not to put any critical information there wink

Offline

 

#16 2009-07-31 14:33:56

BlueChip
Moderator

Re: Documentation? PNG images and more...

PAL is 525 "lines"
NTSC is 480 "lines"
If the image is interlaced then you really ought to use the lines in pairs or else you will see "shimmering"
If you are using a 4:3 TV, the pixels will square
If you are using a 16:9 TV, the image will be stretched to fit, and the pixel will become wider than they are tall
...so a circle on a 4:3 will look like someone has sat on it when viewed in 16:9
you also have "overscan" - that is, the first few "lines" will be off the top of your TV and the last few will be off the bottom
"overscan" also happens on the left and right as well
The amount of "overscan" is defined by the company who made your TV (or TV-capture-card)

So if you want a circle in the exact centre of the TV - give up - sure you can know if you have 4:3 or 16:9 and allow for that - you can know if you have a PAL or NTSC TV and allow for that too - but there is no way you can know the overscan of the TV in my living room [actually, it's a 22year old 4:3 PAL50 interlaced CRT by JVC with *no* overscan!]

And now you know why lots of games have curtains at the side of the widescreen to make it be only 4:3 ...because it's a really hard problem to solve sad

It is a problem I plan to address at some point for my own game - but but don't hold your breath
My game looks perfect on my TV ...on 16:9 everything looks "fat" ...and on *most* TV's (including my kworld capture card) the left side of the screen is missing

Solution:  Just move stuff around til it looks right sad

BC


I can be found on efnet, freenode, msn, gtalk, aim, ychat & icq ...PM me for details

Offline

 

#17 2009-08-01 00:32:50

Pajn
Member

Re: Documentation? PNG images and more...

It is possible to lock even pal on 480 lines? whiteout black borders if possible... I have a pal 16:9 but i need it to also look good on a 4:3. But if i releases the work some people maybe want it to look good on ntcs?

Offline

 

Board footer

Powered by FluxBB