From fcf76f406b13f32d6db5e0b374c587fdd7934176 Mon Sep 17 00:00:00 2001 From: N0NameN0 Date: Thu, 5 Feb 2009 23:12:52 +0000 Subject: [PATCH] [CHG] main.c added a little fire effect to show use of get and set pixel in texture buffer ;) --- template/source/gfx/pixeltest.c | 14 ++++++++------ template/source/gfx/pixeltest.png | Bin 150 -> 183 bytes template/source/main.c | 30 ++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/template/source/gfx/pixeltest.c b/template/source/gfx/pixeltest.c index 59a1c9f..cd05c23 100644 --- a/template/source/gfx/pixeltest.c +++ b/template/source/gfx/pixeltest.c @@ -5,14 +5,16 @@ Visit http://www.devkitpro.org const unsigned char pixeltest[] = { 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, - 0x8b, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0x08, 0x06, 0x00, 0x00, 0x00, 0x8c, 0xfe, 0xb8, + 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, 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, - 0x05, 0x12, 0x1b, 0x0e, 0xe5, 0xd7, 0xd5, 0x96, 0x00, 0x00, 0x00, 0x16, 0x49, 0x44, 0x41, 0x54, - 0x18, 0xd3, 0x63, 0xfc, 0xff, 0xff, 0xff, 0x7f, 0x06, 0x3c, 0x80, 0x89, 0x81, 0x00, 0x18, 0x1e, - 0x0a, 0x00, 0x1b, 0x6e, 0x04, 0x0c, 0x19, 0x49, 0x52, 0xd1, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, - 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 + 0x05, 0x16, 0x36, 0x01, 0x52, 0x4b, 0x3a, 0x34, 0x00, 0x00, 0x00, 0x37, 0x49, 0x44, 0x41, 0x54, + 0x58, 0xc3, 0xed, 0xce, 0x01, 0x0d, 0x00, 0x20, 0x0c, 0xc0, 0xb0, 0x81, 0x7f, 0xcf, 0xc7, 0xc6, + 0x49, 0x5a, 0x05, 0x3d, 0xd5, 0xb4, 0xd8, 0x6d, 0x39, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, + 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); diff --git a/template/source/gfx/pixeltest.png b/template/source/gfx/pixeltest.png index fba69e4e0d636fae23e4ff24b0761af51b5caf8f..22e8c3be771d2b88a2ca368b4ba87737d0c9a2b3 100644 GIT binary patch delta 128 zcmbQnxSdh4Gr-TCmrII^fq{Y7)59eQNNa#F2OE&=`L`o?qM}2Xm>FY`x0MM{#N5-x zF(l&f+jES(3<^94HZ<0sKYq+Jiq-b&mK(X2j#$CL_-20L?~MM(%(B-5jbQL}^>bP0 Hl+XkKN)RN* delta 95 zcmdnaIE_)UGr-TCmrII^fq{Y7)59eQNOOQN2OE$)!oRP3qN0PTkTl=Z>sO}%MZ`Q^ s977~7C;$2X|9?H3O+#lRgM=IxgLEDXkECbNMW6}>Pgg&ebxsLQ06I_^D*ylh diff --git a/template/source/main.c b/template/source/main.c index 36fefdb..2c374fb 100644 --- a/template/source/main.c +++ b/template/source/main.c @@ -56,8 +56,8 @@ Mtx GXmodelView2D; int main() { int left = 0, top = 0, page = 0, frame = TILE_DOWN + 1; unsigned int wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN; - int x, y; - u32 val; + int x, y, val1,val2,val3,val4; + u32 val, valtmp; ir_t ir1; u32 wpaddown, wpadheld; 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_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) { WPAD_SetVRes(0, 640, 480); WPAD_ScanPads(); @@ -113,8 +106,25 @@ int main() { 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(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