mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
Properly format NEED_GRRLIB_FUNCTION example
This commit is contained in:
parent
5126a84654
commit
3af649b2a9
1 changed files with 177 additions and 181 deletions
|
@ -1,11 +1,11 @@
|
||||||
/*===========================================
|
/*===========================================
|
||||||
NoNameNo
|
NoNameNo
|
||||||
Since i cant code all these new function alone,
|
Since I cant code all these new function alone,
|
||||||
i really need help to find the best way to provide
|
I really need help to find the best way to provide
|
||||||
GRRLIB functions to all these new effets in this demo.
|
GRRLIB functions to all these new effects in this demo.
|
||||||
With the help of the doc you can try also to find how it works,
|
With the help of the doc you can try also to find how it works,
|
||||||
for exemple i didnt succes fully coded a specular position and direction....
|
for example I didn't success fully coded a specular position and direction...
|
||||||
So i repeat i need HELP !!! ;)
|
So I repeat I need HELP !!! ;)
|
||||||
============================================*/
|
============================================*/
|
||||||
#include <grrlib.h>
|
#include <grrlib.h>
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ int main() {
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
WPAD_ScanPads();
|
WPAD_ScanPads();
|
||||||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
|
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
|
||||||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS) if(demo<5) demo++;
|
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS && demo < 5) demo++;
|
||||||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS) if(demo>0) demo--;
|
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS && demo > 0) demo--;
|
||||||
|
|
||||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
GRRLIB_3dMode(0.1, 1000, 45, false, true);
|
||||||
|
|
||||||
if(demo==0) {
|
if(demo==0) {
|
||||||
/////////////////// DEFINE A DIFUSE LIGHT /////////////////////////////////////////////
|
/////////////////// DEFINE A DIFFUSE LIGHT /////////////////////////////////////////////
|
||||||
guVector l0pos={0.0f,20.0f,0.0f};
|
guVector l0pos={0.0f,20.0f,0.0f};
|
||||||
guVecMultiply(_GRR_view, &l0pos, &l0pos);
|
guVecMultiply(_GRR_view, &l0pos, &l0pos);
|
||||||
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
|
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
|
||||||
|
@ -66,7 +66,7 @@ int main() {
|
||||||
GX_SetNumChans(1);
|
GX_SetNumChans(1);
|
||||||
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP,GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant (3th param)
|
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP,GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant (3th param)
|
||||||
|
|
||||||
/////////////////////// Define MAterial and Ambiant color and draw object /////////////////////////////////////
|
/////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
|
||||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
|
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
|
||||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||||
|
@ -80,9 +80,8 @@ int main() {
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Diffuse Light Source");
|
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Diffuse Light Source");
|
||||||
}
|
}
|
||||||
|
else if(demo==1) {
|
||||||
if(demo==1) {
|
/////////////////// DEFINE 2 DIFFUSE LIGHTS /////////////////////////////////////////////
|
||||||
/////////////////// DEFINE 2 DIFUSE LIGHTS /////////////////////////////////////////////
|
|
||||||
guVector l0pos={0.0f,20.0f,0.0f};
|
guVector l0pos={0.0f,20.0f,0.0f};
|
||||||
guVecMultiply(_GRR_view, &l0pos, &l0pos);
|
guVecMultiply(_GRR_view, &l0pos, &l0pos);
|
||||||
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
|
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
|
||||||
|
@ -103,7 +102,7 @@ int main() {
|
||||||
GX_SetNumChans(1);
|
GX_SetNumChans(1);
|
||||||
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0|GX_LIGHT1, GX_DF_CLAMP, GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant (3th param)
|
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0|GX_LIGHT1, GX_DF_CLAMP, GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant (3th param)
|
||||||
|
|
||||||
/////////////////////// Define MAterial and Ambiant color and draw object /////////////////////////////////////
|
/////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
|
||||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
|
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
|
||||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||||
|
@ -117,13 +116,12 @@ int main() {
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 2 Diffuse Light Sources");
|
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 2 Diffuse Light Sources");
|
||||||
}
|
}
|
||||||
|
else if(demo==2) {
|
||||||
if(demo==2) {
|
/////////////////// DEFINE A SPECULAR LIGHT /////////////////////////////////////////////
|
||||||
/////////////////// DEFINE A SPECUALR LIGHT /////////////////////////////////////////////
|
|
||||||
guVector l0dir={0.0f,0.0f,0.0f};
|
guVector l0dir={0.0f,0.0f,0.0f};
|
||||||
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
|
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
|
||||||
|
|
||||||
GX_InitLightShininess(&MyLight0, 20); // entre 4 et 255 !!!
|
GX_InitLightShininess(&MyLight0, 20); // between 4 and 255 !!!
|
||||||
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||||
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
|
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
|
||||||
|
|
||||||
|
@ -141,7 +139,7 @@ int main() {
|
||||||
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV);
|
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV);
|
||||||
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ONE, GX_CC_RASC, GX_CC_ZERO);
|
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ONE, GX_CC_RASC, GX_CC_ZERO);
|
||||||
|
|
||||||
/////////////////////// Define MAterial and Ambiant color and draw object /////////////////////////////////////
|
/////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
|
||||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||||
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||||
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
||||||
|
@ -157,13 +155,12 @@ int main() {
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 20");
|
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 20");
|
||||||
}
|
}
|
||||||
|
else if(demo==3) {
|
||||||
if(demo==3) {
|
/////////////////// DEFINE A SPECULAR LIGHT /////////////////////////////////////////////
|
||||||
/////////////////// DEFINE A SPECUALR LIGHT /////////////////////////////////////////////
|
|
||||||
guVector l0dir={0.0f,0.0f,0.0f};
|
guVector l0dir={0.0f,0.0f,0.0f};
|
||||||
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
|
GX_InitSpecularDir(&MyLight0, l0dir.x,l0dir.y,l0dir.z);
|
||||||
|
|
||||||
GX_InitLightShininess(&MyLight0, 200); // entre 4 et 255 !!!
|
GX_InitLightShininess(&MyLight0, 200); // between 4 and 255 !!!
|
||||||
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
GX_InitLightColor(&MyLight0, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||||
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
|
GX_LoadLightObj(&MyLight0, GX_LIGHT0);
|
||||||
|
|
||||||
|
@ -181,7 +178,7 @@ int main() {
|
||||||
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV);
|
GX_SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV);
|
||||||
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ONE, GX_CC_RASC, GX_CC_ZERO);
|
GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_CPREV, GX_CC_ONE, GX_CC_RASC, GX_CC_ZERO);
|
||||||
|
|
||||||
/////////////////////// Define MAterial and Ambiant color and draw object /////////////////////////////////////
|
/////////////////////// Define Material and Ambiant color and draw object /////////////////////////////////////
|
||||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||||
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||||
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
||||||
|
@ -197,7 +194,7 @@ int main() {
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 200");
|
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 200");
|
||||||
}
|
}
|
||||||
if(demo==4) {
|
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)
|
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))
|
||||||
|
|
||||||
|
@ -219,7 +216,7 @@ int main() {
|
||||||
GRRLIB_2dMode();
|
GRRLIB_2dMode();
|
||||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Mapping Using textgen from normal coord");
|
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Mapping Using textgen from normal coord");
|
||||||
}
|
}
|
||||||
if(demo==5) {
|
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)
|
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(rx, 'X', a); // Here i rotate the texture
|
||||||
|
@ -248,7 +245,6 @@ int main() {
|
||||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Environmental Mapping");
|
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Environmental Mapping");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GRRLIB_Render();
|
GRRLIB_Render();
|
||||||
}
|
}
|
||||||
GRRLIB_FreeTexture(tex_font);
|
GRRLIB_FreeTexture(tex_font);
|
||||||
|
|
Loading…
Reference in a new issue