[CHG] Cleanup

This commit is contained in:
Crayon2000 2009-11-26 22:46:24 +00:00
parent a3024c20b7
commit 740a81df7e
6 changed files with 119 additions and 121 deletions

View file

@ -40,30 +40,30 @@ void GRRLIB_Screen2Texture (int posx, int posy, GRRLIB_texImg *tex, bool clear)
}
/**
* Start GX Compositing Process.
* Start GX compositing process.
* @see GRRLIB_CompoEnd
*/
void GRRLIB_CompoStart (void){
GX_SetPixelFmt(GX_PF_RGBA6_Z24,GX_ZC_LINEAR);
GX_PokeAlphaRead(GX_READ_NONE);
GX_SetPixelFmt(GX_PF_RGBA6_Z24,GX_ZC_LINEAR);
GX_PokeAlphaRead(GX_READ_NONE);
}
/**
* End GX Compositing Process (Make a snapshot of the screen in a texture WITH ALPHA LAYER).
* End GX compositing process (Make a snapshot of the screen in a texture WITH ALPHA LAYER).
* EFB is cleared after this function.
* @see GRRLIB_CompoStart
* @param posx top left corner of the grabbed part.
* @param posy top left corner of the grabbed part.
* @param tex A pointer to a texture representing the screen or NULL if an error occurs.
* @info EFB is cleared after this function.
*/
void GRRLIB_CompoEnd(int posx, int posy, GRRLIB_texImg *tex){
GRRLIB_Screen2Texture(posx, posy, tex, FALSE);
GRRLIB_Screen2Texture(posx, posy, tex, FALSE);
GX_SetTexCopySrc(0, 0, rmode->fbWidth, rmode->efbHeight);
GX_SetTexCopyDst(rmode->fbWidth, rmode->efbHeight, GX_TF_RGBA8, GX_FALSE);
GX_CopyTex(TrashTex, GX_TRUE);
GX_PixModeSync();
if (rmode->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR) ;
else GX_SetPixelFmt(GX_PF_RGB8_Z24 , GX_ZC_LINEAR) ;
GX_SetTexCopySrc(0, 0, rmode->fbWidth, rmode->efbHeight);
GX_SetTexCopyDst(rmode->fbWidth, rmode->efbHeight, GX_TF_RGBA8, GX_FALSE);
GX_CopyTex(TrashTex, GX_TRUE);
GX_PixModeSync();
if (rmode->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR) ;
else GX_SetPixelFmt(GX_PF_RGB8_Z24 , GX_ZC_LINEAR) ;
}

View file

@ -37,29 +37,27 @@ int main() {
WPAD_ScanPads();
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
GRRLIB_CompoStart ();
GRRLIB_SetAlpha(0xff);
for(i=0;i<360;i+=30){
GRRLIB_Settings.rotation= i+rot;
GRRLIB_DrawTile((rmode->fbWidth/2)-(tex_font->tilew/2), (rmode->efbHeight/2)-(tex_font->tileh+circsize),tex_font,65-32+((int)i/45));
}
GRRLIB_CompoEnd(0, 0, tex_screen);
GRRLIB_CompoStart();
GRRLIB_SetAlpha(0xff);
for(i=0;i<360;i+=30) {
GRRLIB_Settings.rotation= i+rot;
GRRLIB_DrawTile((rmode->fbWidth/2)-(tex_font->tilew/2), (rmode->efbHeight/2)-(tex_font->tileh+circsize), tex_font, 65-32+((int)i/45));
}
GRRLIB_CompoEnd(0, 0, tex_screen);
GRRLIB_Settings.rotation=0;
rot-=0.6;
GRRLIB_Settings.rotation=0;
rot-=0.6;
GRRLIB_SetAlpha(0xff);
GRRLIB_DrawImg(50, 50,tex_screen);
GRRLIB_SetAlpha(0xFF);
GRRLIB_DrawImg(100, 100,tex_screen);
GRRLIB_SetAlpha(0xFF);
GRRLIB_DrawImg(50, 50, tex_screen);
GRRLIB_DrawImg(100, 100, tex_screen);
GRRLIB_Render();
}
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
GRRLIB_FreeTexture(tex_screen);
GRRLIB_FreeTexture(tex_font);
GRRLIB_FreeTexture(tex_screen);
GRRLIB_FreeTexture(tex_font);
exit(0);
}

