Improved documentation

This commit is contained in:
Crayon2000 2022-05-27 00:53:50 -04:00
parent 5f2649c77e
commit 2c9b6345a3
13 changed files with 187 additions and 181 deletions

View file

@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
- Fixed compatibility issues with devkitPPC release 39. - Fixed compatibility issues with devkitPPC release 39.
- Added `GRRLIB_LoadTTFFromFile()` to load a TTF from a file. - Added `GRRLIB_LoadTTFFromFile()` to load a TTF from a file.
- Fixed documentation for `GRRLIB_Camera3dSettings()`. - Fixed documentation for `GRRLIB_Camera3dSettings()`, `GRRLIB_Screen2Texture()` and `GRRLIB_CompoEnd()`.
## [4.4.1] - 2021-03-05 ## [4.4.1] - 2021-03-05

View file

@ -338,7 +338,7 @@ void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32
/** /**
* Set the texture to an object (contributed by chris_c aka DaShAmAn). * Set the texture to an object (contributed by chris_c aka DaShAmAn).
* @param tex Pointer to an image texture (GRRLIB_texImg format). * @param tex Pointer to an image texture (GRRLIB_texImg format).
* @param rep Texture Repeat Mode, True will repeat it, False won't. * @param rep Texture Repeat Mode, @c true will repeat it, @c false won't.
*/ */
void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) { void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) {
GXTexObj texObj; GXTexObj texObj;
@ -709,7 +709,7 @@ void GRRLIB_SetLightDiff(u8 num, guVector pos, f32 distattn, f32 brightness, u32
* @param dir Direction of the specular ray (x/y/z). * @param dir Direction of the specular ray (x/y/z).
* @param shininess Shininess of the specular. ( between 4 and 254) * @param shininess Shininess of the specular. ( between 4 and 254)
* @param lightcolor Color of the light in RGBA format. * @param lightcolor Color of the light in RGBA format.
* @param speccolor Specular color in RGBA format.. * @param speccolor Specular color in RGBA format.
*/ */
void GRRLIB_SetLightSpec(u8 num, guVector dir, f32 shininess, u32 lightcolor, u32 speccolor) { void GRRLIB_SetLightSpec(u8 num, guVector dir, f32 shininess, u32 lightcolor, u32 speccolor) {
Mtx mr,mv; Mtx mr,mv;

View file

@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
Copyright (c) 2009-2019 The GRRLIB Team Copyright (c) 2009-2022 The GRRLIB Team
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -31,18 +31,16 @@ THE SOFTWARE.
* @param y Specifies the y-coordinate of the circle. * @param y Specifies the y-coordinate of the circle.
* @param radius The radius of the circle. * @param radius The radius of the circle.
* @param color The color of the circle in RGBA format. * @param color The color of the circle in RGBA format.
* @param filled Set to true to fill the circle. * @param filled Set to @c true to fill the circle.
*/ */
void GRRLIB_Circle (const f32 x, const f32 y, const f32 radius, void GRRLIB_Circle (const f32 x, const f32 y, const f32 radius,
const u32 color, const u8 filled) { const u32 color, const u8 filled) {
guVector v[36]; guVector v[36];
u32 ncolor[36]; u32 ncolor[36];
u32 a; const f32 G_DTOR = M_DTOR * 10;
f32 ra;
f32 G_DTOR = M_DTOR * 10;
for (a = 0; a < 36; a++) { for (u32 a = 0; a < 36; a++) {
ra = a * G_DTOR; const f32 ra = a * G_DTOR;
v[a].x = cos(ra) * radius + x; v[a].x = cos(ra) * radius + x;
v[a].y = sin(ra) * radius + y; v[a].y = sin(ra) * radius + y;

View file

@ -123,10 +123,10 @@ GRRLIB_ttfFont* GRRLIB_LoadTTFFromFile(const char *filename) {
/** /**
* Make a PNG screenshot. * Make a PNG screenshot.
* It should be called after drawing stuff on the screen, but before GRRLIB_Render. * It should be called after drawing stuff on the screen, but before GRRLIB_Render().
* libfat is required to use the function. * libfat is required to use the function.
* @param filename Name of the file to write. * @param filename Name of the file to write.
* @return bool true=everything worked, false=problems occurred. * @return Returns @c true if everything worked, @c false if problems occurred.
*/ */
bool GRRLIB_ScrShot(const char* filename) { bool GRRLIB_ScrShot(const char* filename) {
int ret = -1; int ret = -1;

View file

@ -28,7 +28,7 @@ static bool geckoinit = false;
/** /**
* Initialize USB Gecko. * Initialize USB Gecko.
* @return bool true=everything worked, false=problems occurred. * @return Returns @c true if everything worked, @c false if problems occurred.
*/ */
bool GRRLIB_GeckoInit() { bool GRRLIB_GeckoInit() {
s32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1); s32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);

View file

@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
Copyright (c) 2009-2019 The GRRLIB Team Copyright (c) 2009-2022 The GRRLIB Team
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -24,21 +24,22 @@ THE SOFTWARE.
/** /**
* Make a snapshot of the screen in a texture WITHOUT ALPHA LAYER. * Make a snapshot of the screen in a texture WITHOUT ALPHA LAYER.
* @param posx top left corner of the grabbed part. * @param posx Top left corner of the grabbed part.
* @param posy top left corner of the grabbed part. * @param posy Top left corner of the grabbed part.
* @param tex A pointer to a texture representing the screen or NULL if an error occurs. * @param tex A pointer to a texture representing the screen.
* @param clear When this flag is set to true, the screen is cleared after copy. * @param clear When this flag is set to @c true, the screen is cleared after copy.
*/ */
void GRRLIB_Screen2Texture (int posx, int posy, GRRLIB_texImg *tex, bool clear) { void GRRLIB_Screen2Texture (int posx, int posy, GRRLIB_texImg *tex, bool clear) {
if(tex->data != NULL) { if(tex == NULL || tex->data == NULL) {
GX_SetTexCopySrc(posx, posy, tex->w, tex->h); return;
GX_SetTexCopyDst(tex->w, tex->h, GX_TF_RGBA8, GX_FALSE); }
GX_CopyTex(tex->data, GX_FALSE); GX_SetTexCopySrc(posx, posy, tex->w, tex->h);
GX_PixModeSync(); GX_SetTexCopyDst(tex->w, tex->h, GX_TF_RGBA8, GX_FALSE);
GRRLIB_FlushTex(tex); GX_CopyTex(tex->data, GX_FALSE);
if(clear == true) { GX_PixModeSync();
GX_CopyDisp(xfb[!fb], GX_TRUE); GRRLIB_FlushTex(tex);
} if(clear == true) {
GX_CopyDisp(xfb[!fb], GX_TRUE);
} }
} }
@ -55,9 +56,9 @@ void GRRLIB_CompoStart (void) {
* End GX compositing process (Make a snapshot of the screen in a texture WITH ALPHA LAYER). * End GX compositing process (Make a snapshot of the screen in a texture WITH ALPHA LAYER).
* EFB is cleared after this function. * EFB is cleared after this function.
* @see GRRLIB_CompoStart * @see GRRLIB_CompoStart
* @param posx top left corner of the grabbed part. * @param posx Top left corner of the grabbed part.
* @param posy top left corner of the grabbed part. * @param posy Top left corner of the grabbed part.
* @param tex A pointer to a texture representing the screen or NULL if an error occurs. * @param tex A pointer to a texture representing the screen.
*/ */
void GRRLIB_CompoEnd(int posx, int posy, GRRLIB_texImg *tex) { void GRRLIB_CompoEnd(int posx, int posy, GRRLIB_texImg *tex) {
GRRLIB_Screen2Texture(posx, posy, tex, GX_TRUE); GRRLIB_Screen2Texture(posx, posy, tex, GX_TRUE);

View file

@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
Copyright (c) 2009-2021 The GRRLIB Team Copyright (c) 2009-2022 The GRRLIB Team
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -77,12 +77,12 @@ typedef struct tagRGBQUAD {
static static
void RawTo4x4RGBA (const u8 *src, void *dst, void RawTo4x4RGBA (const u8 *src, void *dst,
const u32 width, const u32 height) { const u32 width, const u32 height) {
u32 block; u32 block;
u32 i; u32 i;
u8 c; u8 c;
u8 argb; u8 argb;
u8 *p = (u8*)dst; u8 *p = (u8*)dst;
for (block = 0; block < height; block += 4) { for (block = 0; block < height; block += 4) {
for (i = 0; i < width; i += 4) { for (i = 0; i < width; i += 4) {
@ -154,27 +154,30 @@ GRRLIB_texImg* GRRLIB_LoadTexture (const u8 *my_img) {
* If image size is not correct, the texture will be completely transparent. * If image size is not correct, the texture will be completely transparent.
*/ */
GRRLIB_texImg* GRRLIB_LoadTexturePNG (const u8 *my_png) { GRRLIB_texImg* GRRLIB_LoadTexturePNG (const u8 *my_png) {
int width = 0, height = 0;
PNGUPROP imgProp;
IMGCTX ctx;
GRRLIB_texImg *my_texture = calloc(1, sizeof(GRRLIB_texImg)); GRRLIB_texImg *my_texture = calloc(1, sizeof(GRRLIB_texImg));
if (my_texture != NULL) { if (my_texture == NULL) {
ctx = PNGU_SelectImageFromBuffer(my_png); return NULL;
PNGU_GetImageProperties(ctx, &imgProp);
my_texture->data = PNGU_DecodeTo4x4RGBA8(ctx, imgProp.imgWidth, imgProp.imgHeight, &width, &height, NULL);
if (my_texture->data != NULL) {
my_texture->w = width;
my_texture->h = height;
GRRLIB_SetHandle( my_texture, 0, 0 );
if (imgProp.imgWidth != width || imgProp.imgHeight != height) {
// PNGU has resized the texture
memset(my_texture->data, 0, (my_texture->h * my_texture->w) << 2);
}
GRRLIB_FlushTex( my_texture );
}
PNGU_ReleaseImageContext(ctx);
} }
int width = 0;
int height = 0;
PNGUPROP imgProp;
IMGCTX ctx = PNGU_SelectImageFromBuffer(my_png);
PNGU_GetImageProperties(ctx, &imgProp);
my_texture->data = PNGU_DecodeTo4x4RGBA8(ctx, imgProp.imgWidth, imgProp.imgHeight, &width, &height, NULL);
if (my_texture->data != NULL) {
my_texture->w = width;
my_texture->h = height;
GRRLIB_SetHandle( my_texture, 0, 0 );
if (imgProp.imgWidth != width || imgProp.imgHeight != height) {
// PNGU has resized the texture
memset(my_texture->data, 0, (my_texture->h * my_texture->w) << 2);
}
GRRLIB_FlushTex( my_texture );
}
PNGU_ReleaseImageContext(ctx);
return my_texture; return my_texture;
} }
@ -204,135 +207,139 @@ static RGBQUAD* GRRLIB_CreatePalette (const u8 *my_bmp, u32 Size) {
* @return A GRRLIB_texImg structure filled with image information. * @return A GRRLIB_texImg structure filled with image information.
*/ */
GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp) { GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp) {
GRRLIB_texImg *my_texture = calloc(1, sizeof(GRRLIB_texImg));
if (my_texture == NULL) {
return NULL;
}
BITMAPFILEHEADER MyBitmapFileHeader; BITMAPFILEHEADER MyBitmapFileHeader;
BITMAPINFOHEADER MyBitmapHeader; BITMAPINFOHEADER MyBitmapHeader;
u16 pal_ref; u16 pal_ref;
u32 BufferSize; u32 BufferSize;
s32 y, x, i; s32 y, x, i;
GRRLIB_texImg *my_texture = calloc(1, sizeof(GRRLIB_texImg));
if (my_texture != NULL) { // Fill file header structure
// Fill file header structure MyBitmapFileHeader.bfType = (my_bmp[0] | my_bmp[1]<<8);
MyBitmapFileHeader.bfType = (my_bmp[0] | my_bmp[1]<<8); MyBitmapFileHeader.bfSize = (my_bmp[2] | my_bmp[3]<<8 | my_bmp[4]<<16 | my_bmp[5]<<24);
MyBitmapFileHeader.bfSize = (my_bmp[2] | my_bmp[3]<<8 | my_bmp[4]<<16 | my_bmp[5]<<24); MyBitmapFileHeader.bfReserved1 = (my_bmp[6] | my_bmp[7]<<8);
MyBitmapFileHeader.bfReserved1 = (my_bmp[6] | my_bmp[7]<<8); MyBitmapFileHeader.bfReserved2 = (my_bmp[8] | my_bmp[9]<<8);
MyBitmapFileHeader.bfReserved2 = (my_bmp[8] | my_bmp[9]<<8); MyBitmapFileHeader.bfOffBits = (my_bmp[10] | my_bmp[11]<<8 | my_bmp[12]<<16 | my_bmp[13]<<24);
MyBitmapFileHeader.bfOffBits = (my_bmp[10] | my_bmp[11]<<8 | my_bmp[12]<<16 | my_bmp[13]<<24); // Fill the bitmap structure
// Fill the bitmap structure MyBitmapHeader.biSize = (my_bmp[14] | my_bmp[15]<<8 | my_bmp[16]<<16 | my_bmp[17]<<24);
MyBitmapHeader.biSize = (my_bmp[14] | my_bmp[15]<<8 | my_bmp[16]<<16 | my_bmp[17]<<24); MyBitmapHeader.biWidth = (my_bmp[18] | my_bmp[19]<<8 | my_bmp[20]<<16 | my_bmp[21]<<24);
MyBitmapHeader.biWidth = (my_bmp[18] | my_bmp[19]<<8 | my_bmp[20]<<16 | my_bmp[21]<<24); MyBitmapHeader.biHeight = (my_bmp[22] | my_bmp[23]<<8 | my_bmp[24]<<16 | my_bmp[25]<<24);
MyBitmapHeader.biHeight = (my_bmp[22] | my_bmp[23]<<8 | my_bmp[24]<<16 | my_bmp[25]<<24); MyBitmapHeader.biPlanes = (my_bmp[26] | my_bmp[27]<<8);
MyBitmapHeader.biPlanes = (my_bmp[26] | my_bmp[27]<<8); MyBitmapHeader.biBitCount = (my_bmp[28] | my_bmp[29]<<8);
MyBitmapHeader.biBitCount = (my_bmp[28] | my_bmp[29]<<8); MyBitmapHeader.biCompression = (my_bmp[30] | my_bmp[31]<<8 | my_bmp[32]<<16 | my_bmp[33]<<24);
MyBitmapHeader.biCompression = (my_bmp[30] | my_bmp[31]<<8 | my_bmp[32]<<16 | my_bmp[33]<<24); MyBitmapHeader.biSizeImage = (my_bmp[34] | my_bmp[35]<<8 | my_bmp[36]<<16 | my_bmp[37]<<24);
MyBitmapHeader.biSizeImage = (my_bmp[34] | my_bmp[35]<<8 | my_bmp[36]<<16 | my_bmp[37]<<24); MyBitmapHeader.biXPelsPerMeter = (my_bmp[38] | my_bmp[39]<<8 | my_bmp[40]<<16 | my_bmp[41]<<24);
MyBitmapHeader.biXPelsPerMeter = (my_bmp[38] | my_bmp[39]<<8 | my_bmp[40]<<16 | my_bmp[41]<<24); MyBitmapHeader.biYPelsPerMeter = (my_bmp[42] | my_bmp[43]<<8 | my_bmp[44]<<16 | my_bmp[45]<<24);
MyBitmapHeader.biYPelsPerMeter = (my_bmp[42] | my_bmp[43]<<8 | my_bmp[44]<<16 | my_bmp[45]<<24); MyBitmapHeader.biClrUsed = (my_bmp[46] | my_bmp[47]<<8 | my_bmp[48]<<16 | my_bmp[49]<<24);
MyBitmapHeader.biClrUsed = (my_bmp[46] | my_bmp[47]<<8 | my_bmp[48]<<16 | my_bmp[49]<<24); MyBitmapHeader.biClrImportant = (my_bmp[50] | my_bmp[51]<<8 | my_bmp[52]<<16 | my_bmp[53]<<24);
MyBitmapHeader.biClrImportant = (my_bmp[50] | my_bmp[51]<<8 | my_bmp[52]<<16 | my_bmp[53]<<24);
my_texture->data = memalign(32, MyBitmapHeader.biWidth * MyBitmapHeader.biHeight * 4); my_texture->data = memalign(32, MyBitmapHeader.biWidth * MyBitmapHeader.biHeight * 4);
if (my_texture->data != NULL && MyBitmapFileHeader.bfType == 0x4D42) { if (my_texture->data != NULL && MyBitmapFileHeader.bfType == 0x4D42) {
RGBQUAD *Palette; RGBQUAD *Palette;
my_texture->w = MyBitmapHeader.biWidth; my_texture->w = MyBitmapHeader.biWidth;
my_texture->h = MyBitmapHeader.biHeight; my_texture->h = MyBitmapHeader.biHeight;
switch(MyBitmapHeader.biBitCount) { switch(MyBitmapHeader.biBitCount) {
case 32: // RGBA images case 32: // RGBA images
i = 54; i = 54;
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) { for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
for(x=0; x<MyBitmapHeader.biWidth; x++) { for(x=0; x<MyBitmapHeader.biWidth; x++) {
GRRLIB_SetPixelTotexImg(x, y, my_texture, GRRLIB_SetPixelTotexImg(x, y, my_texture,
RGBA(my_bmp[i+2], my_bmp[i+1], my_bmp[i], my_bmp[i+3])); RGBA(my_bmp[i+2], my_bmp[i+1], my_bmp[i], my_bmp[i+3]));
i += 4; i += 4;
}
} }
break; }
case 24: // truecolor images break;
BufferSize = (MyBitmapHeader.biWidth % 4); case 24: // truecolor images
i = 54; BufferSize = (MyBitmapHeader.biWidth % 4);
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) { i = 54;
for(x=0; x<MyBitmapHeader.biWidth; x++) { for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
GRRLIB_SetPixelTotexImg(x, y, my_texture, for(x=0; x<MyBitmapHeader.biWidth; x++) {
RGBA(my_bmp[i+2], my_bmp[i+1], my_bmp[i], 0xFF)); GRRLIB_SetPixelTotexImg(x, y, my_texture,
i += 3; RGBA(my_bmp[i+2], my_bmp[i+1], my_bmp[i], 0xFF));
} i += 3;
i += BufferSize; // Padding
} }
break; i += BufferSize; // Padding
case 8: // 256 color images }
BufferSize = (int) MyBitmapHeader.biWidth; break;
while(BufferSize % 4) { case 8: // 256 color images
BufferSize++; BufferSize = (int) MyBitmapHeader.biWidth;
while(BufferSize % 4) {
BufferSize++;
}
BufferSize -= MyBitmapHeader.biWidth;
Palette = GRRLIB_CreatePalette(&my_bmp[54], 256);
i = 1078; // 54 + (MyBitmapHeader.biBitCount * 4)
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
for(x=0; x<MyBitmapHeader.biWidth; x++) {
GRRLIB_SetPixelTotexImg(x, y, my_texture,
RGBA(Palette[my_bmp[i]].rgbRed,
Palette[my_bmp[i]].rgbGreen,
Palette[my_bmp[i]].rgbBlue,
0xFF));
i++;
} }
BufferSize -= MyBitmapHeader.biWidth; i += BufferSize; // Padding
Palette = GRRLIB_CreatePalette(&my_bmp[54], 256); }
i = 1078; // 54 + (MyBitmapHeader.biBitCount * 4) free(Palette);
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) { break;
for(x=0; x<MyBitmapHeader.biWidth; x++) { case 4: // 16 color images
GRRLIB_SetPixelTotexImg(x, y, my_texture, BufferSize = (int)((MyBitmapHeader.biWidth*4) / 8.0);
RGBA(Palette[my_bmp[i]].rgbRed, while(8*BufferSize < MyBitmapHeader.biWidth*4) {
Palette[my_bmp[i]].rgbGreen, BufferSize++;
Palette[my_bmp[i]].rgbBlue, }
0xFF)); while(BufferSize % 4) {
i++; BufferSize++;
} }
i += BufferSize; // Padding Palette = GRRLIB_CreatePalette(&my_bmp[54], 16);
i = 118; // 54 + (MyBitmapHeader.biBitCount * 4)
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
for(x=0; x<MyBitmapHeader.biWidth; x++) {
pal_ref = (my_bmp[i + (x / 2)] >> ((x % 2) ? 0 : 4)) & 0x0F;
GRRLIB_SetPixelTotexImg(x, y, my_texture,
RGBA(Palette[pal_ref].rgbRed,
Palette[pal_ref].rgbGreen,
Palette[pal_ref].rgbBlue,
0xFF));
} }
free(Palette); i += BufferSize; // Padding
break; }
case 4: // 16 color images free(Palette);
BufferSize = (int)((MyBitmapHeader.biWidth*4) / 8.0); break;
while(8*BufferSize < MyBitmapHeader.biWidth*4) { case 1: // black & white images
BufferSize++; BufferSize = (int)(MyBitmapHeader.biWidth / 8.0);
while(8*BufferSize < MyBitmapHeader.biWidth) {
BufferSize++;
}
while(BufferSize % 4) {
BufferSize++;
}
Palette = GRRLIB_CreatePalette(&my_bmp[54], 2);
i = 62; // 54 + (MyBitmapHeader.biBitCount * 4)
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
for(x=0; x<MyBitmapHeader.biWidth; x++) {
pal_ref = (my_bmp[i + (x / 8)] >> (-x%8+7)) & 0x01;
GRRLIB_SetPixelTotexImg(x, y, my_texture,
RGBA(Palette[pal_ref].rgbRed,
Palette[pal_ref].rgbGreen,
Palette[pal_ref].rgbBlue,
0xFF));
} }
while(BufferSize % 4) { i += BufferSize; // Padding
BufferSize++; }
} free(Palette);
Palette = GRRLIB_CreatePalette(&my_bmp[54], 16); break;
i = 118; // 54 + (MyBitmapHeader.biBitCount * 4) default:
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) { GRRLIB_ClearTex(my_texture);
for(x=0; x<MyBitmapHeader.biWidth; x++) {
pal_ref = (my_bmp[i + (x / 2)] >> ((x % 2) ? 0 : 4)) & 0x0F;
GRRLIB_SetPixelTotexImg(x, y, my_texture,
RGBA(Palette[pal_ref].rgbRed,
Palette[pal_ref].rgbGreen,
Palette[pal_ref].rgbBlue,
0xFF));
}
i += BufferSize; // Padding
}
free(Palette);
break;
case 1: // black & white images
BufferSize = (int)(MyBitmapHeader.biWidth / 8.0);
while(8*BufferSize < MyBitmapHeader.biWidth) {
BufferSize++;
}
while(BufferSize % 4) {
BufferSize++;
}
Palette = GRRLIB_CreatePalette(&my_bmp[54], 2);
i = 62; // 54 + (MyBitmapHeader.biBitCount * 4)
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
for(x=0; x<MyBitmapHeader.biWidth; x++) {
pal_ref = (my_bmp[i + (x / 8)] >> (-x%8+7)) & 0x01;
GRRLIB_SetPixelTotexImg(x, y, my_texture,
RGBA(Palette[pal_ref].rgbRed,
Palette[pal_ref].rgbGreen,
Palette[pal_ref].rgbBlue,
0xFF));
}
i += BufferSize; // Padding
}
free(Palette);
break;
default:
GRRLIB_ClearTex(my_texture);
}
GRRLIB_SetHandle( my_texture, 0, 0 );
GRRLIB_FlushTex( my_texture );
} }
GRRLIB_SetHandle( my_texture, 0, 0 );
GRRLIB_FlushTex( my_texture );
} }
return my_texture; return my_texture;
} }
@ -365,14 +372,15 @@ GRRLIB_texImg* GRRLIB_LoadTextureJPG (const u8 *my_jpg) {
* @return A GRRLIB_texImg structure filled with image information. * @return A GRRLIB_texImg structure filled with image information.
*/ */
GRRLIB_texImg* GRRLIB_LoadTextureJPGEx (const u8 *my_jpg, const int my_size) { GRRLIB_texImg* GRRLIB_LoadTextureJPGEx (const u8 *my_jpg, const int my_size) {
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
GRRLIB_texImg *my_texture = calloc(1, sizeof(GRRLIB_texImg)); GRRLIB_texImg *my_texture = calloc(1, sizeof(GRRLIB_texImg));
if (my_texture == NULL) { if (my_texture == NULL) {
return NULL; return NULL;
} }
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
jpeg_create_decompress(&cinfo); jpeg_create_decompress(&cinfo);
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
cinfo.progress = NULL; cinfo.progress = NULL;

View file

@ -33,7 +33,7 @@ THE SOFTWARE.
* @param hoth The height of the rectangle. * @param hoth The height of the rectangle.
* @param wpadx Specifies the x-coordinate of the point. * @param wpadx Specifies the x-coordinate of the point.
* @param wpady Specifies the y-coordinate of the point. * @param wpady Specifies the y-coordinate of the point.
* @return If the specified point lies within the rectangle, the return value is true otherwise it's false. * @return If the specified point lies within the rectangle, the return value is @c true otherwise it's @c false.
*/ */
INLINE INLINE
bool GRRLIB_PtInRect (const int hotx, const int hoty, bool GRRLIB_PtInRect (const int hotx, const int hoty,
@ -53,7 +53,7 @@ bool GRRLIB_PtInRect (const int hotx, const int hoty,
* @param rect2y Specifies the y-coordinate of the upper-left corner of the rectangle. * @param rect2y Specifies the y-coordinate of the upper-left corner of the rectangle.
* @param rect2w Specifies the width of the rectangle. * @param rect2w Specifies the width of the rectangle.
* @param rect2h Specifies the height of the rectangle. * @param rect2h Specifies the height of the rectangle.
* @return If the specified rectangle lies within the other rectangle, the return value is true otherwise it's false. * @return If the specified rectangle lies within the other rectangle, the return value is @c true otherwise it's @c false.
*/ */
INLINE INLINE
bool GRRLIB_RectInRect (const int rect1x, const int rect1y, bool GRRLIB_RectInRect (const int rect1x, const int rect1y,
@ -75,7 +75,7 @@ bool GRRLIB_RectInRect (const int rect1x, const int rect1y,
* @param rect2y Specifies the y-coordinate of the upper-left corner of the second rectangle. * @param rect2y Specifies the y-coordinate of the upper-left corner of the second rectangle.
* @param rect2w Specifies the width of the second rectangle. * @param rect2w Specifies the width of the second rectangle.
* @param rect2h Specifies the height of the second rectangle. * @param rect2h Specifies the height of the second rectangle.
* @return If the specified rectangle lies on the other rectangle, the return value is true otherwise it's false. * @return If the specified rectangle lies on the other rectangle, the return value is @c true otherwise it's @c false.
*/ */
INLINE INLINE
bool GRRLIB_RectOnRect (const int rect1x, const int rect1y, bool GRRLIB_RectOnRect (const int rect1x, const int rect1y,

View file

@ -76,7 +76,7 @@ void GRRLIB_Line (const f32 x1, const f32 y1,
* @param width The width of the rectangle. * @param width The width of the rectangle.
* @param height The height of the rectangle. * @param height The height of the rectangle.
* @param color The color of the rectangle in RGBA format. * @param color The color of the rectangle in RGBA format.
* @param filled Set to true to fill the rectangle. * @param filled Set to @c true to fill the rectangle.
*/ */
INLINE INLINE
void GRRLIB_Rectangle (const f32 x, const f32 y, void GRRLIB_Rectangle (const f32 x, const f32 y,

View file

@ -73,7 +73,7 @@ GRRLIB_blendMode GRRLIB_GetBlend (void) {
/** /**
* Turn anti-aliasing on/off. * Turn anti-aliasing on/off.
* @param aa Set to true to enable anti-aliasing (Default: Enabled). * @param aa Set to @c true to enable anti-aliasing (Default: Enabled).
*/ */
INLINE INLINE
void GRRLIB_SetAntiAliasing (const bool aa) { void GRRLIB_SetAntiAliasing (const bool aa) {
@ -82,10 +82,9 @@ void GRRLIB_SetAntiAliasing (const bool aa) {
/** /**
* Get current anti-aliasing setting. * Get current anti-aliasing setting.
* @return True if anti-aliasing is enabled. * @return Returns @c true if anti-aliasing is enabled.
*/ */
INLINE INLINE
bool GRRLIB_GetAntiAliasing (void) { bool GRRLIB_GetAntiAliasing (void) {
return GRRLIB_Settings.antialias; return GRRLIB_Settings.antialias;
} }

View file

@ -671,7 +671,7 @@ PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, in
return dst; return dst;
} }
// Coded by Tantric for libwiigui (http://code.google.com/p/libwiigui) // Coded by Tantric for libwiigui (https://github.com/dborth/libwiigui)
int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride) int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride)
{ {
png_uint_32 rowbytes; png_uint_32 rowbytes;

View file

@ -55,7 +55,7 @@ typedef struct
PNGU_u32 imgBitDepth; // In bitx PNGU_u32 imgBitDepth; // In bitx
PNGU_u32 imgColorType; // PNGU_COLOR_TYPE_* PNGU_u32 imgColorType; // PNGU_COLOR_TYPE_*
PNGU_u32 validBckgrnd; // Non zero if there is a background color PNGU_u32 validBckgrnd; // Non zero if there is a background color
PNGUCOLOR bckgrnd; // Backgroun color PNGUCOLOR bckgrnd; // Background color
PNGU_u32 numTrans; // Number of transparent colors PNGU_u32 numTrans; // Number of transparent colors
PNGUCOLOR *trans; // Transparent colors PNGUCOLOR *trans; // Transparent colors
} PNGUPROP; } PNGUPROP;

View file

@ -43,7 +43,7 @@ to allow real-time loading and saving of graphical data, and thus requires
libgrrlib <- 2D/3D graphics library libgrrlib <- 2D/3D graphics library
├── libfat <- File I/O ├── libfat <- File I/O
├── libjpeg <- JPEG image processor ├── libjpeg <- JPEG image processor
├── libpngu <- Wii wrapper for libpng ├── libpngu <- Wrapper for libpng
│ └── libpng <- PNG image processor │ └── libpng <- PNG image processor
└── libfreetype <- TrueType font processor └── libfreetype <- TrueType font processor
``` ```