mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
Use proper types and reduce variables scope
This commit is contained in:
parent
45068cade7
commit
fd9a59a348
9 changed files with 87 additions and 103 deletions
|
@ -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
|
||||||
|
@ -190,7 +190,8 @@ void GRRLIB_ObjectViewScale(f32 scalx, f32 scaly, f32 scalz) {
|
||||||
* @param angz z rotation angle of the object.
|
* @param angz z rotation angle of the object.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_ObjectViewRotate(f32 angx, f32 angy, f32 angz) {
|
void GRRLIB_ObjectViewRotate(f32 angx, f32 angy, f32 angz) {
|
||||||
Mtx m, rx,ry,rz;
|
Mtx m;
|
||||||
|
Mtx rx, ry, rz;
|
||||||
|
|
||||||
guMtxIdentity(m);
|
guMtxIdentity(m);
|
||||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||||
|
@ -245,7 +246,7 @@ void GRRLIB_ObjectViewEnd(void) {
|
||||||
*/
|
*/
|
||||||
void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
|
void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
|
||||||
Mtx ObjTransformationMtx;
|
Mtx ObjTransformationMtx;
|
||||||
Mtx m, rx,ry,rz;
|
Mtx m;
|
||||||
Mtx mv, mvi;
|
Mtx mv, mvi;
|
||||||
|
|
||||||
guMtxIdentity(ObjTransformationMtx);
|
guMtxIdentity(ObjTransformationMtx);
|
||||||
|
@ -258,6 +259,7 @@ void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 ang
|
||||||
}
|
}
|
||||||
|
|
||||||
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)) {
|
if((angx !=0.0f) || (angy !=0.0f) || (angz !=0.0f)) {
|
||||||
|
Mtx rx, ry, rz;
|
||||||
guMtxIdentity(m);
|
guMtxIdentity(m);
|
||||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||||
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
||||||
|
@ -297,7 +299,7 @@ void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 ang
|
||||||
*/
|
*/
|
||||||
void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
|
void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz) {
|
||||||
Mtx ObjTransformationMtx;
|
Mtx ObjTransformationMtx;
|
||||||
Mtx m, rx,ry,rz;
|
Mtx m;
|
||||||
Mtx mv, mvi;
|
Mtx mv, mvi;
|
||||||
|
|
||||||
guMtxIdentity(ObjTransformationMtx);
|
guMtxIdentity(ObjTransformationMtx);
|
||||||
|
@ -317,6 +319,7 @@ void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32
|
||||||
}
|
}
|
||||||
|
|
||||||
if((angx != 0.0f) || (angy != 0.0f) || (angz != 0.0f)) {
|
if((angx != 0.0f) || (angy != 0.0f) || (angz != 0.0f)) {
|
||||||
|
Mtx rx, ry, rz;
|
||||||
guMtxIdentity(m);
|
guMtxIdentity(m);
|
||||||
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
guMtxRotAxisDeg(rx, &_GRRaxisx, angx);
|
||||||
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
guMtxRotAxisDeg(ry, &_GRRaxisy, angy);
|
||||||
|
@ -372,35 +375,28 @@ void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) {
|
||||||
* @param col Color of the torus.
|
* @param col Color of the torus.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col) {
|
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col) {
|
||||||
int i, j;
|
const f32 ringDelta = 2.0 * M_PI / rings;
|
||||||
f32 theta, phi, theta1;
|
const f32 sideDelta = 2.0 * M_PI / nsides;
|
||||||
f32 cosTheta, sinTheta;
|
|
||||||
f32 cosTheta1, sinTheta1;
|
|
||||||
f32 ringDelta, sideDelta;
|
|
||||||
f32 cosPhi, sinPhi, dist;
|
|
||||||
|
|
||||||
ringDelta = 2.0 * M_PI / rings;
|
f32 theta = 0.0;
|
||||||
sideDelta = 2.0 * M_PI / nsides;
|
f32 cosTheta = 1.0;
|
||||||
|
f32 sinTheta = 0.0;
|
||||||
theta = 0.0;
|
for (int i = rings - 1; i >= 0; i--) {
|
||||||
cosTheta = 1.0;
|
const f32 theta1 = theta + ringDelta;
|
||||||
sinTheta = 0.0;
|
const f32 cosTheta1 = cos(theta1);
|
||||||
for (i = rings - 1; i >= 0; i--) {
|
const f32 sinTheta1 = sin(theta1);
|
||||||
theta1 = theta + ringDelta;
|
|
||||||
cosTheta1 = cos(theta1);
|
|
||||||
sinTheta1 = sin(theta1);
|
|
||||||
if(filled == true) {
|
if(filled == true) {
|
||||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (nsides + 1));
|
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (nsides + 1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (nsides + 1));
|
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (nsides + 1));
|
||||||
}
|
}
|
||||||
phi = 0.0;
|
f32 phi = 0.0;
|
||||||
for (j = nsides; j >= 0; j--) {
|
for (int j = nsides; j >= 0; j--) {
|
||||||
phi += sideDelta;
|
phi += sideDelta;
|
||||||
cosPhi = cos(phi);
|
const f32 cosPhi = cos(phi);
|
||||||
sinPhi = sin(phi);
|
const f32 sinPhi = sin(phi);
|
||||||
dist = R + r * cosPhi;
|
const f32 dist = R + r * cosPhi;
|
||||||
|
|
||||||
GX_Position3f32(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
GX_Position3f32(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||||
GX_Normal3f32(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
GX_Normal3f32(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||||
|
@ -425,29 +421,25 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col)
|
||||||
* @param col Color of the sphere.
|
* @param col Color of the sphere.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
||||||
int i, j;
|
for(int i = 0; i <= lats; i++) {
|
||||||
f32 lat0, z0, zr0,
|
const f32 lat0 = M_PI * (-0.5F + (f32) (i - 1) / lats);
|
||||||
lat1, z1, zr1,
|
const f32 z0 = sin(lat0);
|
||||||
lng, x, y;
|
const f32 zr0 = cos(lat0);
|
||||||
|
|
||||||
for(i = 0; i <= lats; i++) {
|
const f32 lat1 = M_PI * (-0.5F + (f32) i / lats);
|
||||||
lat0 = M_PI * (-0.5F + (f32) (i - 1) / lats);
|
const f32 z1 = sin(lat1);
|
||||||
z0 = sin(lat0);
|
const f32 zr1 = cos(lat1);
|
||||||
zr0 = cos(lat0);
|
|
||||||
|
|
||||||
lat1 = M_PI * (-0.5F + (f32) i / lats);
|
|
||||||
z1 = sin(lat1);
|
|
||||||
zr1 = cos(lat1);
|
|
||||||
if(filled == true) {
|
if(filled == true) {
|
||||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (longs + 1));
|
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (longs + 1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (longs + 1));
|
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (longs + 1));
|
||||||
}
|
}
|
||||||
for(j = 0; j <= longs; j++) {
|
for(int j = 0; j <= longs; j++) {
|
||||||
lng = 2 * M_PI * (f32) (j - 1) / longs;
|
const f32 lng = 2 * M_PI * (f32) (j - 1) / longs;
|
||||||
x = cos(lng);
|
const f32 x = cos(lng);
|
||||||
y = sin(lng);
|
const f32 y = sin(lng);
|
||||||
|
|
||||||
GX_Position3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
GX_Position3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
||||||
GX_Normal3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
GX_Normal3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
||||||
|
@ -531,18 +523,15 @@ void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
||||||
* @param col Color of the cylinder.
|
* @param col Color of the cylinder.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
int i;
|
|
||||||
f32 dx, dy;
|
|
||||||
|
|
||||||
if(filled == true) {
|
if(filled == true) {
|
||||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (d+1));
|
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (d+1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1));
|
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1));
|
||||||
}
|
}
|
||||||
for(i = 0; i <= d; i++) {
|
for(int i = 0; i <= d; i++) {
|
||||||
dx = cosf( M_PI * 2.0f * i / d );
|
const f32 dx = cosf( M_PI * 2.0f * i / d );
|
||||||
dy = sinf( M_PI * 2.0f * i / d );
|
const f32 dy = sinf( M_PI * 2.0f * i / d );
|
||||||
GX_Position3f32( r * dx, -0.5f * h, r * dy );
|
GX_Position3f32( r * dx, -0.5f * h, r * dy );
|
||||||
GX_Normal3f32( dx, 0.0f, dy );
|
GX_Normal3f32( dx, 0.0f, dy );
|
||||||
GX_Color1u32(col);
|
GX_Color1u32(col);
|
||||||
|
@ -561,7 +550,7 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
GX_Position3f32(0.0f, -0.5f * h, 0.0f);
|
GX_Position3f32(0.0f, -0.5f * h, 0.0f);
|
||||||
GX_Normal3f32(0.0f, -1.0f, 0.0f);
|
GX_Normal3f32(0.0f, -1.0f, 0.0f);
|
||||||
GX_Color1u32(col);
|
GX_Color1u32(col);
|
||||||
for(i = 0; i <= d; i++) {
|
for(int i = 0; i <= d; i++) {
|
||||||
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), -0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), -0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
||||||
GX_Normal3f32(0.0f, -1.0f, 0.0f);
|
GX_Normal3f32(0.0f, -1.0f, 0.0f);
|
||||||
GX_Color1u32(col);
|
GX_Color1u32(col);
|
||||||
|
@ -577,7 +566,7 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
GX_Position3f32(0.0f, 0.5f * h, 0.0f);
|
GX_Position3f32(0.0f, 0.5f * h, 0.0f);
|
||||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||||
GX_Color1u32(col);
|
GX_Color1u32(col);
|
||||||
for(i = 0; i <= d; i++) {
|
for(int i = 0; i <= d; i++) {
|
||||||
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
||||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||||
GX_Color1u32(col);
|
GX_Color1u32(col);
|
||||||
|
@ -594,18 +583,15 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
* @param col Color of the cone.
|
* @param col Color of the cone.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
|
void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
int i;
|
|
||||||
f32 dx, dy;
|
|
||||||
|
|
||||||
if(filled == true) {
|
if(filled == true) {
|
||||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (d+1));
|
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (d+1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1));
|
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1));
|
||||||
}
|
}
|
||||||
for(i = 0; i <= d; i++) {
|
for(int i = 0; i <= d; i++) {
|
||||||
dx = cosf( M_PI * 2.0f * i / d );
|
const f32 dx = cosf( M_PI * 2.0f * i / d );
|
||||||
dy = sinf( M_PI * 2.0f * i / d );
|
const f32 dy = sinf( M_PI * 2.0f * i / d );
|
||||||
GX_Position3f32( 0, -0.5f * h,0);
|
GX_Position3f32( 0, -0.5f * h,0);
|
||||||
GX_Normal3f32( dx, 0.0f, dy );
|
GX_Normal3f32( dx, 0.0f, dy );
|
||||||
GX_Color1u32(col);
|
GX_Color1u32(col);
|
||||||
|
@ -624,7 +610,7 @@ void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
GX_Position3f32(0.0f, 0.5f * h, 0.0f);
|
GX_Position3f32(0.0f, 0.5f * h, 0.0f);
|
||||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||||
GX_Color1u32(col);
|
GX_Color1u32(col);
|
||||||
for(i = 0; i <= d; i++) {
|
for(int i = 0; i <= d; i++) {
|
||||||
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
||||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||||
GX_Color1u32(col);
|
GX_Color1u32(col);
|
||||||
|
@ -642,12 +628,10 @@ void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||||
* @param col Color in RGBA format.
|
* @param col Color in RGBA format.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 col) {
|
void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 col) {
|
||||||
f32 x, y;
|
const f32 tmpy = h / 2.0f;
|
||||||
|
const f32 tmpx = w / 2.0f;
|
||||||
f32 tmpy = h/2.0f;
|
const u16 tmp = ((w / wstep) * 2) + 2;
|
||||||
f32 tmpx = w/2.0f;
|
for ( f32 y = -tmpy; y <= tmpy; y += hstep )
|
||||||
int tmp = ((w/wstep)*2)+2;
|
|
||||||
for ( y = -tmpy; y <= tmpy; y += hstep )
|
|
||||||
{
|
{
|
||||||
if(filled == true) {
|
if(filled == true) {
|
||||||
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, tmp);
|
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, tmp);
|
||||||
|
@ -655,7 +639,7 @@ void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 c
|
||||||
else {
|
else {
|
||||||
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, tmp);
|
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, tmp);
|
||||||
}
|
}
|
||||||
for ( x = -tmpx; x <= tmpx; x += wstep )
|
for ( f32 x = -tmpx; x <= tmpx; x += wstep )
|
||||||
{
|
{
|
||||||
GX_Position3f32( x, y, 0.0f );
|
GX_Position3f32( x, y, 0.0f );
|
||||||
GX_Normal3f32( 0.0f, 0.0f, 1.0f);
|
GX_Normal3f32( 0.0f, 0.0f, 1.0f);
|
||||||
|
@ -744,7 +728,7 @@ void GRRLIB_SetLightSpec(u8 num, guVector dir, f32 shininess, u32 lightcolor, u3
|
||||||
|
|
||||||
/////////////////////// Define Material and Ambient color and draw object /////////////////////////////////////
|
/////////////////////// Define Material and Ambient color and draw object /////////////////////////////////////
|
||||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0xFF}); // specular ambient forced to black
|
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0xFF}); // specular ambient forced to black
|
||||||
GX_SetChanMatColor(GX_COLOR1, (GXColor) { R(speccolor), G(speccolor), B(speccolor), 0xFF }); // couleur du reflet specular
|
GX_SetChanMatColor(GX_COLOR1, (GXColor) { R(speccolor), G(speccolor), B(speccolor), 0xFF }); // specular reflection color
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
Copyright (c) 2009-2017 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
|
||||||
|
@ -44,8 +44,8 @@ THE SOFTWARE.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// GRRLIB_clipping.h - Clipping control
|
// GRRLIB_clipping.h - Clipping control
|
||||||
INLINE void GRRLIB_ClipReset (void);
|
INLINE void GRRLIB_ClipReset (void);
|
||||||
INLINE void GRRLIB_ClipDrawing (const int x, const int y,
|
INLINE void GRRLIB_ClipDrawing (const u32 x, const u32 y,
|
||||||
const int width, const int height);
|
const u32 width, const u32 height);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// GRRLIB_collision.h - Collision detection
|
// GRRLIB_collision.h - Collision detection
|
||||||
|
@ -66,16 +66,16 @@ INLINE bool GRRLIB_RectOnRect (const int rect1x, const int rect1y,
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// GRRLIB_fbComplex.h -
|
// GRRLIB_fbComplex.h -
|
||||||
INLINE void GRRLIB_NPlot (const guVector v[], const u32 color[],
|
INLINE void GRRLIB_NPlot (const guVector v[], const u32 color[],
|
||||||
const long n);
|
const u16 n);
|
||||||
INLINE void GRRLIB_NGone (const guVector v[], const u32 color[],
|
INLINE void GRRLIB_NGone (const guVector v[], const u32 color[],
|
||||||
const long n);
|
const u16 n);
|
||||||
INLINE void GRRLIB_NGoneFilled (const guVector v[], const u32 color[],
|
INLINE void GRRLIB_NGoneFilled (const guVector v[], const u32 color[],
|
||||||
const long n);
|
const u16 n);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// GRRLIB_fbGX.h -
|
// GRRLIB_fbGX.h -
|
||||||
INLINE void GRRLIB_GXEngine (const guVector v[], const u32 color[],
|
INLINE void GRRLIB_GXEngine (const guVector v[], const u32 color[],
|
||||||
const long n, const u8 fmt);
|
const u16 n, const u8 fmt);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// GRRLIB_fbSimple.h -
|
// GRRLIB_fbSimple.h -
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
Copyright (c) 2009-2017 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
|
||||||
|
@ -42,8 +42,8 @@ void GRRLIB_ClipReset (void) {
|
||||||
* @param height The height of the rectangle.
|
* @param height The height of the rectangle.
|
||||||
*/
|
*/
|
||||||
INLINE
|
INLINE
|
||||||
void GRRLIB_ClipDrawing (const int x, const int y,
|
void GRRLIB_ClipDrawing (const u32 x, const u32 y,
|
||||||
const int width, const int height) {
|
const u32 width, const u32 height) {
|
||||||
GX_SetClipMode( GX_CLIP_ENABLE );
|
GX_SetClipMode( GX_CLIP_ENABLE );
|
||||||
GX_SetScissor( x, y, width, height );
|
GX_SetScissor( x, y, width, height );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
Copyright (c) 2009-2017 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
|
||||||
|
@ -29,10 +29,10 @@ THE SOFTWARE.
|
||||||
* Draw an array of points.
|
* Draw an array of points.
|
||||||
* @param v Array containing the points.
|
* @param v Array containing the points.
|
||||||
* @param color The color of the points in RGBA format.
|
* @param color The color of the points in RGBA format.
|
||||||
* @param n Number of points in the vector array.
|
* @param n Number of points in the vector array. The maximum is 65536.
|
||||||
*/
|
*/
|
||||||
INLINE
|
INLINE
|
||||||
void GRRLIB_NPlot (const guVector v[], const u32 color[], const long n) {
|
void GRRLIB_NPlot (const guVector v[], const u32 color[], const u16 n) {
|
||||||
GRRLIB_GXEngine(v, color, n, GX_POINTS);
|
GRRLIB_GXEngine(v, color, n, GX_POINTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,10 +40,10 @@ void GRRLIB_NPlot (const guVector v[], const u32 color[], const long n) {
|
||||||
* Draw a polygon.
|
* Draw a polygon.
|
||||||
* @param v The vector containing the coordinates of the polygon.
|
* @param v The vector containing the coordinates of the polygon.
|
||||||
* @param color The color of the filled polygon in RGBA format.
|
* @param color The color of the filled polygon in RGBA format.
|
||||||
* @param n Number of points in the vector.
|
* @param n Number of points in the vector. The maximum is 65536.
|
||||||
*/
|
*/
|
||||||
INLINE
|
INLINE
|
||||||
void GRRLIB_NGone (const guVector v[], const u32 color[], const long n) {
|
void GRRLIB_NGone (const guVector v[], const u32 color[], const u16 n) {
|
||||||
GRRLIB_GXEngine(v, color, n, GX_LINESTRIP);
|
GRRLIB_GXEngine(v, color, n, GX_LINESTRIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ void GRRLIB_NGone (const guVector v[], const u32 color[], const long n) {
|
||||||
* Draw a filled polygon.
|
* Draw a filled polygon.
|
||||||
* @param v The vector containing the coordinates of the polygon.
|
* @param v The vector containing the coordinates of the polygon.
|
||||||
* @param color The color of the filled polygon in RGBA format.
|
* @param color The color of the filled polygon in RGBA format.
|
||||||
* @param n Number of points in the vector.
|
* @param n Number of points in the vector. The maximum is 65536.
|
||||||
*/
|
*/
|
||||||
INLINE
|
INLINE
|
||||||
void GRRLIB_NGoneFilled (const guVector v[], const u32 color[], const long n) {
|
void GRRLIB_NGoneFilled (const guVector v[], const u32 color[], const u16 n) {
|
||||||
GRRLIB_GXEngine(v, color, n, GX_TRIANGLEFAN);
|
GRRLIB_GXEngine(v, color, n, GX_TRIANGLEFAN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -29,14 +29,14 @@ THE SOFTWARE.
|
||||||
* Draws a vector.
|
* Draws a vector.
|
||||||
* @param v The vector to draw.
|
* @param v The vector to draw.
|
||||||
* @param color The color of the vector in RGBA format.
|
* @param color The color of the vector in RGBA format.
|
||||||
* @param n Number of points in the vector.
|
* @param n Number of points in the vector. The maximum is 65536.
|
||||||
* @param fmt Type of primitive.
|
* @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 u16 n,
|
||||||
const u8 fmt) {
|
const u8 fmt) {
|
||||||
GX_Begin(fmt, GX_VTXFMT0, n);
|
GX_Begin(fmt, GX_VTXFMT0, n);
|
||||||
for (int i = 0; i < n; i++) {
|
for (u16 i = 0; i < n; i++) {
|
||||||
GX_Position3f32(v[i].x, v[i].y, v[i].z);
|
GX_Position3f32(v[i].x, v[i].y, v[i].z);
|
||||||
GX_Color1u32(color[i]);
|
GX_Color1u32(color[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue