mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 06:52:20 +00:00
[CHG] TTF example is more complete
[BUG] In the 3D test branch the model could be draw with color and texture (order is: position / normal / color / texture) [CHG] In the 3D test branch the example is now using lights
This commit is contained in:
parent
25876beeb9
commit
42d7917d0d
2 changed files with 42 additions and 19 deletions
|
@ -92,17 +92,17 @@ void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool colormode, bool textu
|
|||
|
||||
GX_ClearVtxDesc();
|
||||
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
if(normalmode==TRUE) GX_SetVtxDesc(GX_VA_NRM, GX_DIRECT);
|
||||
if(colormode==TRUE) GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
if(texturemode==TRUE) GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
if(normalmode) GX_SetVtxDesc(GX_VA_NRM, GX_DIRECT);
|
||||
if(colormode) GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
if(texturemode) GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
|
||||
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||
if(normalmode==TRUE) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0);
|
||||
if(colormode==TRUE) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
|
||||
if(texturemode==TRUE ) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
|
||||
if(normalmode) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0);
|
||||
if(colormode) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
|
||||
if(texturemode) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
|
||||
|
||||
if(texturemode==FALSE) GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
else GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
|
||||
if(texturemode) GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
|
||||
else GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,23 +9,45 @@
|
|||
// Font
|
||||
#include "FreeMonoBold_ttf.h"
|
||||
|
||||
extern GXRModeObj *rmode;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Initialise the Graphics & Video subsystem
|
||||
GRRLIB_Init();
|
||||
GRRLIB_ttfFont *myFont = GRRLIB_LoadTTF(FreeMonoBold_ttf, FreeMonoBold_ttf_size);
|
||||
|
||||
GRRLIB_texImg *CopiedImg = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);
|
||||
|
||||
// Initialise the Wii Remotes
|
||||
WPAD_Init();
|
||||
|
||||
// Load the font from memory
|
||||
GRRLIB_ttfFont *myFont = GRRLIB_LoadTTF(FreeMonoBold_ttf, FreeMonoBold_ttf_size);
|
||||
// Create an empty texture to store a copy of the screen
|
||||
GRRLIB_texImg *CopiedImg = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);
|
||||
|
||||
// Fill a table with characters
|
||||
u32 i, n = 0;
|
||||
wchar_t charTable[450];
|
||||
for(i=33; i<=126; i++) { // 0 to 93
|
||||
charTable[n++] = i;
|
||||
}
|
||||
for(i=161; i<=516; i++) { // 94 to 449
|
||||
charTable[n++] = i;
|
||||
}
|
||||
|
||||
// Seed the random-number generator with current time so that
|
||||
// the numbers will be different every time we run.
|
||||
srand(time(NULL));
|
||||
|
||||
wchar_t Letter[2] = L""; // A character + terminal NULL
|
||||
|
||||
// To have a cool effect anti-aliasing is turned on
|
||||
GRRLIB_Settings.antialias = true;
|
||||
|
||||
// Black background
|
||||
GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);
|
||||
|
||||
// Loop forever
|
||||
while(1) {
|
||||
GRRLIB_DrawImg(0, 0, CopiedImg, 0, 1, 1, 0xFFFFFFFF);
|
||||
char Letter[2] = {rand() % 93 + 32, '\0'};
|
||||
GRRLIB_PrintfTTF(rand() % rmode->fbWidth - 50,
|
||||
Letter[0] = charTable[rand() % 449];
|
||||
GRRLIB_PrintfTTFW(rand() % rmode->fbWidth - 50,
|
||||
rand() % rmode->efbHeight - 50,
|
||||
myFont,
|
||||
Letter,
|
||||
|
@ -37,19 +59,20 @@ int main(int argc, char **argv) {
|
|||
|
||||
WPAD_ScanPads(); // Scan the Wii Remotes
|
||||
|
||||
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
|
||||
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) {
|
||||
break;
|
||||
}
|
||||
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) {
|
||||
GRRLIB_Rectangle(0, 0, rmode->fbWidth, rmode->efbHeight, 0x000000FF, 1);
|
||||
GRRLIB_Screen2Texture(0, 0, CopiedImg, false);
|
||||
}
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_1 && WPAD_ButtonsHeld(0) & WPAD_BUTTON_2) {
|
||||
WPAD_Rumble(0, true); // Rumble on
|
||||
GRRLIB_ScrShot("sd:/grrlib_ttf.png");
|
||||
GRRLIB_ScrShot("sd:/grrlib_ttf.png"); // Needs to be after GRRLIB_Render()
|
||||
WPAD_Rumble(0, false); // Rumble off
|
||||
}
|
||||
}
|
||||
|
||||
GRRLIB_FreeTexture(CopiedImg);
|
||||
GRRLIB_FreeTTF(myFont);
|
||||
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
|
||||
|
||||
|
|
Loading…
Reference in a new issue