View file

@ -1,12 +1,12 @@
/*===========================================
GRRLIB (GX Version)
- Example Code -
- Example Code -
How To use Bitmap Fonts
============================================*/
#include <grrlib.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 <wiiuse/wpad.h>
#include <wiiuse/wpad.h>

View file

@ -24,7 +24,7 @@ int main() {
// Load the original texture and create empty texture of the same size as the original one
GRRLIB_texImg *tex_pirate = GRRLIB_LoadTexture(pirate);
GRRLIB_texImg *tex_gray = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
GRRLIB_texImg *tex_sepia = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
GRRLIB_texImg *tex_sepia = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
GRRLIB_texImg *tex_invert = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
GRRLIB_texImg *tex_blur1 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
GRRLIB_texImg *tex_blur2 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
@ -122,44 +122,44 @@ int main() {
switch(page)
{
case 1:
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_Printf(10, 10, text_font1, "GRAYSCALE FX");
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_DrawImg(10, 60, tex_pirate);
GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_gray);
break;
case 2:
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_Printf(10, 10, text_font1, "SEPIA FX");
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_DrawImg(10, 60, tex_pirate);
GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_sepia);
break;
case 3:
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_Printf(10, 10, text_font1, "INVERT FX");
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_DrawImg(10, 60, tex_pirate);
GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_invert);
break;
case 4:
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_Printf(10, 10, text_font1, "FLIPH AND FLIPV FX");
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_DrawImg(10, 60, tex_pirate);
GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_fliph);
GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_flipv);
GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_fliphv);
break;
case 5:
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_Printf(10, 10, text_font1, "BLUR FX");
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_DrawImg(10, 60, tex_pirate);
GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_blur1);
GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_blur2);
@ -169,10 +169,10 @@ int main() {
GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_blur6);
break;
case 6:
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_Printf(10, 10, text_font1, "PIXELATE FX");
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_DrawImg(10, 60, tex_pirate);
GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_pixel1);
GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_pixel2);
@ -182,10 +182,10 @@ int main() {
GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_pixel6);
break;
case 7:
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_Printf(10, 10, text_font1, "SCATTER FX");
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_DrawImg(10, 60, tex_pirate);
GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_scatter1);
GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_scatter2);
@ -195,7 +195,7 @@ int main() {
GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_scatter6);
break;
default:
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_SetColorRGBA(0X000000FF);
GRRLIB_Printf(10, 10, text_font1, "WELCOME TO THE");
GRRLIB_Printf(10, 40, text_font1, "GRRLIB FX DEMO.");
GRRLIB_Printf(10, 80, text_font1, "TO QUIT PRESS THE");

View file

@ -81,12 +81,12 @@ void GRRLIB_addon_Button(int indice, int x,int y,u32 col, int wpadx, int wpady,
}
}
else {
GRRLIB_SetColorRGBA(0xFFFFFF77);
GRRLIB_SetColorRGBA(0xFFFFFF77);
if((toto[0]=='^') && (toto[1]=='U')) GRRLIB_Printf(x+4, y+2, tex_GRRLIBfont, "%c", 0xa1);
else if((toto[0]=='^') && (toto[1]=='D')) GRRLIB_Printf(x+4, y+2, tex_GRRLIBfont, "%c", 0xa2);
else if((toto[0]=='^') && (toto[1]=='L')) GRRLIB_Printf(x+4, y+2, tex_GRRLIBfont, "%c", 0xa3);
else if((toto[0]=='^') && (toto[1]=='R')) GRRLIB_Printf(x+4, y+2, tex_GRRLIBfont, "%c", 0xa4);
else GRRLIB_Printf(x+4, y+2, tex_GRRLIBfont, toto);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_SetColorRGBA(0xFFFFFFFF);
}
}

View file

