[CHG] Replaced tabs with spaces

[CHG] Adapted lesson1
This commit is contained in:
Crayon2000 2009-11-25 05:14:28 +00:00
parent 9e0b0182a9
commit fc3c97d90d
5 changed files with 70 additions and 53 deletions

View file

@ -53,11 +53,11 @@ void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex)
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
// Get current drawing settings. // Get current drawing settings.
u32 color = GRRLIB_Settings.colorRGBA; u32 color = GRRLIB_Settings.colorRGBA;
f32 degrees = GRRLIB_Settings.rotation; f32 degrees = GRRLIB_Settings.rotation;
f32 scaleX = GRRLIB_Settings.scaleX; f32 scaleX = GRRLIB_Settings.scaleX;
f32 scaleY = GRRLIB_Settings.scaleY; f32 scaleY = GRRLIB_Settings.scaleY;
guMtxIdentity (m1); guMtxIdentity (m1);
guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0); guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0);
@ -123,8 +123,8 @@ void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex) {
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
// Get current drawing settings. // Get current drawing settings.
u32 color = GRRLIB_Settings.colorRGBA; u32 color = GRRLIB_Settings.colorRGBA;
guMtxIdentity (m1); guMtxIdentity (m1);
guMtxScaleApply(m1, m1, 1, 1, 1.0); guMtxScaleApply(m1, m1, 1, 1, 1.0);
@ -192,11 +192,11 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
width = tex->tilew * 0.5f; width = tex->tilew * 0.5f;
height = tex->tileh * 0.5f; height = tex->tileh * 0.5f;
// Get current drawing settings. // Get current drawing settings.
u32 color = GRRLIB_Settings.colorRGBA; u32 color = GRRLIB_Settings.colorRGBA;
f32 degrees = GRRLIB_Settings.rotation; f32 degrees = GRRLIB_Settings.rotation;
f32 scaleX = GRRLIB_Settings.scaleX; f32 scaleX = GRRLIB_Settings.scaleX;
f32 scaleY = GRRLIB_Settings.scaleY; f32 scaleY = GRRLIB_Settings.scaleY;
guMtxIdentity (m1); guMtxIdentity (m1);
guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0f); guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0f);
@ -271,11 +271,11 @@ void GRRLIB_DrawPart (const f32 xpos, const f32 ypos, const f32 partx, const f3
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
// Get current drawing settings. // Get current drawing settings.
u32 color = GRRLIB_Settings.colorRGBA; u32 color = GRRLIB_Settings.colorRGBA;
f32 degrees = GRRLIB_Settings.rotation; f32 degrees = GRRLIB_Settings.rotation;
f32 scaleX = GRRLIB_Settings.scaleX; f32 scaleX = GRRLIB_Settings.scaleX;
f32 scaleY = GRRLIB_Settings.scaleY; f32 scaleY = GRRLIB_Settings.scaleY;
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
@ -355,8 +355,8 @@ void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex, const int
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
// Get current drawing settings. // Get current drawing settings.
u32 color = GRRLIB_Settings.colorRGBA; u32 color = GRRLIB_Settings.colorRGBA;
guMtxIdentity (m1); guMtxIdentity (m1);
guMtxScaleApply(m1, m1, 1, 1, 1.0f); guMtxScaleApply(m1, m1, 1, 1, 1.0f);

View file

@ -91,7 +91,7 @@ bool GRRLIB_ScrShot (const char* filename) ;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//! GRRLIB_print.c - Will someome please tell me what these are :) //! GRRLIB_print.c - Will someome please tell me what these are :)
void GRRLIB_Printf (const f32 xpos, const f32 ypos, void GRRLIB_Printf (const f32 xpos, const f32 ypos,
const GRRLIB_texImg *tex, const GRRLIB_texImg *tex,
const char *text, ...) ; const char *text, ...) ;
void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos, void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos,

View file

@ -34,8 +34,8 @@ extern GRRLIB_drawSettings GRRLIB_Settings;
*/ */
INLINE INLINE
void GRRLIB_FillScreen (const u32 color) { void GRRLIB_FillScreen (const u32 color) {
u32 tmpColor = GRRLIB_Settings.colorRGBA; u32 tmpColor = GRRLIB_Settings.colorRGBA;
GRRLIB_SetColorRGBA(color); GRRLIB_SetColorRGBA(color);
GRRLIB_Rectangle(-40, -40, rmode->fbWidth +80, rmode->xfbHeight +80, 1); GRRLIB_Rectangle(-40, -40, rmode->fbWidth +80, rmode->xfbHeight +80, 1);
GRRLIB_SetColorRGBA(tmpColor); GRRLIB_SetColorRGBA(tmpColor);
} }
@ -85,12 +85,12 @@ INLINE
void GRRLIB_Rectangle (const f32 x, const f32 y, void GRRLIB_Rectangle (const f32 x, const f32 y,
const f32 width, const f32 height, const f32 width, const f32 height,
const u8 filled) { const u8 filled) {
// Get current drawing settings. // Get current drawing settings.
u32 color = GRRLIB_Settings.colorRGBA; u32 color = GRRLIB_Settings.colorRGBA;
f32 scaleX = GRRLIB_Settings.scaleX; f32 scaleX = GRRLIB_Settings.scaleX;
f32 scaleY = GRRLIB_Settings.scaleY; f32 scaleY = GRRLIB_Settings.scaleY;
f32 x2 = x + width * scaleX; f32 x2 = x + width * scaleX;
f32 y2 = y + height * scaleY; f32 y2 = y + height * scaleY;

View file

@ -102,10 +102,10 @@ void GRRLIB_SetColor (const u8 r, const u8 g, const u8 b) {
*/ */
INLINE INLINE
void GRRLIB_SetColorRGBA (const u32 color) { void GRRLIB_SetColorRGBA (const u32 color) {
GRRLIB_Settings.colorR = R(color); GRRLIB_Settings.colorR = R(color);
GRRLIB_Settings.colorG = G(color); GRRLIB_Settings.colorG = G(color);
GRRLIB_Settings.colorB = B(color); GRRLIB_Settings.colorB = B(color);
GRRLIB_Settings.colorA = A(color); GRRLIB_Settings.colorA = A(color);
GRRLIB_Settings.colorRGBA = color; GRRLIB_Settings.colorRGBA = color;
} }

View file

@ -106,14 +106,17 @@ int main() {
switch(page) switch(page)
{ {
case 1: // Draw images case 1: // Draw images
GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "IMAGES DEMO"); GRRLIB_ResetSettings();
GRRLIB_Printf(5, 25, tex_BMfont2, "IMAGES DEMO");
GRRLIB_DrawImg(10, 50, tex_test_jpg, 0, 1, 1, GRRLIB_WHITE); // Draw a jpeg GRRLIB_DrawImg(10, 50, tex_test_jpg); // Draw a jpeg
GRRLIB_DrawImg(350, 50, tex_test_bmp, 0, 4, 4, GRRLIB_WHITE); // Draw a bitmap GRRLIB_SetScale(4, 4);
GRRLIB_DrawImg(350, 50, tex_test_bmp); // Draw a bitmap
// Draw a sprite // Draw a sprite
GRRLIB_DrawTile(600, 400, tex_sprite_png, 0, 2, 2, GRRLIB_WHITE, 12*4); // Rupee GRRLIB_SetScale(2, 2);
GRRLIB_DrawTile(320+left, 240+top, tex_sprite_png, 0, 2, 2, GRRLIB_WHITE, frame); GRRLIB_DrawTile(600, 400, tex_sprite_png, 12*4); // Rupee
GRRLIB_DrawTile(320+left, 240+top, tex_sprite_png, frame);
if(GRRLIB_RectOnRect(320+left, 240+top, 48, 64, 618, 434, 12, 30)) if(GRRLIB_RectOnRect(320+left, 240+top, 48, 64, 618, 434, 12, 30))
{ {
WPAD_Rumble(WPAD_CHAN_0, 1); WPAD_Rumble(WPAD_CHAN_0, 1);
@ -140,33 +143,47 @@ int main() {
} }
break; break;
case 2: // Draw shapes case 2: // Draw shapes
GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "SHAPES DEMO"); GRRLIB_ResetSettings();
GRRLIB_Printf(5, 25, tex_BMfont2, "SHAPES DEMO");
GRRLIB_Rectangle(100, 100, 200, 100, GRRLIB_RED, 1); GRRLIB_SetColorRGBA(GRRLIB_RED);
GRRLIB_Line(100, 100, 350, 200, GRRLIB_SILVER); GRRLIB_Rectangle(100, 100, 200, 100, 1);
GRRLIB_SetColorRGBA(GRRLIB_SILVER);
GRRLIB_Line(100, 100, 350, 200);
GRRLIB_NGoneFilled(triangle, trianglecolor, 3); GRRLIB_NGoneFilled(triangle, trianglecolor, 3);
GRRLIB_Rectangle(left + 150, top + 150, 200, 200, 0x0000FFC8, 1); // Blue with alpha GRRLIB_SetColorRGBA(0x0000FFC8); // Blue with alpha
GRRLIB_Rectangle(left + 150, top + 150, 200, 200, 1);
GRRLIB_SetColorRGBA(GRRLIB_OLIVE);
GRRLIB_Circle(left + 300, top + 300, 50, GRRLIB_OLIVE, 1); GRRLIB_Circle(left + 300, top + 300, 50, GRRLIB_OLIVE, 1);
// Draw a yellow four pixel dot where the wiimote is pointing // Draw a yellow four pixel dot where the wiimote is pointing
GRRLIB_Plot(ir1.sx, ir1.sy, GRRLIB_YELLOW); GRRLIB_SetColorRGBA(GRRLIB_YELLOW);
GRRLIB_Plot(ir1.sx + 1, ir1.sy, GRRLIB_YELLOW); GRRLIB_Plot(ir1.sx, ir1.sy);
GRRLIB_Plot(ir1.sx, ir1.sy + 1, GRRLIB_YELLOW); GRRLIB_Plot(ir1.sx + 1, ir1.sy);
GRRLIB_Plot(ir1.sx + 1, ir1.sy + 1, GRRLIB_YELLOW); GRRLIB_Plot(ir1.sx, ir1.sy + 1);
GRRLIB_Plot(ir1.sx + 1, ir1.sy + 1);
break; break;
default: // Print some text default: // Print some text
GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "TEXT DEMO"); GRRLIB_ResetSettings();
GRRLIB_Printf(5, 25, tex_BMfont2, "TEXT DEMO");
GRRLIB_Printf(5, 100, tex_BMfont4, GRRLIB_WHITE, 1, "TO QUIT PRESS THE HOME BUTTON."); GRRLIB_Printf(5, 100, tex_BMfont4, "TO QUIT PRESS THE HOME BUTTON.");
GRRLIB_Printf(5, 140, tex_BMfont4, GRRLIB_YELLOW, 1, "USE + OR - TO MOVE ACROSS PAGES."); GRRLIB_SetColorRGBA(GRRLIB_YELLOW);
GRRLIB_Printf(5, 180, tex_BMfont4, GRRLIB_GREEN, 1, "USE THE D-PAD TO MOVE STUFF."); GRRLIB_Printf(5, 140, tex_BMfont4, "USE + OR - TO MOVE ACROSS PAGES.");
GRRLIB_Printf(left, top+250, tex_BMfont1, GRRLIB_WHITE, 1, "IR X VALUE: %d", (int)ir1.x); GRRLIB_SetColorRGBA(GRRLIB_GREEN);
GRRLIB_Printf(left, top+300, tex_BMfont3, GRRLIB_WHITE, 1, "IR Y VALUE: %d", (int)ir1.y); GRRLIB_Printf(5, 180, tex_BMfont4, "USE THE D-PAD TO MOVE STUFF.");
GRRLIB_Printf(left, top+350, tex_BMfont3, 0XFFFFFF50, 1, "TEXT WITH ALPHA"); GRRLIB_SetColorRGBA(GRRLIB_WHITE);
GRRLIB_Printf(left, top+400, tex_BMfont5, GRRLIB_LIME, 1, "This font has the 128 ASCII characters"); GRRLIB_Printf(left, top+250, tex_BMfont1, "IR X VALUE: %d", (int)ir1.x);
GRRLIB_Printf(left, top+300, tex_BMfont3, "IR Y VALUE: %d", (int)ir1.y);
GRRLIB_SetColorRGBA(0XFFFFFF50);
GRRLIB_Printf(left, top+350, tex_BMfont3, "TEXT WITH ALPHA");
GRRLIB_SetColorRGBA(GRRLIB_LIME);
GRRLIB_Printf(left, top+400, tex_BMfont5, "This font has the 128 ASCII characters");
GRRLIB_SetColorRGBA(GRRLIB_WHITE);
GRRLIB_PrintBMF(left, top+420, bmf_Font2, 1, "%s", bmf_Font2->name); GRRLIB_PrintBMF(left, top+420, bmf_Font2, 1, "%s", bmf_Font2->name);
} }
GRRLIB_Printf(500, 27, tex_BMfont5, GRRLIB_WHITE, 1, "Current FPS: %d", FPS); GRRLIB_ResetSettings();
GRRLIB_Printf(500, 27, tex_BMfont5, "Current FPS: %d", FPS);
GRRLIB_Render(); GRRLIB_Render();
FPS = CalculateFrameRate(); FPS = CalculateFrameRate();