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,13 +24,15 @@ 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) {
return;
}
GX_SetTexCopySrc(posx, posy, tex->w, tex->h); GX_SetTexCopySrc(posx, posy, tex->w, tex->h);
GX_SetTexCopyDst(tex->w, tex->h, GX_TF_RGBA8, GX_FALSE); GX_SetTexCopyDst(tex->w, tex->h, GX_TF_RGBA8, GX_FALSE);
GX_CopyTex(tex->data, GX_FALSE); GX_CopyTex(tex->data, GX_FALSE);
@ -39,7 +41,6 @@ void GRRLIB_Screen2Texture (int posx, int posy, GRRLIB_texImg *tex, bool clear)
if(clear == true) { if(clear == true) {
GX_CopyDisp(xfb[!fb], GX_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
@ -154,13 +154,16 @@ 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;
}
int width = 0;
int height = 0;
PNGUPROP imgProp;
IMGCTX ctx = PNGU_SelectImageFromBuffer(my_png);
PNGU_GetImageProperties(ctx, &imgProp); PNGU_GetImageProperties(ctx, &imgProp);
my_texture->data = PNGU_DecodeTo4x4RGBA8(ctx, imgProp.imgWidth, imgProp.imgHeight, &width, &height, NULL); my_texture->data = PNGU_DecodeTo4x4RGBA8(ctx, imgProp.imgWidth, imgProp.imgHeight, &width, &height, NULL);
if (my_texture->data != NULL) { if (my_texture->data != NULL) {
@ -174,7 +177,7 @@ GRRLIB_texImg* GRRLIB_LoadTexturePNG (const u8 *my_png) {
GRRLIB_FlushTex( my_texture ); GRRLIB_FlushTex( my_texture );
} }
PNGU_ReleaseImageContext(ctx); PNGU_ReleaseImageContext(ctx);
}
return my_texture; return my_texture;
} }
@ -204,14 +207,18 @@ 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);
@ -332,7 +339,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp) {
GRRLIB_SetHandle( my_texture, 0, 0 ); GRRLIB_SetHandle( my_texture, 0, 0 );
GRRLIB_FlushTex( my_texture ); 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
``` ```