mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-12-22 18:39:18 +00:00
Improved documentation
This commit is contained in:
parent
5f2649c77e
commit
2c9b6345a3
13 changed files with 187 additions and 181 deletions
|
@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
- Fixed compatibility issues with devkitPPC release 39.
|
||||
- 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
|
||||
|
||||
|
|
|
@ -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).
|
||||
* @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) {
|
||||
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 shininess Shininess of the specular. ( between 4 and 254)
|
||||
* @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) {
|
||||
Mtx mr,mv;
|
||||
|
|
|
@ -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
|
||||
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 radius The radius of the circle.
|
||||
* @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,
|
||||
const u32 color, const u8 filled) {
|
||||
guVector v[36];
|
||||
u32 ncolor[36];
|
||||
u32 a;
|
||||
f32 ra;
|
||||
f32 G_DTOR = M_DTOR * 10;
|
||||
const f32 G_DTOR = M_DTOR * 10;
|
||||
|
||||
for (a = 0; a < 36; a++) {
|
||||
ra = a * G_DTOR;
|
||||
for (u32 a = 0; a < 36; a++) {
|
||||
const f32 ra = a * G_DTOR;
|
||||
|
||||
v[a].x = cos(ra) * radius + x;
|
||||
v[a].y = sin(ra) * radius + y;
|
||||
|
|
|
@ -123,10 +123,10 @@ GRRLIB_ttfFont* GRRLIB_LoadTTFFromFile(const char *filename) {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* @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) {
|
||||
int ret = -1;
|
||||
|
|
|
@ -28,7 +28,7 @@ static bool geckoinit = false;
|
|||
|
||||
/**
|
||||
* 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() {
|
||||
s32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
|
||||
|
|
|
@ -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
|
||||
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.
|
||||
* @param posx 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 clear When this flag is set to true, the screen is cleared after copy.
|
||||
* @param posx 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.
|
||||
* @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) {
|
||||
if(tex->data != NULL) {
|
||||
GX_SetTexCopySrc(posx, posy, tex->w, tex->h);
|
||||
GX_SetTexCopyDst(tex->w, tex->h, GX_TF_RGBA8, GX_FALSE);
|
||||
GX_CopyTex(tex->data, GX_FALSE);
|
||||
GX_PixModeSync();
|
||||
GRRLIB_FlushTex(tex);
|
||||
if(clear == true) {
|
||||
GX_CopyDisp(xfb[!fb], GX_TRUE);
|
||||
}
|
||||
if(tex == NULL || tex->data == NULL) {
|
||||
return;
|
||||
}
|
||||
GX_SetTexCopySrc(posx, posy, tex->w, tex->h);
|
||||
GX_SetTexCopyDst(tex->w, tex->h, GX_TF_RGBA8, GX_FALSE);
|
||||
GX_CopyTex(tex->data, GX_FALSE);
|
||||
GX_PixModeSync();
|
||||
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).
|
||||
* EFB is cleared after this function.
|
||||
* @see GRRLIB_CompoStart
|
||||
* @param posx 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 posx 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.
|
||||
*/
|
||||
void GRRLIB_CompoEnd(int posx, int posy, GRRLIB_texImg *tex) {
|
||||
GRRLIB_Screen2Texture(posx, posy, tex, GX_TRUE);
|
||||
|
|
|
@ -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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -77,12 +77,12 @@ typedef struct tagRGBQUAD {
|
|||
static
|
||||
void RawTo4x4RGBA (const u8 *src, void *dst,
|
||||
const u32 width, const u32 height) {
|
||||
u32 block;
|
||||
u32 i;
|
||||
u8 c;
|
||||
u8 argb;
|
||||
u32 block;
|
||||
u32 i;
|
||||
u8 c;
|
||||
u8 argb;
|
||||
|
||||
u8 *p = (u8*)dst;
|
||||
u8 *p = (u8*)dst;
|
||||
|
||||
for (block = 0; block < height; block += 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.
|
||||
*/
|
||||
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));
|
||||
|
||||
if (my_texture != NULL) {
|
||||
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);
|
||||
if (my_texture == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -204,135 +207,139 @@ static RGBQUAD* GRRLIB_CreatePalette (const u8 *my_bmp, u32 Size) {
|
|||
* @return A GRRLIB_texImg structure filled with image information.
|
||||
*/
|
||||
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;
|
||||
BITMAPINFOHEADER MyBitmapHeader;
|
||||
u16 pal_ref;
|
||||
u32 BufferSize;
|
||||
s32 y, x, i;
|
||||
GRRLIB_texImg *my_texture = calloc(1, sizeof(GRRLIB_texImg));
|
||||
|
||||
if (my_texture != NULL) {
|
||||
// Fill file header structure
|
||||
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.bfReserved1 = (my_bmp[6] | my_bmp[7]<<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);
|
||||
// Fill the bitmap structure
|
||||
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.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.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.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.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.biClrImportant = (my_bmp[50] | my_bmp[51]<<8 | my_bmp[52]<<16 | my_bmp[53]<<24);
|
||||
// Fill file header structure
|
||||
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.bfReserved1 = (my_bmp[6] | my_bmp[7]<<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);
|
||||
// Fill the bitmap structure
|
||||
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.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.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.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.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.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);
|
||||
if (my_texture->data != NULL && MyBitmapFileHeader.bfType == 0x4D42) {
|
||||
RGBQUAD *Palette;
|
||||
my_texture->w = MyBitmapHeader.biWidth;
|
||||
my_texture->h = MyBitmapHeader.biHeight;
|
||||
switch(MyBitmapHeader.biBitCount) {
|
||||
case 32: // RGBA images
|
||||
i = 54;
|
||||
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
|
||||
for(x=0; x<MyBitmapHeader.biWidth; x++) {
|
||||
GRRLIB_SetPixelTotexImg(x, y, my_texture,
|
||||
RGBA(my_bmp[i+2], my_bmp[i+1], my_bmp[i], my_bmp[i+3]));
|
||||
i += 4;
|
||||
}
|
||||
my_texture->data = memalign(32, MyBitmapHeader.biWidth * MyBitmapHeader.biHeight * 4);
|
||||
if (my_texture->data != NULL && MyBitmapFileHeader.bfType == 0x4D42) {
|
||||
RGBQUAD *Palette;
|
||||
my_texture->w = MyBitmapHeader.biWidth;
|
||||
my_texture->h = MyBitmapHeader.biHeight;
|
||||
switch(MyBitmapHeader.biBitCount) {
|
||||
case 32: // RGBA images
|
||||
i = 54;
|
||||
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
|
||||
for(x=0; x<MyBitmapHeader.biWidth; x++) {
|
||||
GRRLIB_SetPixelTotexImg(x, y, my_texture,
|
||||
RGBA(my_bmp[i+2], my_bmp[i+1], my_bmp[i], my_bmp[i+3]));
|
||||
i += 4;
|
||||
}
|
||||
break;
|
||||
case 24: // truecolor images
|
||||
BufferSize = (MyBitmapHeader.biWidth % 4);
|
||||
i = 54;
|
||||
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
|
||||
for(x=0; x<MyBitmapHeader.biWidth; x++) {
|
||||
GRRLIB_SetPixelTotexImg(x, y, my_texture,
|
||||
RGBA(my_bmp[i+2], my_bmp[i+1], my_bmp[i], 0xFF));
|
||||
i += 3;
|
||||
}
|
||||
i += BufferSize; // Padding
|
||||
}
|
||||
break;
|
||||
case 24: // truecolor images
|
||||
BufferSize = (MyBitmapHeader.biWidth % 4);
|
||||
i = 54;
|
||||
for(y=MyBitmapHeader.biHeight-1; y>=0; y--) {
|
||||
for(x=0; x<MyBitmapHeader.biWidth; x++) {
|
||||
GRRLIB_SetPixelTotexImg(x, y, my_texture,
|
||||
RGBA(my_bmp[i+2], my_bmp[i+1], my_bmp[i], 0xFF));
|
||||
i += 3;
|
||||
}
|
||||
break;
|
||||
case 8: // 256 color images
|
||||
BufferSize = (int) MyBitmapHeader.biWidth;
|
||||
while(BufferSize % 4) {
|
||||
BufferSize++;
|
||||
i += BufferSize; // Padding
|
||||
}
|
||||
break;
|
||||
case 8: // 256 color images
|
||||
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;
|
||||
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++;
|
||||
}
|
||||
i += BufferSize; // Padding
|
||||
i += BufferSize; // Padding
|
||||
}
|
||||
free(Palette);
|
||||
break;
|
||||
case 4: // 16 color images
|
||||
BufferSize = (int)((MyBitmapHeader.biWidth*4) / 8.0);
|
||||
while(8*BufferSize < MyBitmapHeader.biWidth*4) {
|
||||
BufferSize++;
|
||||
}
|
||||
while(BufferSize % 4) {
|
||||
BufferSize++;
|
||||
}
|
||||
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);
|
||||
break;
|
||||
case 4: // 16 color images
|
||||
BufferSize = (int)((MyBitmapHeader.biWidth*4) / 8.0);
|
||||
while(8*BufferSize < MyBitmapHeader.biWidth*4) {
|
||||
BufferSize++;
|
||||
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));
|
||||
}
|
||||
while(BufferSize % 4) {
|
||||
BufferSize++;
|
||||
}
|
||||
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));
|
||||
}
|
||||
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 );
|
||||
i += BufferSize; // Padding
|
||||
}
|
||||
free(Palette);
|
||||
break;
|
||||
default:
|
||||
GRRLIB_ClearTex(my_texture);
|
||||
}
|
||||
GRRLIB_SetHandle( my_texture, 0, 0 );
|
||||
GRRLIB_FlushTex( 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.
|
||||
*/
|
||||
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));
|
||||
|
||||
if (my_texture == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
|
||||
jpeg_create_decompress(&cinfo);
|
||||
cinfo.err = jpeg_std_error(&jerr);
|
||||
cinfo.progress = NULL;
|
||||
|
|
|
@ -33,7 +33,7 @@ THE SOFTWARE.
|
|||
* @param hoth The height of the rectangle.
|
||||
* @param wpadx Specifies the x-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
|
||||
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 rect2w Specifies the width 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
|
||||
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 rect2w Specifies the width 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
|
||||
bool GRRLIB_RectOnRect (const int rect1x, const int rect1y,
|
||||
|
|
|
@ -76,7 +76,7 @@ void GRRLIB_Line (const f32 x1, const f32 y1,
|
|||
* @param width The width of the rectangle.
|
||||
* @param height The height of the rectangle.
|
||||
* @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
|
||||
void GRRLIB_Rectangle (const f32 x, const f32 y,
|
||||
|
|
|
@ -73,7 +73,7 @@ GRRLIB_blendMode GRRLIB_GetBlend (void) {
|
|||
|
||||
/**
|
||||
* 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
|
||||
void GRRLIB_SetAntiAliasing (const bool aa) {
|
||||
|
@ -82,10 +82,9 @@ void GRRLIB_SetAntiAliasing (const bool aa) {
|
|||
|
||||
/**
|
||||
* Get current anti-aliasing setting.
|
||||
* @return True if anti-aliasing is enabled.
|
||||
* @return Returns @c true if anti-aliasing is enabled.
|
||||
*/
|
||||
INLINE
|
||||
bool GRRLIB_GetAntiAliasing (void) {
|
||||
return GRRLIB_Settings.antialias;
|
||||
}
|
||||
|
||||
|
|
|
@ -671,7 +671,7 @@ PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, in
|
|||
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)
|
||||
{
|
||||
png_uint_32 rowbytes;
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef struct
|
|||
PNGU_u32 imgBitDepth; // In bitx
|
||||
PNGU_u32 imgColorType; // PNGU_COLOR_TYPE_*
|
||||
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
|
||||
PNGUCOLOR *trans; // Transparent colors
|
||||
} PNGUPROP;
|
||||
|
|
|
@ -43,7 +43,7 @@ to allow real-time loading and saving of graphical data, and thus requires
|
|||
libgrrlib <- 2D/3D graphics library
|
||||
├── libfat <- File I/O
|
||||
├── libjpeg <- JPEG image processor
|
||||
├── libpngu <- Wii wrapper for libpng
|
||||
├── libpngu <- Wrapper for libpng
|
||||
│ └── libpng <- PNG image processor
|
||||
└── libfreetype <- TrueType font processor
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue