Grrlib simple help
June 06, 2009 12:02PM
Ok, I suck so badly at this Grrlib thing xD
Tomorrow is my birthday (Posting Late) I just wanna know if someone could help me show ONE static image.
Just stick on that one image. or even a code not related to Grrlib would be fine.

PLZ I will be checking in the morning :D thanks so much.
Re: Grrlib simple help
June 06, 2009 07:29PM
With GRRLIB, I think you will need to convert your image to a header file. This can be done easily with WiiBuilder [www.wiibrew.org]. Put the header file in your source folder or a subfolder. Then include that header-file.

Like this:

#include "graphics/image.h"


or

#include "image.h"


depending on your path.

to init GRRLIB, which you have to do before you can actually draw anything, use:

GRRLIB_Init();

After that you have got to load the image with GRRLIB_LoadTexture(const unsigned char my_img[])

like this:

GRRLIB_texImg *theImage = GRRLIB_LoadTexture(image);

and when you like to draw the image use GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color)

like this:

GRRLIB_DrawImg (150, 100, theImage, 0, 1, 1, 0x000000FF);

and then to render use:

GRRLIB_Render();

I think that is all you need to do! (And you have to include GRRLIB to and put it in a folder which your include-line links to!

Happy Birthday!
Re: Grrlib simple help
June 06, 2009 07:43PM
Well first, the code I use is GRRLIB 3.0 and is based on the fact that I have used WiiBuilder to convert my .PNG images to a .H header file. (Remember, your image dimensions have to be in multiples of 4 in order to convert the file) Once you have your image converted, you'll have to include the header file, load it, then display. Here's a rundown of the code, once you've converted your image:

// include files
#include "image.h"

// loading image as texture
u8 *tex_image=GRRLIB_LoadTexture(image);

// displays the specified image
GRRLIB_DrawImg(0,0,640,480,tex_black,0,1,1,255);
GRRLIB_Render();

When putting in the code for loading to texture, the tex_image and (image) parts are just variables which you can name whatever you want.

In the code "GRRLIB_DrawImg()", the variables used are as follows:
GRRLIB_DrawImg(x coord, y coord, height, width, which image to use, rotation degrees, x scale, y scale, alpha)

Hope that helps!

EDIT: I guess profetylen got to it before me....haha, that's what I get for being busy with work.



Edited 1 time(s). Last edit at 06/06/2009 07:44PM by RazorChrist.
Re: Grrlib simple help
June 09, 2009 02:42PM
You do not need need to convert images to headers any longer.

Taken from one of my projects:


GRRLIB_texImg *background;

long curfade = 0xFFFFFF00;

int background_init(void)
{
	background = GRRLIB_LoadTextureFromFile("content/background_640_480.png");
	
	if(!background)
		return -1;

	return 1;
}

void background_draw(void)
{
	GRRLIB_DrawImg(0,0,background,0,1,1,0xFFFFFFFF);
}

This is relatively new with grrlib.. The file where GRRLIB_LoadTextureFromFile() resides in is GRRLIB_addon.c. If you want to use it you need to checkout the svn repository for grrlib. Use this command:


svn checkout [grrlib.googlecode.com] grrlib-read-only

Hope that helps!
Re: Grrlib simple help
June 12, 2009 10:59AM
Quote
MrPeanut
You do not need need to convert images to headers any longer. This is relatively new with grrlib.. The file where GRRLIB_LoadTextureFromFile() resides in is GRRLIB_addon.c. Hope that helps!

Question on this....if you're loading the Texture from file, as the command suggests, does it compile the file directly into the .dol, like it would for an image header? Or does it load the file directly from the SD? If it works basically the same as loading a file directly from SD, I'll pass, as I'm not big on having to setup extra files located elsewhere on the SD.

Otherwise, if it just compiles it like an image header, I'll check it out, as it would save time having to convert the files.



Edited 2 time(s). Last edit at 06/12/2009 11:00AM by RazorChrist.
Re: Grrlib simple help
June 12, 2009 05:24PM
GRRLIB_LoadTextureFromFile() does not compile the file into the dol.
Re: Grrlib simple help
June 12, 2009 07:36PM
Quote
MrPeanut
GRRLIB_LoadTextureFromFile() does not compile the file into the dol.

Have you got GRRLIB from the svn newly?
Sorry, only registered users may post in this forum.

Click here to login