mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-26 08:42:19 +00:00
[BUG] Addon lib is working
[CHG] Added GRRLIB_ScrShot function to lesson1
This commit is contained in:
parent
27e586c4a3
commit
83f0679add
3 changed files with 32 additions and 9 deletions
|
@ -10,11 +10,8 @@
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
|
||||||
#include "../lib/libpng/pngu/pngu.h"
|
#include "../lib/libpng/pngu/pngu.h"
|
||||||
#include "GRRLIB.h"
|
#include "GRRLIB.h"
|
||||||
#include "GRRLIBaddon.h"
|
|
||||||
#include <ogc/conf.h>
|
|
||||||
#include <fat.h>
|
#include <fat.h>
|
||||||
|
|
||||||
extern u32 fb;
|
extern u32 fb;
|
||||||
|
@ -60,3 +57,26 @@ bool GRRLIB_ScrShot(const char* File) {
|
||||||
}
|
}
|
||||||
return !ErrorCode;
|
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;
|
||||||
|
}
|
|
@ -5,8 +5,8 @@
|
||||||
GX hints : RedShade
|
GX hints : RedShade
|
||||||
===========================================*/
|
===========================================*/
|
||||||
|
|
||||||
#ifndef __GXHDR__
|
#ifndef __GRRLIB_ADDON__
|
||||||
#define __GXHDR__
|
#define __GRRLIB_ADDON__
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file GRRLIBaddon.h
|
* @file GRRLIBaddon.h
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
GRRLIB_texImg *GRRLIB_LoadTextureFromFile(const char *filename);
|
GRRLIB_texImg *GRRLIB_LoadTextureFromFile(const char *filename);
|
||||||
bool GRRLIB_ScrShot(const char*);
|
bool GRRLIB_ScrShot(const char*);
|
||||||
|
GRRLIB_texImg *GRRLIB_Screen2Texture();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -5,11 +5,11 @@
|
||||||
How To use Bitmap Fonts
|
How To use Bitmap Fonts
|
||||||
============================================*/
|
============================================*/
|
||||||
#include "../../../GRRLIB/GRRLIB/GRRLIB.h"
|
#include "../../../GRRLIB/GRRLIB/GRRLIB.h"
|
||||||
|
#include "../../../GRRLIB/GRRLIB/GRRLIB_addon.h"
|
||||||
|
|
||||||
#include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs
|
#include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
#include <fat.h>
|
|
||||||
|
|
||||||
#include "gfx/BMfont1.h"
|
#include "gfx/BMfont1.h"
|
||||||
#include "gfx/BMfont2.h"
|
#include "gfx/BMfont2.h"
|
||||||
|
@ -64,8 +64,6 @@ int main() {
|
||||||
|
|
||||||
GRRLIB_Init();
|
GRRLIB_Init();
|
||||||
|
|
||||||
|
|
||||||
fatInitDefault();
|
|
||||||
WPAD_Init();
|
WPAD_Init();
|
||||||
WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
|
WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
|
||||||
|
|
||||||
|
@ -212,6 +210,11 @@ int main() {
|
||||||
top = 0;
|
top = 0;
|
||||||
if(page > 2) page = 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
|
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
|
||||||
// Free some textures
|
// Free some textures
|
||||||
|
|
Loading…
Reference in a new issue