mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
[CHG] pngu.c does not required to include gx.h anymore
[BUG] Fixed some examples using GRRLIB_ScrShot
This commit is contained in:
parent
1e066f3877
commit
8789bd4ba6
4 changed files with 17 additions and 11 deletions
|
@ -85,6 +85,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureFromFile(const char *filename) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a PNG screenshot.
|
* Make a PNG screenshot.
|
||||||
|
* It should be called after drawing stuff on the screen, but before GRRLIB_Render.
|
||||||
* libfat is required to use the function.
|
* libfat is required to use the function.
|
||||||
* @param filename Name of the file to write.
|
* @param filename Name of the file to write.
|
||||||
* @return bool true=everything worked, false=problems occurred.
|
* @return bool true=everything worked, false=problems occurred.
|
||||||
|
|
|
@ -9,7 +9,6 @@ More info : http://frontier-dev.net
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <ogc/gx.h>
|
|
||||||
#include "pngu.h"
|
#include "pngu.h"
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
|
@ -18,6 +17,10 @@ More info : http://frontier-dev.net
|
||||||
#define PNGU_SOURCE_BUFFER 1
|
#define PNGU_SOURCE_BUFFER 1
|
||||||
#define PNGU_SOURCE_DEVICE 2
|
#define PNGU_SOURCE_DEVICE 2
|
||||||
|
|
||||||
|
#define _SHIFTL(v, s, w) \
|
||||||
|
((png_uint_32) (((png_uint_32)(v) & ((0x01 << (w)) - 1)) << (s)))
|
||||||
|
#define _SHIFTR(v, s, w) \
|
||||||
|
((png_uint_32)(((png_uint_32)(v) >> (s)) & ((0x01 << (w)) - 1)))
|
||||||
|
|
||||||
// Prototypes of helper functions
|
// Prototypes of helper functions
|
||||||
int pngu_info (IMGCTX ctx);
|
int pngu_info (IMGCTX ctx);
|
||||||
|
@ -821,20 +824,21 @@ int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void
|
||||||
// Coded by Crayon for GRRLIB (http://code.google.com/p/grrlib)
|
// Coded by Crayon for GRRLIB (http://code.google.com/p/grrlib)
|
||||||
int PNGU_EncodeFromEFB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stride)
|
int PNGU_EncodeFromEFB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stride)
|
||||||
{
|
{
|
||||||
|
png_uint_32 regval,val;
|
||||||
int x,y,res;
|
int x,y,res;
|
||||||
unsigned char * tmpbuffer = (unsigned char *)malloc(width*height*3);
|
unsigned char * tmpbuffer = (unsigned char *)malloc(width*height*3);
|
||||||
memset(tmpbuffer, 0, width*height*3);
|
memset(tmpbuffer, 0, width*height*3);
|
||||||
GXColor peekColor;
|
|
||||||
|
|
||||||
for(y=0; y < height; y++)
|
for(y=0; y < height; y++)
|
||||||
{
|
{
|
||||||
for(x=0; x < width; x++)
|
for(x=0; x < width; x++)
|
||||||
{
|
{
|
||||||
GX_PeekARGB(x, y, &peekColor);
|
regval = 0xc8000000|(_SHIFTL(x,2,10));
|
||||||
|
regval = (regval&~0x3FF000)|(_SHIFTL(y,12,10));
|
||||||
tmpbuffer[y*640*3+x*3] = peekColor.r; // R
|
val = *(png_uint_32*)regval;
|
||||||
tmpbuffer[y*640*3+x*3+1] = peekColor.g; // G
|
tmpbuffer[y*640*3+x*3] = _SHIFTR(val,16,8); // R
|
||||||
tmpbuffer[y*640*3+x*3+2] = peekColor.b; // B
|
tmpbuffer[y*640*3+x*3+1] = _SHIFTR(val,8,8); // G
|
||||||
|
tmpbuffer[y*640*3+x*3+2] = val&0xff; // B
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,6 @@ int main() {
|
||||||
GRRLIB_PrintBMF(left, top+420, bmf_Font2, "%s", bmf_Font2->name);
|
GRRLIB_PrintBMF(left, top+420, bmf_Font2, "%s", bmf_Font2->name);
|
||||||
}
|
}
|
||||||
GRRLIB_Printf(500, 27, tex_BMfont5, GRRLIB_WHITE, 1, "Current FPS: %d", FPS);
|
GRRLIB_Printf(500, 27, tex_BMfont5, GRRLIB_WHITE, 1, "Current FPS: %d", FPS);
|
||||||
GRRLIB_Render();
|
|
||||||
FPS = CalculateFrameRate();
|
|
||||||
|
|
||||||
if(wpaddown & WPAD_BUTTON_HOME) {
|
if(wpaddown & WPAD_BUTTON_HOME) {
|
||||||
break;
|
break;
|
||||||
|
@ -217,6 +215,9 @@ int main() {
|
||||||
GRRLIB_ScrShot("sd:/grrlib.png");
|
GRRLIB_ScrShot("sd:/grrlib.png");
|
||||||
WPAD_Rumble(WPAD_CHAN_0, 0); // Rumble off
|
WPAD_Rumble(WPAD_CHAN_0, 0); // Rumble off
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GRRLIB_Render();
|
||||||
|
FPS = CalculateFrameRate();
|
||||||
}
|
}
|
||||||
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
|
||||||
|
@ -235,7 +236,6 @@ int main() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function calculates the number of frames we render each second.
|
* This function calculates the number of frames we render each second.
|
||||||
* It must be called right after GRRLIB_Render.
|
|
||||||
* @return The number of frames per second.
|
* @return The number of frames per second.
|
||||||
*/
|
*/
|
||||||
static u8 CalculateFrameRate() {
|
static u8 CalculateFrameRate() {
|
||||||
|
|
|
@ -68,7 +68,6 @@ int main(int argc, char **argv) {
|
||||||
GRRLIB_PrintfTTF(500+1, 25+1, myFont, FPS, 12, 0x000000FF);
|
GRRLIB_PrintfTTF(500+1, 25+1, myFont, FPS, 12, 0x000000FF);
|
||||||
GRRLIB_PrintfTTF(500, 25, myFont, FPS, 12, 0xFFFFFFFF);
|
GRRLIB_PrintfTTF(500, 25, myFont, FPS, 12, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
GRRLIB_Render(); // Render the frame buffer to the TV
|
|
||||||
|
|
||||||
WPAD_ScanPads(); // Scan the Wii Remotes
|
WPAD_ScanPads(); // Scan the Wii Remotes
|
||||||
|
|
||||||
|
@ -86,6 +85,8 @@ int main(int argc, char **argv) {
|
||||||
ScreenShot(); // Needs to be after GRRLIB_Render()
|
ScreenShot(); // Needs to be after GRRLIB_Render()
|
||||||
WPAD_Rumble(0, false); // Rumble off
|
WPAD_Rumble(0, false); // Rumble off
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GRRLIB_Render(); // Render the frame buffer to the TV
|
||||||
}
|
}
|
||||||
|
|
||||||
GRRLIB_FreeTexture(CopiedImg);
|
GRRLIB_FreeTexture(CopiedImg);
|
||||||
|
|
Loading…
Reference in a new issue