diff --git a/GRRLIB/GRRLIB/GRRLIBaddon.c b/GRRLIB/GRRLIB/GRRLIB_addon.c similarity index 64% rename from GRRLIB/GRRLIB/GRRLIBaddon.c rename to GRRLIB/GRRLIB/GRRLIB_addon.c index b2e3bfc..5fa9be5 100644 --- a/GRRLIB/GRRLIB/GRRLIBaddon.c +++ b/GRRLIB/GRRLIB/GRRLIB_addon.c @@ -10,11 +10,8 @@ #include #include #include -#include #include "../lib/libpng/pngu/pngu.h" #include "GRRLIB.h" -#include "GRRLIBaddon.h" -#include #include extern u32 fb; @@ -60,3 +57,26 @@ bool GRRLIB_ScrShot(const char* File) { } return !ErrorCode; } + +/** + * Make a snapshot of the screen in a texture. + * @return A pointer to a texture representing the screen or NULL if an error occurs. + */ +GRRLIB_texImg *GRRLIB_Screen2Texture() { + GRRLIB_texImg *tex = (struct GRRLIB_texImg *)calloc(1, sizeof(GRRLIB_texImg)); + + if(tex != NULL) { + tex->w = rmode->fbWidth; + tex->h = rmode->efbHeight; + GRRLIB_SetHandle( tex, 0, 0 ); + tex->data = memalign(32, tex->w * tex->h * 4); + if(tex->data != NULL) { + GX_SetTexCopySrc(0, 0, rmode->fbWidth, rmode->efbHeight); + GX_SetTexCopyDst(rmode->fbWidth, rmode->efbHeight, GX_TF_RGBA8, GX_FALSE); + GX_CopyTex(tex->data, GX_FALSE); + GX_PixModeSync(); + GRRLIB_FlushTex(tex); + } + } + return tex; +} diff --git a/GRRLIB/GRRLIB/GRRLIBaddon.h b/GRRLIB/GRRLIB/GRRLIB_addon.h similarity index 80% rename from GRRLIB/GRRLIB/GRRLIBaddon.h rename to GRRLIB/GRRLIB/GRRLIB_addon.h index 3b34eb7..555e815 100644 --- a/GRRLIB/GRRLIB/GRRLIBaddon.h +++ b/GRRLIB/GRRLIB/GRRLIB_addon.h @@ -5,8 +5,8 @@ GX hints : RedShade ===========================================*/ -#ifndef __GXHDR__ -#define __GXHDR__ +#ifndef __GRRLIB_ADDON__ +#define __GRRLIB_ADDON__ /** * @file GRRLIBaddon.h @@ -21,7 +21,7 @@ GRRLIB_texImg *GRRLIB_LoadTextureFromFile(const char *filename); bool GRRLIB_ScrShot(const char*); - +GRRLIB_texImg *GRRLIB_Screen2Texture(); #ifdef __cplusplus } diff --git a/examples/lesson1/source/main.c b/examples/lesson1/source/main.c index 07437b9..d46e807 100644 --- a/examples/lesson1/source/main.c +++ b/examples/lesson1/source/main.c @@ -5,11 +5,11 @@ How To use Bitmap Fonts ============================================*/ #include "../../../GRRLIB/GRRLIB/GRRLIB.h" +#include "../../../GRRLIB/GRRLIB/GRRLIB_addon.h" #include // Needed for gettime and ticks_to_millisecs #include #include -#include #include "gfx/BMfont1.h" #include "gfx/BMfont2.h" @@ -64,8 +64,6 @@ int main() { GRRLIB_Init(); - - fatInitDefault(); WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); @@ -212,6 +210,11 @@ int main() { top = 0; if(page > 2) page = 0; } + if(wpadheld & WPAD_BUTTON_1 && wpadheld & WPAD_BUTTON_2) { + WPAD_Rumble(WPAD_CHAN_0, 1); // Rumble on + GRRLIB_ScrShot("sd:/grrlib.png"); + WPAD_Rumble(WPAD_CHAN_0, 0); // Rumble off + } } GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB // Free some textures