mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[CHG] GRRLIB_Rectangle is calling directly GX_Begin/GX_End
[CHG] Documentation improvement
This commit is contained in:
parent
0ac411a9e8
commit
2e8876f899
3 changed files with 33 additions and 10 deletions
|
@ -30,13 +30,11 @@ THE SOFTWARE.
|
||||||
/**
|
/**
|
||||||
* A helper function for the YCbCr -> RGB conversion.
|
* A helper function for the YCbCr -> RGB conversion.
|
||||||
* Clamps the given value into a range of 0 - 255 and thus preventing an overflow.
|
* Clamps the given value into a range of 0 - 255 and thus preventing an overflow.
|
||||||
* @param Value The value to clamp.
|
* @param Value The value to clamp. Using float to increase the precision. This makes a full spectrum (0 - 255) possible.
|
||||||
* @return Returns a clean, clamped unsigned char.
|
* @return Returns a clean, clamped unsigned char.
|
||||||
*/
|
*/
|
||||||
INLINE
|
INLINE
|
||||||
u8 GRRLIB_ClampVar8 (f32 Value) {
|
u8 GRRLIB_ClampVar8 (f32 Value) {
|
||||||
/* Using float to increase the precision.
|
|
||||||
This makes a full spectrum (0 - 255) possible. */
|
|
||||||
Value = roundf(Value);
|
Value = roundf(Value);
|
||||||
if (Value < 0) Value = 0 ;
|
if (Value < 0) Value = 0 ;
|
||||||
else if (Value > 255) Value = 255 ;
|
else if (Value > 255) Value = 255 ;
|
||||||
|
|
|
@ -27,6 +27,10 @@ THE SOFTWARE.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a vector.
|
* Draws a vector.
|
||||||
|
* @param v The vector to draw.
|
||||||
|
* @param color The color of the vector in RGBA format.
|
||||||
|
* @param n Number of points in the vector.
|
||||||
|
* @param fmt Type of primitive.
|
||||||
*/
|
*/
|
||||||
INLINE
|
INLINE
|
||||||
void GRRLIB_GXEngine (const guVector v[], const u32 color[], const long n,
|
void GRRLIB_GXEngine (const guVector v[], const u32 color[], const long n,
|
||||||
|
|
|
@ -84,12 +84,33 @@ INLINE
|
||||||
void GRRLIB_Rectangle (const f32 x, const f32 y,
|
void GRRLIB_Rectangle (const f32 x, const f32 y,
|
||||||
const f32 width, const f32 height,
|
const f32 width, const f32 height,
|
||||||
const u32 color, const u8 filled) {
|
const u32 color, const u8 filled) {
|
||||||
f32 x2 = x+width;
|
f32 x2 = x + width;
|
||||||
f32 y2 = y+height;
|
f32 y2 = y + height;
|
||||||
guVector v[] = { {x,y,0.0f}, {x2,y,0.0f}, {x2,y2,0.0f}, {x,y2,0.0f},
|
|
||||||
{x,y,0.0f} };
|
|
||||||
u32 ncolor[] = {color,color,color,color,color};
|
|
||||||
|
|
||||||
if (!filled) GRRLIB_NGone (v, ncolor, 5) ;
|
if (filled) {
|
||||||
else GRRLIB_NGoneFilled(v, ncolor, 4) ;
|
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
|
||||||
|
GX_Position3f32(x,y,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_Position3f32(x2,y,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_Position3f32(x2,y2,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_Position3f32(x,y2,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_End();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 5);
|
||||||
|
GX_Position3f32(x,y,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_Position3f32(x2,y,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_Position3f32(x2,y2,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_Position3f32(x,y2,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_Position3f32(x,y,0.0f);
|
||||||
|
GX_Color1u32(color);
|
||||||
|
GX_End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue