mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-09-20 12:45:05 +00:00
[CHG] Pure cosmetic update - Made the code more readable and fixed some spelling errors.
This commit is contained in:
parent
c2086fbf93
commit
fc6019ae7b
1 changed files with 207 additions and 216 deletions
|
@ -27,7 +27,7 @@ static void RawTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int
|
|||
|
||||
/**
|
||||
* Clear screen with a specific color.
|
||||
* @param color the color to use to fill the screen.
|
||||
* @param color The color to use to fill the screen.
|
||||
*/
|
||||
inline void GRRLIB_FillScreen(u32 color) {
|
||||
GRRLIB_Rectangle(-40, -40, 680, 520, color, 1);
|
||||
|
@ -35,9 +35,9 @@ inline void GRRLIB_FillScreen(u32 color) {
|
|||
|
||||
/**
|
||||
* Draw a dot.
|
||||
* @param x specifies the x-coordinate of the dot.
|
||||
* @param y specifies the y-coordinate of the dot.
|
||||
* @param color the color of the dot in RGBA format.
|
||||
* @param x Specifies the x-coordinate of the dot.
|
||||
* @param y Specifies the y-coordinate of the dot.
|
||||
* @param color The color of the dot in RGBA format.
|
||||
*/
|
||||
inline void GRRLIB_Plot(f32 x, f32 y, u32 color) {
|
||||
Vector v[] = {{x,y,0.0f}};
|
||||
|
@ -47,9 +47,9 @@ inline void GRRLIB_Plot(f32 x, f32 y, u32 color) {
|
|||
|
||||
/**
|
||||
* Draw an array of points.
|
||||
* @param v array containing the points.
|
||||
* @param color the color of the points in RGBA format.
|
||||
* @param n number of points in the vector array.
|
||||
* @param v Array containing the points.
|
||||
* @param color The color of the points in RGBA format.
|
||||
* @param n Number of points in the vector array.
|
||||
*/
|
||||
void GRRLIB_NPlot(Vector v[], u32 color, long n) {
|
||||
GRRLIB_GXEngine(v, color, n, GX_POINTS);
|
||||
|
@ -57,11 +57,11 @@ void GRRLIB_NPlot(Vector v[], u32 color, long n) {
|
|||
|
||||
/**
|
||||
* Draw a line.
|
||||
* @param x1 start point for line for the x coordinate.
|
||||
* @param y1 start point for line for the y coordinate.
|
||||
* @param x2 end point for line for the x coordinate.
|
||||
* @param y2 end point for line for the x coordinate.
|
||||
* @param color line color in RGBA format.
|
||||
* @param x1 Starting point for line for the x coordinate.
|
||||
* @param y1 Starting point for line for the y coordinate.
|
||||
* @param x2 Ending point for line for the x coordinate.
|
||||
* @param y2 Ending point for line for the x coordinate.
|
||||
* @param color Line color in RGBA format.
|
||||
*/
|
||||
inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color) {
|
||||
Vector v[] = {{x1,y1,0.0f}, {x2,y2,0.0f}};
|
||||
|
@ -71,12 +71,12 @@ inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color) {
|
|||
|
||||
/**
|
||||
* Draw a rectangle.
|
||||
* @param x specifies the x-coordinate of the upper-left corner of the rectangle.
|
||||
* @param y specifies the y-coordinate of the upper-left corner of the rectangle.
|
||||
* @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 true to fill the rectangle with a color.
|
||||
* @param x Specifies the x-coordinate of the upper-left corner of the rectangle.
|
||||
* @param y Specifies the y-coordinate of the upper-left corner of the rectangle.
|
||||
* @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.
|
||||
*/
|
||||
inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8 filled) {
|
||||
f32 x2 = x+width;
|
||||
|
@ -94,11 +94,11 @@ inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8
|
|||
/**
|
||||
* Draw a circle.
|
||||
* @author Dark_Link
|
||||
* @param x
|
||||
* @param y
|
||||
* @param radius the radius of the circle.
|
||||
* @param color the color of the circle in RGBA format.
|
||||
* @param filled true to fill the circle with a color.
|
||||
* @param x Specifies the x-coordinate of the circle.
|
||||
* @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.
|
||||
*/
|
||||
inline void GRRLIB_Circle(f32 x, f32 y, f32 radius, u32 color, u8 filled) {
|
||||
Vector v[36];
|
||||
|
@ -124,9 +124,9 @@ inline void GRRLIB_Circle(f32 x, f32 y, f32 radius, u32 color, u8 filled) {
|
|||
|
||||
/**
|
||||
* Draw a polygon.
|
||||
* @param v
|
||||
* @param color the color of the polygon in RGBA format.
|
||||
* @param n
|
||||
* @param v The vector containing the coordinates of the polygon.
|
||||
* @param color The color of the filled polygon in RGBA format.
|
||||
* @param n Number of points in the vector.
|
||||
*/
|
||||
void GRRLIB_NGone(Vector v[], u32 color, long n) {
|
||||
GRRLIB_GXEngine(v, color, n, GX_LINESTRIP);
|
||||
|
@ -134,9 +134,9 @@ void GRRLIB_NGone(Vector v[], u32 color, long n) {
|
|||
|
||||
/**
|
||||
* Draw a filled polygon.
|
||||
* @param v
|
||||
* @param color the color of the filled polygon in RGBA format.
|
||||
* @param n
|
||||
* @param v The vector containing the coordinates of the polygon.
|
||||
* @param color The color of the filled polygon in RGBA format.
|
||||
* @param n Number of points in the vector.
|
||||
*/
|
||||
void GRRLIB_NGoneFilled(Vector v[], u32 color, long n) {
|
||||
GRRLIB_GXEngine(v, color, n, GX_TRIANGLEFAN);
|
||||
|
@ -144,10 +144,10 @@ void GRRLIB_NGoneFilled(Vector v[], u32 color, long n) {
|
|||
|
||||
/**
|
||||
* Initialize a tile set.
|
||||
* @param tex texture to initialize.
|
||||
* @param tilew widht of the tile.
|
||||
* @param tileh height of the tile.
|
||||
* @param tilestart offset for starting position.
|
||||
* @param tex The texture to initialize.
|
||||
* @param tilew Width of the tile.
|
||||
* @param tileh Height of the tile.
|
||||
* @param tilestart Offset for starting position. (Used in fonts)
|
||||
*/
|
||||
void GRRLIB_InitTileSet(struct GRRLIB_texImg *tex, unsigned int tilew, unsigned int tileh, unsigned int tilestart) {
|
||||
tex->tilew = tilew;
|
||||
|
@ -162,7 +162,7 @@ void GRRLIB_InitTileSet(struct GRRLIB_texImg *tex, unsigned int tilew, unsigned
|
|||
/**
|
||||
* Load a texture from a buffer.
|
||||
* @param my_png the PNG buffer to load.
|
||||
* @return A GRRLIB_texImg structure filled with PNG informations.
|
||||
* @return A GRRLIB_texImg structure filled with image informations.
|
||||
*/
|
||||
GRRLIB_texImg GRRLIB_LoadTexturePNG(const unsigned char my_png[]) {
|
||||
PNGUPROP imgProp;
|
||||
|
@ -182,7 +182,7 @@ GRRLIB_texImg GRRLIB_LoadTexturePNG(const unsigned char my_png[]) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert a raw bmp (RGB, no alpha) to 4x4RGBA.
|
||||
* Convert a raw BMP (RGB, no alpha) to 4x4RGBA.
|
||||
* @author DragonMinded
|
||||
* @param src
|
||||
* @param dst
|
||||
|
@ -224,10 +224,10 @@ static void RawTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int
|
|||
|
||||
/**
|
||||
* Load a texture from a buffer.
|
||||
* Take Care to have a JPG finnishing by 0xFF 0xD9 !!!!
|
||||
* Take care to have the JPG finnish with 0xFF 0xD9!!
|
||||
* @author DrTwox
|
||||
* @param my_jpg the JPEG buffer to load.
|
||||
* @return A GRRLIB_texImg structure filled with PNG informations.
|
||||
* @param my_jpg The JPEG buffer to load.
|
||||
* @return A GRRLIB_texImg structure filled with image informations.
|
||||
*/
|
||||
GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
|
@ -237,7 +237,7 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
|
|||
unsigned int i;
|
||||
|
||||
if ((my_jpg[0]==0xff) && (my_jpg[1]==0xd8) && (my_jpg[2]==0xff)) {
|
||||
while(1) {
|
||||
while(true) {
|
||||
if ((my_jpg[n]==0xff) && (my_jpg[n+1]==0xd9))
|
||||
break;
|
||||
n++;
|
||||
|
@ -267,7 +267,7 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
|
|||
my_texture.data = memalign(32, cinfo.output_width * cinfo.output_height * 4);
|
||||
RawTo4x4RGBA(tempBuffer, my_texture.data, cinfo.output_width, cinfo.output_height);
|
||||
|
||||
/* Done - do cleanup and release memory */
|
||||
/* Done - Do cleanup and release allocated memory */
|
||||
jpeg_finish_decompress(&cinfo);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
free(row_pointer[0]);
|
||||
|
@ -283,11 +283,11 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
|
|||
|
||||
/**
|
||||
* Print formatted output.
|
||||
* @param xpos
|
||||
* @param ypos
|
||||
* @param bmf
|
||||
* @param zoom
|
||||
* @param text text to draw.
|
||||
* @param xpos Specifies the x-coordinate of the upper-left corner of the text.
|
||||
* @param ypos Specifies the y-coordinate of the upper-left corner of the text.
|
||||
* @param bmf The ByteMap font to use.
|
||||
* @param zoom This is a factor by which the text size will be increase or decrease.
|
||||
* @param text Text to draw.
|
||||
* @param ... Optional arguments.
|
||||
*/
|
||||
void GRRLIB_PrintBMF(f32 xpos, f32 ypos, GRRLIB_bytemapFont bmf, f32 zoom, const char *text, ...) {
|
||||
|
@ -321,16 +321,15 @@ void GRRLIB_PrintBMF(f32 xpos, f32 ypos, GRRLIB_bytemapFont bmf, f32 zoom, const
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
GRRLIB_FlushTex(tex_BMfont);
|
||||
|
||||
GRRLIB_DrawImg(0, 0, tex_BMfont, 0, 1, 1, 0xFFFFFFFF);
|
||||
|
||||
free(tex_BMfont.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a ByteMap font structure from a buffer.
|
||||
* @param my_bmf the ByteMap font buffer to load.
|
||||
* @param my_bmf The ByteMap font buffer to load.
|
||||
* @return A GRRLIB_bytemapFont structure filled with BMF informations.
|
||||
*/
|
||||
GRRLIB_bytemapFont GRRLIB_LoadBMF(const unsigned char my_bmf[]) {
|
||||
|
@ -384,11 +383,10 @@ GRRLIB_bytemapFont GRRLIB_LoadBMF(const unsigned char my_bmf[]) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Free memory.
|
||||
* Free memory allocated by ByteMap fonts.
|
||||
* @param bmf a GRRLIB_bytemapFont structure.
|
||||
*/
|
||||
void GRRLIB_FreeBMF(GRRLIB_bytemapFont bmf)
|
||||
{
|
||||
void GRRLIB_FreeBMF(GRRLIB_bytemapFont bmf) {
|
||||
unsigned int i;
|
||||
|
||||
for (i=0; i<bmf.nbChar; i++) {
|
||||
|
@ -401,8 +399,8 @@ void GRRLIB_FreeBMF(GRRLIB_bytemapFont bmf)
|
|||
|
||||
/**
|
||||
* Load a texture from a buffer.
|
||||
* @param my_img the JPEG or PNG buffer to load.
|
||||
* @return A GRRLIB_texImg structure filled with imgage informations.
|
||||
* @param my_img The JPEG or PNG buffer to load.
|
||||
* @return A GRRLIB_texImg structure filled with image informations.
|
||||
*/
|
||||
GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_img[]) {
|
||||
if (my_img[0]==0xFF && my_img[1]==0xD8 && my_img[2]==0xFF) {
|
||||
|
@ -415,8 +413,8 @@ GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_img[]) {
|
|||
|
||||
/**
|
||||
* Create an empty texture.
|
||||
* @param w width of the new texture to create.
|
||||
* @param h height of the new texture to create.
|
||||
* @param w Width of the new texture to create.
|
||||
* @param h Height of the new texture to create.
|
||||
* @return A GRRLIB_texImg structure newly created.
|
||||
*/
|
||||
GRRLIB_texImg GRRLIB_CreateEmptyTexture(unsigned int w, unsigned int h) {
|
||||
|
@ -438,13 +436,13 @@ GRRLIB_texImg GRRLIB_CreateEmptyTexture(unsigned int w, unsigned int h) {
|
|||
|
||||
/**
|
||||
* Draw a texture.
|
||||
* @param xpos specifies the x-coordinate of the upper-left corner.
|
||||
* @param ypos specifies the y-coordinate of the upper-left corner.
|
||||
* @param tex texture to draw.
|
||||
* @param degrees angle of rotation.
|
||||
* @param scaleX specifies the x-coordinate scale. -1 could be used for flipping the texture horizontally.
|
||||
* @param scaleY specifies the y-coordinate scale. -1 could be used for flipping the texture vertically.
|
||||
* @param color
|
||||
* @param xpos Specifies the x-coordinate of the upper-left corner.
|
||||
* @param ypos Specifies the y-coordinate of the upper-left corner.
|
||||
* @param tex The texture to draw.
|
||||
* @param degrees Angle of rotation.
|
||||
* @param scaleX Specifies the x-coordinate scale. -1 could be used for flipping the texture horizontally.
|
||||
* @param scaleY Specifies the y-coordinate scale. -1 could be used for flipping the texture vertically.
|
||||
* @param color Color in RGBA format.
|
||||
*/
|
||||
inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color) {
|
||||
GXTexObj texObj;
|
||||
|
@ -495,14 +493,14 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees,
|
|||
|
||||
/**
|
||||
* Draw a tile.
|
||||
* @param xpos specifies the x-coordinate of the upper-left corner.
|
||||
* @param ypos specifies the y-coordinate of the upper-left corner.
|
||||
* @param tex texture containing the tile to draw.
|
||||
* @param degrees angle of rotation.
|
||||
* @param scaleX specifies the x-coordinate scale. -1 could be used for flipping the texture horizontally.
|
||||
* @param scaleY specifies the y-coordinate scale. -1 could be used for flipping the texture vertically.
|
||||
* @param color
|
||||
* @param frame specifies the frame to draw.
|
||||
* @param xpos Specifies the x-coordinate of the upper-left corner.
|
||||
* @param ypos Specifies the y-coordinate of the upper-left corner.
|
||||
* @param tex The texture containing the tile to draw.
|
||||
* @param degrees Angle of rotation.
|
||||
* @param scaleX Specifies the x-coordinate scale. -1 could be used for flipping the texture horizontally.
|
||||
* @param scaleY Specifies the y-coordinate scale. -1 could be used for flipping the texture vertically.
|
||||
* @param color Color in RGBA format.
|
||||
* @param frame Specifies the frame to draw.
|
||||
*/
|
||||
inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color, int frame) {
|
||||
GXTexObj texObj;
|
||||
|
@ -558,12 +556,12 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees
|
|||
|
||||
/**
|
||||
* Print formatted output.
|
||||
* @param xpos specifies the x-coordinate of the upper-left corner of the text.
|
||||
* @param ypos specifies the y-coordinate of the upper-left corner of the text.
|
||||
* @param tex texture containing the character set.
|
||||
* @param color text color in RGBA format. The alpha channel is used to change the opacity of the text.
|
||||
* @param zoom this is a factor by which the text size will be increase or decrease.
|
||||
* @param text text to draw.
|
||||
* @param xpos Specifies the x-coordinate of the upper-left corner of the text.
|
||||
* @param ypos Specifies the y-coordinate of the upper-left corner of the text.
|
||||
* @param tex The texture containing the character set.
|
||||
* @param color Text color in RGBA format. The alpha channel is used to change the opacity of the text.
|
||||
* @param zoom This is a factor by which the text size will be increase or decrease.
|
||||
* @param text Text to draw.
|
||||
* @param ... Optional arguments.
|
||||
*/
|
||||
void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, const char *text, ...) {
|
||||
|
@ -582,13 +580,13 @@ void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, c
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified point lies within the specified rectangle.
|
||||
* @param hotx specifies the x-coordinate of the upper-left corner of the rectangle.
|
||||
* @param hoty specifies the y-coordinate of the upper-left corner of the rectangle.
|
||||
* @param hotw the width of the rectangle.
|
||||
* @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.
|
||||
* Determine whether the specified point lies within the specified rectangle.
|
||||
* @param hotx Specifies the x-coordinate of the upper-left corner of the rectangle.
|
||||
* @param hoty Specifies the y-coordinate of the upper-left corner of the rectangle.
|
||||
* @param hotw The width of the rectangle.
|
||||
* @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.
|
||||
*/
|
||||
bool GRRLIB_PtInRect(int hotx, int hoty, int hotw, int hoth, int wpadx, int wpady) {
|
||||
|
@ -596,15 +594,15 @@ bool GRRLIB_PtInRect(int hotx, int hoty, int hotw, int hoth, int wpadx, int wpad
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines whether a specified rectangle lies within another rectangle.
|
||||
* @param rect1x specifies the x-coordinate of the upper-left corner of the rectangle.
|
||||
* @param rect1y specifies the y-coordinate of the upper-left corner of the rectangle.
|
||||
* @param rect1w specifies the width of the rectangle.
|
||||
* @param rect1h specifies the height of the rectangle.
|
||||
* @param rect2x specifies the x-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 rect2h specifies the height of the rectangle.
|
||||
* Determine whether a specified rectangle lies within another rectangle.
|
||||
* @param rect1x Specifies the x-coordinate of the upper-left corner of the rectangle.
|
||||
* @param rect1y Specifies the y-coordinate of the upper-left corner of the rectangle.
|
||||
* @param rect1w Specifies the width of the rectangle.
|
||||
* @param rect1h Specifies the height of the rectangle.
|
||||
* @param rect2x Specifies the x-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 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.
|
||||
*/
|
||||
bool GRRLIB_RectInRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2x, int rect2y, int rect2w, int rect2h) {
|
||||
|
@ -613,15 +611,15 @@ bool GRRLIB_RectInRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines whether a part of a specified rectangle lies on another rectangle.
|
||||
* @param rect1x specifies the x-coordinate of the upper-left corner of the first rectangle.
|
||||
* @param rect1y specifies the y-coordinate of the upper-left corner of the first rectangle.
|
||||
* @param rect1w specifies the width of the first rectangle.
|
||||
* @param rect1h specifies the height of the first rectangle.
|
||||
* @param rect2x specifies the x-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 rect2h specifies the height of the second rectangle.
|
||||
* Determine whether a part of a specified rectangle lies on another rectangle.
|
||||
* @param rect1x Specifies the x-coordinate of the upper-left corner of the first rectangle.
|
||||
* @param rect1y Specifies the y-coordinate of the upper-left corner of the first rectangle.
|
||||
* @param rect1w Specifies the width of the first rectangle.
|
||||
* @param rect1h Specifies the height of the first rectangle.
|
||||
* @param rect2x Specifies the x-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 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.
|
||||
*/
|
||||
bool GRRLIB_RectOnRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2x, int rect2y, int rect2w, int rect2h) {
|
||||
|
@ -633,7 +631,7 @@ bool GRRLIB_RectOnRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2
|
|||
|
||||
|
||||
/**
|
||||
* Clips the drawing area to an rectangle
|
||||
* Clip the drawing area to an rectangle
|
||||
* @param x The x-coordinate of the rectangle.
|
||||
* @param y The y-coordinate of the rectangle.
|
||||
* @param width The width of the rectangle.
|
||||
|
@ -645,17 +643,16 @@ void GRRLIB_ClipDrawing( int x, int y, int width, int height ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Resets the clipping to normal
|
||||
* Reset the clipping to normal
|
||||
*/
|
||||
void GRRLIB_ClipReset() {
|
||||
GX_SetClipMode( GX_CLIP_DISABLE );
|
||||
GX_SetScissor( 0, 0, rmode->fbWidth, rmode->efbHeight );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a texture's X and Y handles. (e.g. for rotation)
|
||||
* @param tex GRRLIB Texture
|
||||
* Set a texture's X and Y handles. (e.g. for rotation)
|
||||
* @param tex The texture to set the handle on.
|
||||
* @param x The handle's x-coordinate
|
||||
* @param y The handle's y-coordinate
|
||||
*/
|
||||
|
@ -667,8 +664,8 @@ void GRRLIB_SetHandle( GRRLIB_texImg * tex, int x, int y ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Centers a texture's handles. (e.g. for rotation)
|
||||
* @param tex GRRLIB Texture
|
||||
* Center a texture's handles. (e.g. for rotation)
|
||||
* @param tex The texture to center.
|
||||
*/
|
||||
void GRRLIB_SetMidHandle( GRRLIB_texImg * tex ) {
|
||||
tex->handlex = 0;
|
||||
|
@ -680,9 +677,9 @@ void GRRLIB_SetMidHandle( GRRLIB_texImg * tex ) {
|
|||
|
||||
/**
|
||||
* Return the color value of a pixel from a GRRLIB_texImg.
|
||||
* @param x specifies the x-coordinate of the pixel in the texture.
|
||||
* @param y specifies the y-coordinate of the pixel in the texture.
|
||||
* @param tex texture to get the color from.
|
||||
* @param x Specifies the x-coordinate of the pixel in the texture.
|
||||
* @param y Specifies the y-coordinate of the pixel in the texture.
|
||||
* @param tex The texture to get the color from.
|
||||
* @return The color of a pixel in RGBA format.
|
||||
*/
|
||||
u32 GRRLIB_GetPixelFromtexImg(int x, int y, GRRLIB_texImg tex) {
|
||||
|
@ -703,10 +700,10 @@ u32 GRRLIB_GetPixelFromtexImg(int x, int y, GRRLIB_texImg tex) {
|
|||
/**
|
||||
* Set the color value of a pixel to a GRRLIB_texImg.
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param x specifies the x-coordinate of the pixel in the texture.
|
||||
* @param y specifies the y-coordinate of the pixel in the texture.
|
||||
* @param tex texture to set the color to.
|
||||
* @param color the color of the pixel in RGBA format.
|
||||
* @param x Specifies the x-coordinate of the pixel in the texture.
|
||||
* @param y Specifies the y-coordinate of the pixel in the texture.
|
||||
* @param tex The texture to set the color to.
|
||||
* @param color The color of the pixel in RGBA format.
|
||||
*/
|
||||
void GRRLIB_SetPixelTotexImg(int x, int y, GRRLIB_texImg tex, u32 color) {
|
||||
u8 *truc = (u8*)tex.data;
|
||||
|
@ -721,20 +718,19 @@ void GRRLIB_SetPixelTotexImg(int x, int y, GRRLIB_texImg tex, u32 color) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Writes the contents of a texture in the data cache down to main memory.
|
||||
* Write the contents of a texture in the data cache down to main memory.
|
||||
* For performance the CPU holds a data cache where modifications are stored before they get written down to mainmemory.
|
||||
* @param tex the texture to flush.
|
||||
* @param tex The texture to flush.
|
||||
*/
|
||||
void GRRLIB_FlushTex(GRRLIB_texImg tex)
|
||||
{
|
||||
void GRRLIB_FlushTex(GRRLIB_texImg tex) {
|
||||
DCFlushRange(tex.data, tex.w * tex.h * 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a texture to gray scale.
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param texsrc the texture source.
|
||||
* @param texdest the texture grayscaled destination.
|
||||
* @param texsrc The texture source.
|
||||
* @param texdest The texture grayscaled destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_Grayscale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
||||
unsigned int x, y;
|
||||
|
@ -756,8 +752,8 @@ void GRRLIB_BMFX_Grayscale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
|||
/**
|
||||
* Invert colors of the texture.
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param texsrc the texture source.
|
||||
* @param texdest the texture destination.
|
||||
* @param texsrc The texture source.
|
||||
* @param texdest The texture destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
||||
unsigned int x, y;
|
||||
|
@ -766,7 +762,6 @@ void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
|||
for (y = 0; y < texsrc.h; y++) {
|
||||
for (x = 0; x < texsrc.w; x++) {
|
||||
color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
|
||||
|
||||
GRRLIB_SetPixelTotexImg(x, y, texdest,
|
||||
((0xFFFFFF - (color >> 8 & 0xFFFFFF)) << 8) | (color & 0xFF));
|
||||
}
|
||||
|
@ -776,8 +771,8 @@ void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
|||
/**
|
||||
* Flip texture horizontal.
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param texsrc the texture source.
|
||||
* @param texdest the texture destination.
|
||||
* @param texsrc The texture source.
|
||||
* @param texdest The texture destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_FlipH(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
||||
unsigned int x, y, txtWidth = texsrc.w - 1;
|
||||
|
@ -793,8 +788,8 @@ void GRRLIB_BMFX_FlipH(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
|||
/**
|
||||
* Flip texture vertical.
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param texsrc the texture source.
|
||||
* @param texdest the texture destination.
|
||||
* @param texsrc The texture source.
|
||||
* @param texdest The texture destination.
|
||||
*/
|
||||
void GRRLIB_BMFX_FlipV(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
||||
unsigned int x, y, texHeight = texsrc.h - 1;
|
||||
|
@ -808,11 +803,11 @@ void GRRLIB_BMFX_FlipV(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Blur a texture.
|
||||
* A texture effect. (Blur)
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param texsrc the texture source.
|
||||
* @param texdest the texture destination.
|
||||
* @param factor the blur factor.
|
||||
* @param texsrc The texture source.
|
||||
* @param texdest The texture destination.
|
||||
* @param factor The blur factor.
|
||||
*/
|
||||
void GRRLIB_BMFX_Blur(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
|
||||
int numba = (1+(factor<<1))*(1+(factor<<1));
|
||||
|
@ -863,10 +858,10 @@ void GRRLIB_BMFX_Blur(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
|
|||
}
|
||||
|
||||
/**
|
||||
* A texture effect.
|
||||
* A texture effect. (Pixelate)
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param texsrc the texture source.
|
||||
* @param texdest the texture destination.
|
||||
* @param texsrc The texture source.
|
||||
* @param texdest The texture destination.
|
||||
* @param factor The factor level of the effect.
|
||||
*/
|
||||
void GRRLIB_BMFX_Pixelate(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
|
||||
|
@ -887,10 +882,10 @@ void GRRLIB_BMFX_Pixelate(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int facto
|
|||
}
|
||||
|
||||
/**
|
||||
* A texture effect.
|
||||
* A texture effect. (Scatter)
|
||||
* @see GRRLIB_FlushTex
|
||||
* @param texsrc the texture source.
|
||||
* @param texdest the texture destination.
|
||||
* @param texsrc The texture source.
|
||||
* @param texdest The texture destination.
|
||||
* @param factor The factor level of the effect.
|
||||
*/
|
||||
void GRRLIB_BMFX_Scatter(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
|
||||
|
@ -917,11 +912,7 @@ void GRRLIB_BMFX_Scatter(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param v
|
||||
* @param color
|
||||
* @param n
|
||||
* @param fmt
|
||||
* Draws a vector.
|
||||
*/
|
||||
void GRRLIB_GXEngine(Vector v[], u32 color, long n, u8 fmt) {
|
||||
int i;
|
||||
|
@ -973,10 +964,10 @@ void GRRLIB_Init() {
|
|||
memset(gp_fifo, 0, DEFAULT_FIFO_SIZE);
|
||||
GX_Init(gp_fifo, DEFAULT_FIFO_SIZE);
|
||||
|
||||
// clears the bg to color and clears the z buffer
|
||||
// Clears the BG to color and clears the z-buffer
|
||||
GX_SetCopyClear((GXColor){ 0, 0, 0, 0xff }, GX_MAX_Z24);
|
||||
|
||||
// other gx setup
|
||||
// Other GX setup
|
||||
yscale = GX_GetYScaleFactor(rmode->efbHeight, rmode->xfbHeight);
|
||||
xfbHeight = GX_SetDispCopyYScale(yscale);
|
||||
GX_SetScissor(0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||
|
@ -993,8 +984,8 @@ void GRRLIB_Init() {
|
|||
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||
|
||||
|
||||
// setup the vertex descriptor
|
||||
// tells the flipper to expect direct data
|
||||
// Setup the vertex descriptor
|
||||
// Tells the flipper to expect direct data
|
||||
GX_ClearVtxDesc();
|
||||
GX_InvVtxCache();
|
||||
GX_InvalidateTexAll();
|
||||
|
@ -1035,7 +1026,7 @@ void GRRLIB_Init() {
|
|||
void GRRLIB_Render() {
|
||||
GX_DrawDone();
|
||||
|
||||
fb ^= 1; // flip framebuffer
|
||||
fb ^= 1; // Flip framebuffer
|
||||
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
GX_SetColorUpdate(GX_TRUE);
|
||||
GX_CopyDisp(xfb[fb], GX_TRUE);
|
||||
|
@ -1049,7 +1040,7 @@ void GRRLIB_Render() {
|
|||
*/
|
||||
void GRRLIB_Exit() {
|
||||
GX_SetClipMode( GX_CLIP_DISABLE );
|
||||
GX_SetScissor( 0, 0, WinW, WinH );
|
||||
GX_SetScissor( 0, 0, rmode->fbWidth, rmode->efbHeight );
|
||||
GRRLIB_FillScreen( 0x000000FF );
|
||||
GRRLIB_Render();
|
||||
GX_Flush();
|
||||
|
|
Loading…
Reference in a new issue