[CHG] main.c added a little fire effect to show use of get and set pixel

in texture buffer ;)
This commit is contained in:
N0NameN0 2009-02-05 23:12:52 +00:00
parent e3e8ed4df7
commit fcf76f406b
3 changed files with 28 additions and 16 deletions

View file

@ -5,14 +5,16 @@ Visit http://www.devkitpro.org
const unsigned char pixeltest[] = { const unsigned char pixeltest[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0x0f, 0xbe, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0x08, 0x06, 0x00, 0x00, 0x00, 0x8c, 0xfe, 0xb8,
0x8b, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93,
0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13,
0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45, 0x07, 0xd9, 0x02, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45, 0x07, 0xd9, 0x02,
0x05, 0x12, 0x1b, 0x0e, 0xe5, 0xd7, 0xd5, 0x96, 0x00, 0x00, 0x00, 0x16, 0x49, 0x44, 0x41, 0x54, 0x05, 0x16, 0x36, 0x01, 0x52, 0x4b, 0x3a, 0x34, 0x00, 0x00, 0x00, 0x37, 0x49, 0x44, 0x41, 0x54,
0x18, 0xd3, 0x63, 0xfc, 0xff, 0xff, 0xff, 0x7f, 0x06, 0x3c, 0x80, 0x89, 0x81, 0x00, 0x18, 0x1e, 0x58, 0xc3, 0xed, 0xce, 0x01, 0x0d, 0x00, 0x20, 0x0c, 0xc0, 0xb0, 0x81, 0x7f, 0xcf, 0xc7, 0xc6,
0x0a, 0x00, 0x1b, 0x6e, 0x04, 0x0c, 0x19, 0x49, 0x52, 0xd1, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x49, 0x5a, 0x05, 0x3d, 0xd5, 0xb4, 0xd8, 0x6d, 0x39, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0xc1,
0x5f, 0x83, 0x0f, 0x13, 0xf7, 0x01, 0x4f, 0xc6, 0x36, 0x6b, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x49,
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
}; };
const int pixeltest_size = sizeof(pixeltest); const int pixeltest_size = sizeof(pixeltest);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

After

Width:  |  Height:  |  Size: 183 B

View file

@ -56,8 +56,8 @@ Mtx GXmodelView2D;
int main() { int main() {
int left = 0, top = 0, page = 0, frame = TILE_DOWN + 1; int left = 0, top = 0, page = 0, frame = TILE_DOWN + 1;
unsigned int wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN; unsigned int wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN;
int x, y; int x, y, val1,val2,val3,val4;
u32 val; u32 val, valtmp;
ir_t ir1; ir_t ir1;
u32 wpaddown, wpadheld; u32 wpaddown, wpadheld;
Vector triangle[] = {{400,200,0.0f}, {500,400,0.0f}, {300,400,0.0f}}; Vector triangle[] = {{400,200,0.0f}, {500,400,0.0f}, {300,400,0.0f}};
@ -90,13 +90,6 @@ int main() {
GRRLIB_texImg tex_BMfont5 = GRRLIB_LoadTexturePNG(BMfont5); GRRLIB_texImg tex_BMfont5 = GRRLIB_LoadTexturePNG(BMfont5);
GRRLIB_InitTileSet(&tex_BMfont5, 8, 16, 0); GRRLIB_InitTileSet(&tex_BMfont5, 8, 16, 0);
for(y=0;y<8;y++){
for(x=0;x<8;x++){
val = GRRLIB_GetPixelFromtexImg(x+8,y+8,tex_sprite_png);
GRRLIB_SetPixelTotexImg(x, y, tex_pixeltest, val);
}
}
while(1) { while(1) {
WPAD_SetVRes(0, 640, 480); WPAD_SetVRes(0, 640, 480);
WPAD_ScanPads(); WPAD_ScanPads();
@ -113,8 +106,25 @@ int main() {
GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "IMAGES DEMO"); GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "IMAGES DEMO");
GRRLIB_DrawImg(10, 50, tex_test_jpg, 0, 1, 1, GRRLIB_WHITE); GRRLIB_DrawImg(10, 50, tex_test_jpg, 0, 1, 1, GRRLIB_WHITE);
GRRLIB_DrawImg(400, 150, tex_pixeltest, 0, 20, 20, GRRLIB_WHITE); GRRLIB_DrawImg(400, 150, tex_pixeltest, 0, 2, 2, GRRLIB_WHITE);
for(x=0;x<40;x++){
valtmp = 1 + (int) (180 * (rand() / (RAND_MAX + 1.0)));
val=(valtmp<<24) | (valtmp<<16) | (valtmp<<8) | 0xFF;
GRRLIB_SetPixelTotexImg(x,39,tex_pixeltest,val);
}
for(y=38;y>0;y--){
for(x=1;x<39;x++){
val1 = (GRRLIB_GetPixelFromtexImg(x-1,y+1,tex_pixeltest)>>8)& 0xFF;
val2 = (GRRLIB_GetPixelFromtexImg(x,y+1,tex_pixeltest)>>8)& 0xFF;
val3 = (GRRLIB_GetPixelFromtexImg(x+1,y+1,tex_pixeltest)>>8)& 0xFF;
val4 = (GRRLIB_GetPixelFromtexImg(x,y-1,tex_pixeltest)>>8)& 0XFF;
valtmp = (val1+val2+val3+val4)/4;
val=(valtmp<<24) | (valtmp<<16) | (valtmp<<8) | 0xFF;
GRRLIB_SetPixelTotexImg(x, y, tex_pixeltest, val);
}
}
// Draw a sprite // Draw a sprite