You are not logged in.

#1 2008-06-25 19:54:29

JustWoody
Member

DrawTile problem?

Hi guys thanks for the hard work that you are putting into GRRLIB, it makes programming Wii games much easier.

I am having a problem with the GRRLIB_DrawTile routine:

I have a tile set of 42 tiles each tile 48x64, when I have them in one png file (converted to .h + .c using raw2c) it comes out as gibberish when using GRRLIB_DrawTile.

Code:

GRRLIB_DrawTile(50,50,48,64,tex_tiles,0,1,1,255,0,42);

But, if I cut the image in half so I have 2 files each with 21 tiles it all works fine.

Code:

GRRLIB_DrawTile(50,50,48,64,tex_tiles1,0,1,1,255,0,21);

As you can see I am using all the same settings for both, but with the number of tiles changed, can anyone help?

FYI the input image is PNG32

Offline

 

#2 2008-06-25 20:04:52

Crayon
Bad Mother Fucker

Re: DrawTile problem?

Apparently there is a limit for the Width and Height, the limit is 1024 pixels. But it's not confirmed yet.

Offline

 

#3 2008-06-25 20:16:32

JustWoody
Member

Re: DrawTile problem?

Cheers for the reply Crayon smile

I also tried putting the tiles on two lines in the same file (so the width only 1008 same as ones that work) with the same results.

Looking at the DrawTile code it looks like this is not supported yet though, seems only one tile height at the mo.

Offline

 

#4 2008-06-25 20:19:05

RedShade
Member

Re: DrawTile problem?

The draw tile method seems to have problems with tiles over 1024 in pixel width. It's something I've wanted to look into, and one of the reasons I'd thought of another way to do image strips for animations (and an entirely different way of doing tiles for maps and such that I've shown NoNameNo that's handled entirely on the GPU with no code by people needed).

I don't really know what the issue is  yet, unless someones tried loading an image larger than 1024 and drawn it to a single quad and had problems. :-/The patents say there is a limit to the texels of 1,024 (the blocks that make up the images, 4x4 for RGBA), but not to actual pixel count.

I know that with an end product images wouldn't be loaded into your binary since they'd probably be handled by libfat, but until then you can avoid the loading of the ".h" and ".c" for files by using an assembler stub
*file in the folder that ends in either ".s" or ".S" , replace _variable_ with whatever you want*

Code:

   .rodata
   .globl _variable_
   .balign 4
   _variable_:
   .incbin "../source/_filename_"

This just copies the file to the executable, and gives you the pointer _variable_ (whatever you named it) to the beginning of the data.

Code:

extern u8 * _variable_;

Last edited by RedShade (2008-06-25 20:21:52)

Offline

 

#5 2008-06-26 18:30:06

JustWoody
Member

Re: DrawTile problem?

Cheers for your advice RedShade, I am having a few problems in implementing them sad

I have added a file asm.s as follows:

Code:

   .rodata
   .globl _variable_
   .balign 4
   tiles1:
   .incbin "../source/gfx/tileset.png"

and added the following lines to my program:

Code:

   extern u8 *tiles1;
...
GRRLIB_DrawTile(50,50,48,64,tiles1,0,0.9,0.9,255,0,21);

I am getting this error:

d:/projects/wii/xxxxxxxx/source/main.c:47: undefined reference to `tiles1'

I'm probably doing something really stupid?

I've not changed the make file to add the asembler stub, do I have to do this?

Last edited by JustWoody (2008-06-26 18:35:53)

Offline

 

#6 2008-06-26 18:43:11

JustWoody
Member

Re: DrawTile problem?

Ah it was something stupid smile

I just noticed that i had forgotten to change the other _variable_ in the assembler!

This now compiles ok, but doesn't show any graphics when i use the draw tile, I don't get anything

Probably doing something else thats stupid roll

Last edited by JustWoody (2008-06-26 18:46:35)

Offline

 

#7 2008-06-26 19:12:18

RedShade
Member

Re: DrawTile problem?

I assumed that since you were using raw2c, you had some way of converting the raw data into a texture. a png file won't be displayed natively on the wii.

Code:

IMGCTX img = PNGU_SelectImageFromBuffer(tiles1);
PNGUPROP prop; PNGU_GetImageProperties(img,&prop);
u8 * tiles1_texture= memalign(32,(prop.imgWidth*prop.imgHeight)<<2);
PNGU_DecodeTo4x4RGBA8 (img,prop.imgWidth, prop.imgHeight, tiles1_texture, 0xFF);

Then tiles1_texture will have the translated image that you can draw.

Last edited by RedShade (2008-06-26 19:12:49)

Offline

 

#8 2008-06-26 19:54:20

JustWoody
Member

Re: DrawTile problem?

cheer for the extra help, unfortunately its now dumping!

I've added an include for pngu.h and there is an entry for -lpng in the libs of my makefile, is there anything else that I am missing?

Offline

 

#9 2008-06-26 20:07:43

RedShade
Member

Re: DrawTile problem?

Ah... sorry. I didn't look through the GRRLIB code.
The helper function he has already should just allow you to use:

Code:

u8 * tiles1_texture = GRRLIB_LoadTexture(tiles1);

Offline

 

Board footer

Powered by FluxBB