mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-24 15:52:20 +00:00
Reduce variable scope
This commit is contained in:
parent
95c915f5f8
commit
7e35d7b62d
5 changed files with 114 additions and 134 deletions
|
@ -26,9 +26,9 @@ THE SOFTWARE.
|
|||
|
||||
// User should not directly modify these
|
||||
Mtx _GRR_view; // Should be static as soon as all light functions needing this var will be in this file ;)
|
||||
static guVector _GRR_cam = {0.0F, 0.0F, 0.0F},
|
||||
_GRR_up = {0.0F, 1.0F, 0.0F},
|
||||
_GRR_look = {0.0F, 0.0F, -100.0F};
|
||||
static guVector _GRR_cam = {0.0f, 0.0f, 0.0f},
|
||||
_GRR_up = {0.0f, 1.0f, 0.0f},
|
||||
_GRR_look = {0.0f, 0.0f, -100.0f};
|
||||
static guVector _GRRaxisx = (guVector){1, 0, 0}; // DO NOT MODIFY!!!
|
||||
static guVector _GRRaxisy = (guVector){0, 1, 0}; // Even at runtime
|
||||
static guVector _GRRaxisz = (guVector){0, 0, 1}; // NOT ever!
|
||||
|
@ -134,7 +134,7 @@ void GRRLIB_2dMode() {
|
|||
GX_LoadProjectionMtx(m, GX_ORTHOGRAPHIC);
|
||||
|
||||
guMtxIdentity(view);
|
||||
guMtxTransApply(view, view, 0, 0, -100.0F);
|
||||
guMtxTransApply(view, view, 0, 0, -100.0f);
|
||||
GX_LoadPosMtxImm(view, GX_PNMTX0);
|
||||
|
||||
GX_ClearVtxDesc();
|
||||
|
|
|
@ -176,7 +176,7 @@ int GRRLIB_Init (void) {
|
|||
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
||||
|
||||
guMtxIdentity(GXmodelView2D);
|
||||
guMtxTransApply(GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -100.0F);
|
||||
guMtxTransApply(GXmodelView2D, GXmodelView2D, 0.0f, 0.0f, -100.0f);
|
||||
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
|
||||
|
||||
guOrtho(perspective, 0.0f, rmode->efbHeight, 0.0f, rmode->fbWidth, 0.0f, 1000.0f);
|
||||
|
@ -223,9 +223,7 @@ void GRRLIB_Exit (void) {
|
|||
if (done == true || is_setup == false) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
done = true;
|
||||
}
|
||||
|
||||
// Allow write access to the full screen
|
||||
GX_SetClipMode( GX_CLIP_DISABLE );
|
||||
|
@ -233,8 +231,10 @@ void GRRLIB_Exit (void) {
|
|||
|
||||
// We empty both frame buffers on our way out
|
||||
// otherwise dead frames are sometimes seen when starting the next app
|
||||
GRRLIB_FillScreen( 0x000000FF ); GRRLIB_Render();
|
||||
GRRLIB_FillScreen( 0x000000FF ); GRRLIB_Render();
|
||||
GRRLIB_FillScreen( 0x000000FF );
|
||||
GRRLIB_Render();
|
||||
GRRLIB_FillScreen( 0x000000FF );
|
||||
GRRLIB_Render();
|
||||
|
||||
// Shut down the GX engine
|
||||
GX_DrawDone();
|
||||
|
|
|
@ -196,7 +196,7 @@ int main() {
|
|||
}
|
||||
else if(demo == 4) {
|
||||
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0); // We say we use the Normal coord to map the texture (since there is no textcoord with this torus)
|
||||
guLightFrustum(mv, 1.0F, -1.0F, 1.0F, -1.0F, 1.0F, 0.5F, 0.5F, 0.5F, 0.5F); // we are projecting the texture like a light (ie : videoprojector))
|
||||
guLightFrustum(mv, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f); // we are projecting the texture like a light (ie : videoprojector))
|
||||
|
||||
guMtxScale(mr, -2.8f, -2.8f, 0.0f); //here is a little scaling to fit the torus
|
||||
guMtxConcat(mr, mv, mv);
|
||||
|
@ -218,7 +218,7 @@ int main() {
|
|||
}
|
||||
else if(demo == 5) {
|
||||
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0); // We say we use the Normal coord to map the texture (since there is no textcoord with this torus)
|
||||
guLightFrustum(mv, 1.0F, -1.0F, 1.0F, -1.0F, 1.0F, 0.5F, 0.5F, 0.5F, 0.5F); // we are projecting the texture like a light (ie : videoprojector))
|
||||
guLightFrustum(mv, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f); // we are projecting the texture like a light (ie : videoprojector))
|
||||
guMtxRotDeg(rx, 'X', a); // Here i rotate the texture
|
||||
guMtxRotDeg(ry, 'Y', a*2); // in the inverse way
|
||||
guMtxRotDeg(rz, 'Z', a*3); // of the
|
||||
|
|
|
@ -10,71 +10,61 @@
|
|||
|
||||
|
||||
int main() {
|
||||
int offset1, offset2, offset3, offset4;
|
||||
int periode1, periode2, periode3, periode4;
|
||||
int length1, length2, length3, length4;
|
||||
int amp1, amp2, amp3, amp4;
|
||||
int origine1, origine2, origine3, origine4;
|
||||
int adc1, adc2, adc3, adc4;
|
||||
float siny1, siny2, siny3, siny4;
|
||||
int x;
|
||||
float pas1, pas2, pas3, pas4;
|
||||
|
||||
// Initialise the Graphics & Video subsystem
|
||||
GRRLIB_Init();
|
||||
|
||||
// Initialise the Wiimotes
|
||||
// Initialise the Wii Remotes
|
||||
WPAD_Init();
|
||||
|
||||
|
||||
adc1=0;
|
||||
offset1=0;
|
||||
origine1=0;
|
||||
length1=1280;
|
||||
amp1=100;
|
||||
periode1=1;
|
||||
pas1=(periode1*360.0F)/length1;
|
||||
siny1 = offset1*pas1;
|
||||
const int adc1=0;
|
||||
const int offset1=0;
|
||||
const int origin1=0;
|
||||
const int length1=1280;
|
||||
const int amp1=100;
|
||||
const int period1=1;
|
||||
const float pas1=(period1*360.0f)/length1;
|
||||
float siny1 = offset1*pas1;
|
||||
|
||||
adc2=1;
|
||||
offset2=0;
|
||||
origine2=0;
|
||||
length2=1280;
|
||||
amp2=40;
|
||||
periode2=2;
|
||||
pas2=(periode2*360.0F)/length2;
|
||||
siny2 = offset2*pas2;
|
||||
const int adc2=1;
|
||||
const int offset2=0;
|
||||
const int origin2=0;
|
||||
const int length2=1280;
|
||||
const int amp2=40;
|
||||
const int period2=2;
|
||||
const float pas2=(period2*360.0f)/length2;
|
||||
float siny2 = offset2*pas2;
|
||||
|
||||
adc3=-3;
|
||||
offset3=0;
|
||||
origine3=0;
|
||||
length3=1280;
|
||||
amp3=30;
|
||||
periode3=1;
|
||||
pas3=(periode3*360.0F)/length3;
|
||||
siny3 = offset3*pas3;
|
||||
const int adc3=-3;
|
||||
const int offset3=0;
|
||||
const int origin3=0;
|
||||
const int length3=1280;
|
||||
const int amp3=30;
|
||||
const int period3=1;
|
||||
const float pas3=(period3*360.0f)/length3;
|
||||
float siny3 = offset3*pas3;
|
||||
|
||||
adc4=-7;
|
||||
offset4=0;
|
||||
origine4=0;
|
||||
length4=1280;
|
||||
amp4=70;
|
||||
periode4=1;
|
||||
pas4=(periode4*360.0F)/length4;
|
||||
siny4 = offset4*pas4;
|
||||
const int adc4=-7;
|
||||
const int offset4=0;
|
||||
const int origin4=0;
|
||||
const int length4=1280;
|
||||
const int amp4=70;
|
||||
const int period4=1;
|
||||
const float pas4=(period4*360.0f)/length4;
|
||||
float siny4 = offset4*pas4;
|
||||
|
||||
|
||||
while (1) {
|
||||
GRRLIB_FillScreen(0x000000FF);
|
||||
WPAD_ScanPads(); // Scan the Wiimotes
|
||||
WPAD_ScanPads(); // Scan the Wii Remotes
|
||||
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;
|
||||
float old1=siny1;
|
||||
float old2=siny2;
|
||||
float old3=siny3;
|
||||
float old4=siny4;
|
||||
const float old1=siny1;
|
||||
const float old2=siny2;
|
||||
const float old3=siny3;
|
||||
const float old4=siny4;
|
||||
|
||||
|
||||
for (x=0; x<=640; x++) {
|
||||
for (u16 x=0; x<=640; x++) {
|
||||
siny1+=pas1;
|
||||
siny2+=pas2;
|
||||
siny3+=pas3;
|
||||
|
@ -83,11 +73,11 @@ int main() {
|
|||
GX_Begin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GX_Position3f32(x, 0, 0);
|
||||
GX_Color1u32(0x000000FF);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origine1)+(sin(DegToRad(siny2))*amp2+origine2)+(sin(DegToRad(siny3))*amp3+origine3)+(sin(DegToRad(siny4))*amp4+origine4)+240, 0);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origin1)+(sin(DegToRad(siny2))*amp2+origin2)+(sin(DegToRad(siny3))*amp3+origin3)+(sin(DegToRad(siny4))*amp4+origin4)+240, 0);
|
||||
GX_Color1u32(0xFF00007F);
|
||||
GX_End();
|
||||
GX_Begin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origine1)+(sin(DegToRad(siny2))*amp2+origine2)+(sin(DegToRad(siny3))*amp3+origine3)+(sin(DegToRad(siny4))*amp4+origine4)+240, 0);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origin1)+(sin(DegToRad(siny2))*amp2+origin2)+(sin(DegToRad(siny3))*amp3+origin3)+(sin(DegToRad(siny4))*amp4+origin4)+240, 0);
|
||||
GX_Color1u32(0xFF00007F);
|
||||
GX_Position3f32(x, 480, 0);
|
||||
GX_Color1u32(0x000000FF);
|
||||
|
|
|
@ -10,16 +10,6 @@
|
|||
|
||||
|
||||
int main() {
|
||||
int offset1, offset2, offset3, offset4;
|
||||
int periode1, periode2, periode3, periode4;
|
||||
int length1, length2, length3, length4;
|
||||
int amp1, amp2, amp3, amp4;
|
||||
int origine1, origine2, origine3, origine4;
|
||||
int adc1, adc2, adc3, adc4;
|
||||
float siny1, siny2, siny3, siny4;
|
||||
int x;
|
||||
float pas1, pas2, pas3, pas4;
|
||||
|
||||
// Initialise the Graphics & Video subsystem
|
||||
GRRLIB_Init();
|
||||
|
||||
|
@ -27,54 +17,54 @@ int main() {
|
|||
PAD_Init();
|
||||
|
||||
|
||||
adc1=0;
|
||||
offset1=0;
|
||||
origine1=0;
|
||||
length1=1280;
|
||||
amp1=100;
|
||||
periode1=1;
|
||||
pas1=(periode1*360.0F)/length1;
|
||||
siny1 = offset1*pas1;
|
||||
const int adc1=0;
|
||||
const int offset1=0;
|
||||
const int origin1=0;
|
||||
const int length1=1280;
|
||||
const int amp1=100;
|
||||
const int period1=1;
|
||||
const float pas1=(period1*360.0f)/length1;
|
||||
float siny1 = offset1*pas1;
|
||||
|
||||
adc2=1;
|
||||
offset2=0;
|
||||
origine2=0;
|
||||
length2=1280;
|
||||
amp2=40;
|
||||
periode2=2;
|
||||
pas2=(periode2*360.0F)/length2;
|
||||
siny2 = offset2*pas2;
|
||||
const int adc2=1;
|
||||
const int offset2=0;
|
||||
const int origin2=0;
|
||||
const int length2=1280;
|
||||
const int amp2=40;
|
||||
const int period2=2;
|
||||
const float pas2=(period2*360.0f)/length2;
|
||||
float siny2 = offset2*pas2;
|
||||
|
||||
adc3=-3;
|
||||
offset3=0;
|
||||
origine3=0;
|
||||
length3=1280;
|
||||
amp3=30;
|
||||
periode3=1;
|
||||
pas3=(periode3*360.0F)/length3;
|
||||
siny3 = offset3*pas3;
|
||||
const int adc3=-3;
|
||||
const int offset3=0;
|
||||
const int origin3=0;
|
||||
const int length3=1280;
|
||||
const int amp3=30;
|
||||
const int period3=1;
|
||||
const float pas3=(period3*360.0f)/length3;
|
||||
float siny3 = offset3*pas3;
|
||||
|
||||
adc4=-7;
|
||||
offset4=0;
|
||||
origine4=0;
|
||||
length4=1280;
|
||||
amp4=70;
|
||||
periode4=1;
|
||||
pas4=(periode4*360.0F)/length4;
|
||||
siny4 = offset4*pas4;
|
||||
const int adc4=-7;
|
||||
const int offset4=0;
|
||||
const int origin4=0;
|
||||
const int length4=1280;
|
||||
const int amp4=70;
|
||||
const int period4=1;
|
||||
const float pas4=(period4*360.0f)/length4;
|
||||
float siny4 = offset4*pas4;
|
||||
|
||||
|
||||
while (1) {
|
||||
GRRLIB_FillScreen(0x000000FF);
|
||||
PAD_ScanPads(); // Scan the GameCube controllers
|
||||
if (PAD_ButtonsDown(0) & PAD_BUTTON_START) break;
|
||||
float old1=siny1;
|
||||
float old2=siny2;
|
||||
float old3=siny3;
|
||||
float old4=siny4;
|
||||
const float old1=siny1;
|
||||
const float old2=siny2;
|
||||
const float old3=siny3;
|
||||
const float old4=siny4;
|
||||
|
||||
|
||||
for (x=0; x<=640; x++) {
|
||||
for (u16 x=0; x<=640; x++) {
|
||||
siny1+=pas1;
|
||||
siny2+=pas2;
|
||||
siny3+=pas3;
|
||||
|
@ -83,11 +73,11 @@ int main() {
|
|||
GX_Begin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GX_Position3f32(x, 0, 0);
|
||||
GX_Color1u32(0x000000FF);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origine1)+(sin(DegToRad(siny2))*amp2+origine2)+(sin(DegToRad(siny3))*amp3+origine3)+(sin(DegToRad(siny4))*amp4+origine4)+240, 0);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origin1)+(sin(DegToRad(siny2))*amp2+origin2)+(sin(DegToRad(siny3))*amp3+origin3)+(sin(DegToRad(siny4))*amp4+origin4)+240, 0);
|
||||
GX_Color1u32(0xFF00007F);
|
||||
GX_End();
|
||||
GX_Begin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origine1)+(sin(DegToRad(siny2))*amp2+origine2)+(sin(DegToRad(siny3))*amp3+origine3)+(sin(DegToRad(siny4))*amp4+origine4)+240, 0);
|
||||
GX_Position3f32(x, (sin(DegToRad(siny1))*amp1+origin1)+(sin(DegToRad(siny2))*amp2+origin2)+(sin(DegToRad(siny3))*amp3+origin3)+(sin(DegToRad(siny4))*amp4+origin4)+240, 0);
|
||||
GX_Color1u32(0xFF00007F);
|
||||
GX_Position3f32(x, 480, 0);
|
||||
GX_Color1u32(0x000000FF);
|
||||
|
|
Loading…
Reference in a new issue