@ -32,39 +32,39 @@ GRRLIB_texImg *GFX_Font;
int main() {
// Init Variables
// Init Variables
u32 WPADKeyDown;
u32 WPADKeyHeld;
short WinW, WinH;
int P1MX, P1MY;
int P1MX, P1MY;
u8 Stage = 0, Blending = 0;
u8 BlobType = 0;
u8 Color = 255;
u16 Step = 0;
float SX, SY;
u8 Stage = 0, Blending = 0;
u8 BlobType = 0;
u8 Color = 255;
u16 Step = 0;
float SX, SY;
// Init GRRLIB & WiiUse
// Init GRRLIB & WiiUse
GRRLIB_Init();
WinW = rmode->fbWidth;
WinH = rmode->efbHeight;
WinH = rmode->efbHeight;
WPAD_Init();
WPAD_SetIdleTimeout( 60*10 );
WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR );
WPAD_SetDataFormat( WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR );
// Load Textures
GFX_Background = GRRLIB_LoadTextureJPG(RGFX_Background);
GFX_Blob[0] = GRRLIB_LoadTexturePNG(RGFX_Blob01);
GFX_Blob[1] = GRRLIB_LoadTexturePNG(RGFX_Blob02);
GFX_Blob[2] = GRRLIB_LoadTexturePNG(RGFX_Blob03);
GFX_Font = GRRLIB_LoadTexturePNG(RGFX_Font);
GRRLIB_InitTileSet(GFX_Font, 8, 16, 32);
// Load Textures
GFX_Background = GRRLIB_LoadTextureJPG(RGFX_Background);
GFX_Blob[0] = GRRLIB_LoadTexturePNG(RGFX_Blob01);
GFX_Blob[1] = GRRLIB_LoadTexturePNG(RGFX_Blob02);
GFX_Blob[2] = GRRLIB_LoadTexturePNG(RGFX_Blob03);
GFX_Font = GRRLIB_LoadTexturePNG(RGFX_Font);
GRRLIB_InitTileSet(GFX_Font, 8, 16, 32);
// Set Handles
GRRLIB_SetMidHandle( GFX_Blob[0], true );
GRRLIB_SetMidHandle( GFX_Blob[1], true );
GRRLIB_SetMidHandle( GFX_Blob[2], true );
// Set Handles
GRRLIB_SetMidHandle( GFX_Blob[0], true );
GRRLIB_SetMidHandle( GFX_Blob[1], true );
GRRLIB_SetMidHandle( GFX_Blob[2], true );
while (true) {
@ -72,51 +72,51 @@ int main() {
WPADKeyDown = WPAD_ButtonsDown(WPAD_CHAN_0);
WPADKeyHeld = WPAD_ButtonsHeld(WPAD_CHAN_0);
WPAD_SetVRes(WPAD_CHAN_0, WinW, WinH);
WPAD_IR(WPAD_CHAN_0, &P1Mote);
WPAD_IR(WPAD_CHAN_0, &P1Mote);
// WiiMote IR Viewport Correction
P1MX = P1Mote.sx - 150;
P1MY = P1Mote.sy - 150;
// WiiMote IR Viewport Correction
P1MX = P1Mote.sx - 150;
P1MY = P1Mote.sy - 150;
// Update Stage
Step = Step + 1;
if (Step == 720) { Step = 0; }
SX = 320 + (sin(DegToRad(Step )) * 250);
SY = 240 + (cos(DegToRad(Step*3)) * 100);
// Update Stage
Step = Step + 1;
if (Step == 720) { Step = 0; }
SX = 320 + (sin(DegToRad(Step )) * 250);
SY = 240 + (cos(DegToRad(Step*3)) * 100);
// Draw Stage
GRRLIB_SetColorRGBA(RGBA(255, 255, 255, 255));
GRRLIB_DrawImg( 0, 0, GFX_Background );
GRRLIB_SetBlend( (Blending+1) ); Color = 255;
switch (Stage) {
case 2: Color = 160; break;
case 3: Color = 128; break;
case 4: Color = 64; break;
}
GRRLIB_SetColorRGBA(RGBA(Color, Color, Color, 255));
GRRLIB_DrawImg( SX, SY, GFX_Blob[BlobType] );
// Draw Stage
GRRLIB_SetColorRGBA(RGBA(255, 255, 255, 255));
GRRLIB_DrawImg( 0, 0, GFX_Background );
GRRLIB_SetBlend( (Blending+1) ); Color = 255;
switch (Stage) {
case 2: Color = 160; break;
case 3: Color = 128; break;
case 4: Color = 64; break;
}
GRRLIB_SetColorRGBA(RGBA(Color, Color, Color, 255));
GRRLIB_DrawImg( SX, SY, GFX_Blob[BlobType] );
// IR Pointer
if (P1Mote.state == 1) {
GRRLIB_DrawImg( P1MX, P1MY, GFX_Blob[BlobType] );
}
// IR Pointer
if (P1Mote.state == 1) {
GRRLIB_DrawImg( P1MX, P1MY, GFX_Blob[BlobType] );
}
// Draw Text
GRRLIB_SetBlend ( GRRLIB_BLEND_ALPHA );
GRRLIB_SetColorRGBA( RGBA(0, 0, 0, 160) );
GRRLIB_Rectangle( 28, 28, 480 + 16, 76, 1 );
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_Printf ( 32, 32, GFX_Font, "Point your WiiMote on the screen." );
GRRLIB_Printf ( 32, 48, GFX_Font, "Press LEFT and RIGHT to switch through the different stages." );
GRRLIB_Printf ( 32, 64, GFX_Font, "Press A to change the blob sprite." );
switch (Stage) {
case 0: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 1: Additive Blending" ); Blending = 0; break;
case 1: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 2: Alpha Light Blending" ); Blending = 1; break;
case 2: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 3: Multiply Blending (75%)" ); Blending = 2; break;
case 3: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 4: Multiply Blending (50%)" ); Blending = 2; break;
case 4: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 5: Multiply Blending (25%)" ); Blending = 2; break;
case 5: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 6: Invert Color Blending" ); Blending = 3; break;
}
// Draw Text
GRRLIB_SetBlend ( GRRLIB_BLEND_ALPHA );
GRRLIB_SetColorRGBA( RGBA(0, 0, 0, 160) );
GRRLIB_Rectangle( 28, 28, 480 + 16, 76, 1 );
GRRLIB_SetColorRGBA(0xFFFFFFFF);
GRRLIB_Printf ( 32, 32, GFX_Font, "Point your WiiMote on the screen." );
GRRLIB_Printf ( 32, 48, GFX_Font, "Press LEFT and RIGHT to switch through the different stages." );
GRRLIB_Printf ( 32, 64, GFX_Font, "Press A to change the blob sprite." );
switch (Stage) {
case 0: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 1: Additive Blending" ); Blending = 0; break;
case 1: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 2: Alpha Light Blending" ); Blending = 1; break;
case 2: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 3: Multiply Blending (75%)" ); Blending = 2; break;
case 3: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 4: Multiply Blending (50%)" ); Blending = 2; break;
case 4: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 5: Multiply Blending (25%)" ); Blending = 2; break;
case 5: GRRLIB_Printf( 32, 88, GFX_Font, "Stage 6: Invert Color Blending" ); Blending = 3; break;
}
GRRLIB_Render();
if (WPADKeyDown & WPAD_BUTTON_RIGHT) { if (Stage < 5) { Stage += 1; } }
@ -129,16 +129,16 @@ int main() {
}
static void ExitGame() {
// Deinitialize GRRLIB & Video
GRRLIB_Exit();
// Deinitialize GRRLIB & Video
GRRLIB_Exit();
// Free all memory used by textures.
GRRLIB_FreeTexture(GFX_Background);
GRRLIB_FreeTexture(GFX_Blob[0]);
GRRLIB_FreeTexture(GFX_Blob[1]);
GRRLIB_FreeTexture(GFX_Blob[2]);
GRRLIB_FreeTexture(GFX_Font);
// Free all memory used by textures.
GRRLIB_FreeTexture(GFX_Background);
GRRLIB_FreeTexture(GFX_Blob[0]);
GRRLIB_FreeTexture(GFX_Blob[1]);
GRRLIB_FreeTexture(GFX_Blob[2]);
GRRLIB_FreeTexture(GFX_Font);
// Exit application
exit(0);
// Exit application
exit(0);
}