void SendVertex_i(u16 index, u32 color, ParticleSystem* psystem) { GX_Position1x16(index); GX_Color1u32(color); f32* v = buffer + 3*index; System::Log(L"SEND_VERTEX %d:(%.3f, %.3f, %.3f)", index, v[0], v[1], v[2]); }
void SendVertex(guVector& p, u32 color) { GX_Position3f32(p.x, p.y, p.z); GX_Color1u32(color); }
int main() { int startx=0, starty=0; int x=0, y=0; int dirx=0, diry=0; int cptx=0, cpty=0; int bgx=-32, bgy=-32; float idperso=0; int i=0; float sinnonameno=0, oldsinnonameno=0; float camZ=1400.0f; float a=0; GRRLIB_Init(); GRRLIB_Settings.antialias = false; WPAD_Init(); GRRLIB_ClipDrawing(0,0,rmode->fbWidth,rmode->efbHeight); GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1); GRRLIB_InitTileSet(tex_tile1, TileMap1Width, TileMap1Height, 0); GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso); GRRLIB_InitTileSet(tex_perso, 64, 64, 0); GRRLIB_texImg *tex_bg = GRRLIB_LoadTexture(bg); GRRLIB_texImg *tex_nonameno = GRRLIB_LoadTexture(nonameno); GRRLIB_InitTileSet(tex_nonameno, 32, 32, 0); GRRLIB_texImg *tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight); GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF); while(1) { GRRLIB_2dMode(); WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break; if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS) camZ+=20.0f; if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS) camZ-=20.0f; if((dirx==0) && (diry==0)) { if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { diry=-4; idperso=15;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { diry=4; idperso=15;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { dirx=-4 ; idperso=1;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { dirx=4 ; idperso=8;} } if((dirx==0) && (diry==0)) { idperso=0; } if(((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) || ((Map1Info[9+starty][10+startx]==43521) || (Map1Info[9+starty][11+startx]==43521))) { } else{ dirx=0; diry=-4; } if(dirx<0) { if((Map1Info[7+starty][12+startx]==8) || (Map1Info[7+starty][12+startx]==2) || (Map1Info[8+starty][12+startx]==8) || (Map1Info[8+starty][12+startx]==2)) { dirx=0; } else { idperso++; if(idperso>7) idperso=1; } } if(dirx>0) { if((Map1Info[7+starty][9+startx]==8) || (Map1Info[7+starty][9+startx]==2) || (Map1Info[8+starty][9+startx]==8) || (Map1Info[8+starty][9+startx]==2)) { dirx=0; } else { idperso++; if(idperso>14) idperso=8; } } if(diry<0) { if((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) { diry=0; } } if(diry!=0) { idperso++; if(idperso>22) idperso=16; } cptx+=dirx; if(dirx>0) bgx++; else if(dirx<0) bgx--; if((bgx>-1) || (bgx<-63)) bgx=-32; if(cptx==32) { cptx=0; dirx=0; startx--; } else if(cptx==-32) { cptx=0; dirx=0; startx++; } cpty+=diry; if(diry>0) bgy++; else if(diry<0) bgy--; if((bgy>-1) ||(bgy<-63)) bgy=-32; if(cpty==32) { cpty=0; diry=0; starty--; } else if(cpty==-32) { cpty=0; if(((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) || ((Map1Info[9+starty][10+startx]==43521) || (Map1Info[9+starty][11+startx]==43521))) { diry=0; } starty++; } GRRLIB_DrawImg(bgx, bgy, tex_bg, 0, 1, 1, 0xFFFFFFFF); for(y=0;y<=(17);y++) { for(x=0;x<=(21);x++) { if(Map1Data[y+starty][x+startx] != 0) { GRRLIB_DrawTile(x*TileMap1Width+cptx-TileMap1Width,y*TileMap1Height+cpty-TileMap1Height,tex_tile1,0,1,1,0xFFFFFFFF,Map1Data[y+starty][x+startx]-1); } } } GRRLIB_DrawTile(TileMap1Width*9,TileMap1Height*6,tex_perso,0,1,1,0xFFFFFFFF,(int)idperso); oldsinnonameno=sinnonameno; for(i=0; i<8; i++) { GRRLIB_DrawTile(TileMap1Width*(6+i),(TileMap1Height*10)+sin(sinnonameno)*64,tex_nonameno,0,1,1,0xFFFFFFFF,i); sinnonameno+=0.4F; } sinnonameno=oldsinnonameno+0.08F; GRRLIB_Screen2Texture(0, 0, tex_screen, GX_TRUE); GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0); GRRLIB_3dMode(0.1,3000,45,1,0); GRRLIB_SetTexture(tex_screen,0); GRRLIB_ObjectView(0,0,0, a,a*2,a*3,1,1,1); GX_Begin(GX_QUADS, GX_VTXFMT0, 16); GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_End(); a+=0.2f; GRRLIB_Render(); } GRRLIB_FreeTexture(tex_tile1); GRRLIB_FreeTexture(tex_perso); GRRLIB_FreeTexture(tex_bg); GRRLIB_FreeTexture(tex_nonameno); GRRLIB_FreeTexture(tex_screen); GRRLIB_Exit(); exit(0); }
void SendVertex(Vec3& p, u32 color, f32 u, f32 v) { GX_Position3f32(p.x, p.y, p.z); GX_Color1u32(color); GX_TexCoord2f32(u, v); }
int main() { float a=0; int cubeZ=5; int i=0; float sinx=0, oldsinx=0; GRRLIB_Init(); WPAD_Init(); GRRLIB_texImg *tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth,rmode->efbHeight); GRRLIB_InitTileSet(tex_screen, rmode->fbWidth, 1, 0); GRRLIB_texImg *tex_girl= GRRLIB_LoadTexture(girl); GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font); GRRLIB_InitTileSet(tex_font, 16, 16, 32); GRRLIB_Settings.antialias = true; GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF); GRRLIB_Camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0); while(1) { GRRLIB_2dMode(); WPAD_ScanPads(); if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0); if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++; if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--; GRRLIB_3dMode(0.1,1000,45,1,0); GRRLIB_SetTexture(tex_girl,0); GRRLIB_ObjectView(0,0,cubeZ, a,a*2,a*3,1,1,1); GX_Begin(GX_QUADS, GX_VTXFMT0, 24); GX_Position3f32(-1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(-1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(-1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_End(); GRRLIB_Screen2Texture(0,0,tex_screen,1); a+=0.5f; // Switch To 2D Mode to display text GRRLIB_2dMode(); oldsinx=sinx; for(i=0; i<rmode->efbHeight; i++) { GRRLIB_DrawTile(0+sin(sinx)*60,i,tex_screen,0,1,1,0xFFFFFFFF,i); sinx+=0.02f; } sinx=oldsinx+0.02f; GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS A OR B TO ZOOM THE CUBE"); GRRLIB_Render(); } GRRLIB_FreeTexture(tex_girl); GRRLIB_FreeTexture(tex_font); GRRLIB_FreeTexture(tex_screen); GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB exit(0); }
int main() { int i; int screen_index = 0; float t=0; const int R=81; const int r=71; const int d=120; float f=0; float ff=0; float spr=0; int n=1; float a=0; float cubeZ=10.0f; float camZ=30.0f;; GRRLIB_Init(); PAD_Init(); GRRLIB_Settings.antialias = false; GRRLIB_texImg *tex_screen[9]; for(i=0; i<9; i++) { tex_screen[i] = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight); } GRRLIB_texImg *tex_girl = GRRLIB_LoadTexture(girl); GRRLIB_texImg *tex_logo = GRRLIB_LoadTexture(logo); GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font); GRRLIB_InitTileSet(tex_font, 16, 16, 32); for(i=0;i<=255;i+=1) { GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY 3D CUBE"); GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH"); GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i); GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM"); GRRLIB_Render(); } for(i=255;i>=0;i-=2) { GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY 3D CUBE"); GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH"); GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i); GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM"); GRRLIB_Render(); } GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF); while(1) { PAD_ScanPads(); GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0); GRRLIB_2dMode(); GRRLIB_DrawImg(0, 0, tex_screen[screen_index], 0, 1, 1, 0xFFFFFFFF); GRRLIB_3dMode(0.1, 1000, 45, 1, 0); GRRLIB_SetBlend(GRRLIB_BLEND_ALPHA); cubeZ+=0.02f; GRRLIB_ObjectView((float)(((R + r-ff)*cos(t-f) - d*cos(((R + r-f)/r)*t)))/20.0f,(float)(((R + r-ff)*sin(t) - d*sin(((R + r)/r)*t)-f))/20.0f,sin(cubeZ)*10, a,a*2,a*3,1,1,1); GRRLIB_SetTexture(tex_girl, 0); GX_Begin(GX_QUADS, GX_VTXFMT0, 24); GX_Position3f32(-1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(-1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(-1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f,1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-1.0f,1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(1.0f,-1.0f,1.0f); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2f32(0.0f,1.0f); GX_End(); a+=0.5f; GRRLIB_2dMode(); GRRLIB_Screen2Texture(0, 0, tex_screen[screen_index], GX_FALSE); GRRLIB_Printf((640-(16*6*5))/2+5, 200+5, tex_font, 0x00000088, 5, "%06d",(int)spr); GRRLIB_Printf((640-(16*6*5))/2, 200, tex_font, 0xFFEEEE88, 5, "%06d",(int)spr); GRRLIB_Render(); screen_index++; screen_index %= 9; spr+=0.1f; t+=0.01f; if(t>n*2*M_PI) { n++; f+=0.01f; } if(f>2*M_PI) { f=0; ff+=0.02f; } if(PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0); } GRRLIB_FreeTexture(tex_logo); GRRLIB_FreeTexture(tex_girl); GRRLIB_FreeTexture(tex_font); for(i=0; i<9; i++) { GRRLIB_FreeTexture(tex_screen[i]); } GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB return 0; }