mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 06:52: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
|
||||
Since i cant code all these new function alone,
|
||||
i really need help to find the best way to provide
|
||||
GRRLIB functions to all these new effets in this demo.
|
||||
Since I cant code all these new function alone,
|
||||
I really need help to find the best way to provide
|
||||
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,
|
||||
for exemple i didnt succes fully coded a specular position and direction....
|
||||
So i repeat i need HELP !!! ;)
|
||||
for example I didn't success fully coded a specular position and direction...
|
||||
So I repeat I need HELP !!! ;)
|
||||
============================================*/
|
||||
#include <grrlib.h>
|
||||
|
||||
|
@ -25,7 +25,7 @@ int main() {
|
|||
GXLightObj MyLight1;
|
||||
int demo = 0;
|
||||
|
||||
Mtx mr,mv,rx,ry,rz,m;
|
||||
Mtx mr, mv, rx, ry, rz, m;
|
||||
GXTexObj texObj;
|
||||
|
||||
GRRLIB_Init();
|
||||
|
@ -47,13 +47,13 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
WPAD_ScanPads();
|
||||
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_MINUS) if(demo>0) demo--;
|
||||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS && demo < 5) 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) {
|
||||
/////////////////// DEFINE A DIFUSE LIGHT /////////////////////////////////////////////
|
||||
/////////////////// DEFINE A DIFFUSE LIGHT /////////////////////////////////////////////
|
||||
guVector l0pos={0.0f,20.0f,0.0f};
|
||||
guVecMultiply(_GRR_view, &l0pos, &l0pos);
|
||||
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
|
||||
|
@ -66,11 +66,11 @@ int main() {
|
|||
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)
|
||||
|
||||
/////////////////////// 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);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true,0xFFFFFFFF);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
//////////////////////////// Turn light off and Write demo name
|
||||
|
@ -80,9 +80,8 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Diffuse Light Source");
|
||||
}
|
||||
|
||||
if(demo==1) {
|
||||
/////////////////// DEFINE 2 DIFUSE LIGHTS /////////////////////////////////////////////
|
||||
else if(demo==1) {
|
||||
/////////////////// DEFINE 2 DIFFUSE LIGHTS /////////////////////////////////////////////
|
||||
guVector l0pos={0.0f,20.0f,0.0f};
|
||||
guVecMultiply(_GRR_view, &l0pos, &l0pos);
|
||||
GX_InitLightPos(&MyLight0, l0pos.x, l0pos.y, l0pos.z);
|
||||
|
@ -101,13 +100,13 @@ int main() {
|
|||
|
||||
/////////////////////// Turn lights ON ////////////////////////////////////////////////
|
||||
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);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
//////////////////////////// Turn light off and Write demo name
|
||||
|
@ -117,13 +116,12 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 2 Diffuse Light Sources");
|
||||
}
|
||||
|
||||
if(demo==2) {
|
||||
/////////////////// DEFINE A SPECUALR LIGHT /////////////////////////////////////////////
|
||||
else if(demo==2) {
|
||||
/////////////////// DEFINE A SPECULAR LIGHT /////////////////////////////////////////////
|
||||
guVector l0dir={0.0f,0.0f,0.0f};
|
||||
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_LoadLightObj(&MyLight0, GX_LIGHT0);
|
||||
|
||||
|
@ -135,19 +133,19 @@ int main() {
|
|||
GX_SetChanCtrl(GX_ALPHA1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE);
|
||||
|
||||
GX_SetNumTevStages(2);
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0 );
|
||||
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1 );
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1);
|
||||
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
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_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);
|
||||
|
||||
/////////////////////// 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);
|
||||
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00});
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
//////////////////////////// Turn light off and Write demo name
|
||||
|
@ -157,13 +155,12 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo 1 Specular Source with shininess = 20");
|
||||
}
|
||||
|
||||
if(demo==3) {
|
||||
/////////////////// DEFINE A SPECUALR LIGHT /////////////////////////////////////////////
|
||||
else if(demo==3) {
|
||||
/////////////////// DEFINE A SPECULAR LIGHT /////////////////////////////////////////////
|
||||
guVector l0dir={0.0f,0.0f,0.0f};
|
||||
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_LoadLightObj(&MyLight0, GX_LIGHT0);
|
||||
|
||||
|
@ -175,13 +172,13 @@ int main() {
|
|||
GX_SetChanCtrl(GX_ALPHA1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHTNULL, GX_DF_NONE, GX_AF_NONE);
|
||||
|
||||
GX_SetNumTevStages(2);
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0 );
|
||||
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1 );
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR1A1);
|
||||
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
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_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);
|
||||
|
||||
/////////////////////// 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);
|
||||
GX_SetChanAmbColor(GX_COLOR0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
||||
|
@ -197,7 +194,7 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
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)
|
||||
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))
|
||||
|
||||
|
@ -213,13 +210,13 @@ int main() {
|
|||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||
|
||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
GRRLIB_2dMode();
|
||||
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)
|
||||
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
|
||||
|
@ -241,14 +238,13 @@ int main() {
|
|||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||
|
||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60, true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf(20, 30, tex_font, 0xFFFFFFFF, 1, "Simple Demo Environmental Mapping");
|
||||
}
|
||||
|
||||
|
||||
GRRLIB_Render();
|
||||
}
|
||||
GRRLIB_FreeTexture(tex_font);
|
||||
|
|
Loading…
Reference in a new issue