2009-12-07 18:29:47 +00:00
|
|
|
/*===========================================
|
|
|
|
NoNameNo
|
|
|
|
Simple Textured 3D cube and Compositing
|
|
|
|
to make a nice sin wave on it ;)
|
|
|
|
============================================*/
|
|
|
|
#include <grrlib.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <wiiuse/wpad.h>
|
|
|
|
|
|
|
|
|
2022-05-25 13:20:52 +00:00
|
|
|
#include "font_png.h"
|
|
|
|
#include "girl_png.h"
|
2009-12-07 18:29:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
2009-12-15 22:32:21 +00:00
|
|
|
float a=0;
|
|
|
|
int cubeZ=5;
|
2020-01-13 19:41:26 +00:00
|
|
|
int i;
|
2017-06-18 18:29:12 +00:00
|
|
|
float sinx=0;
|
2009-12-07 18:29:47 +00:00
|
|
|
|
|
|
|
GRRLIB_Init();
|
|
|
|
WPAD_Init();
|
|
|
|
|
|
|
|
GRRLIB_texImg *tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth,rmode->efbHeight);
|
|
|
|
GRRLIB_InitTileSet(tex_screen, rmode->fbWidth, 1, 0);
|
|
|
|
|
2022-05-25 13:20:52 +00:00
|
|
|
GRRLIB_texImg *tex_girl= GRRLIB_LoadTexture(girl_png);
|
2009-12-07 18:29:47 +00:00
|
|
|
|
2022-05-25 13:20:52 +00:00
|
|
|
GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font_png);
|
2009-12-07 18:29:47 +00:00
|
|
|
GRRLIB_InitTileSet(tex_font, 16, 16, 32);
|
|
|
|
|
|
|
|
|
|
|
|
GRRLIB_Settings.antialias = true;
|
|
|
|
|
2009-12-15 22:51:39 +00:00
|
|
|
GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);
|
|
|
|
GRRLIB_Camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0);
|
2009-12-07 18:29:47 +00:00
|
|
|
|
|
|
|
while(1) {
|
2009-12-15 22:32:21 +00:00
|
|
|
GRRLIB_2dMode();
|
2009-12-07 18:29:47 +00:00
|
|
|
WPAD_ScanPads();
|
|
|
|
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
|
|
|
|
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++;
|
|
|
|
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--;
|
|
|
|
|
2010-04-06 11:23:31 +00:00
|
|
|
GRRLIB_3dMode(0.1,1000,45,1,0);
|
2009-12-15 22:51:39 +00:00
|
|
|
GRRLIB_SetTexture(tex_girl,0);
|
2010-01-05 22:04:33 +00:00
|
|
|
GRRLIB_ObjectView(0,0,cubeZ, a,a*2,a*3,1,1,1);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
|
|
|
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,0.0f);
|
|
|
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,0.0f);
|
|
|
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,1.0f);
|
|
|
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,1.0f);
|
|
|
|
|
|
|
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,0.0f);
|
|
|
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,0.0f);
|
|
|
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,1.0f);
|
|
|
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,1.0f);
|
|
|
|
|
|
|
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,0.0f);
|
|
|
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,0.0f);
|
|
|
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,1.0f);
|
|
|
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,1.0f);
|
|
|
|
|
|
|
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,0.0f);
|
|
|
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,0.0f);
|
|
|
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,1.0f);
|
|
|
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,1.0f);
|
|
|
|
|
|
|
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,0.0f);
|
|
|
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,0.0f);
|
|
|
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,1.0f);
|
|
|
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,1.0f);
|
|
|
|
|
|
|
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,0.0f);
|
|
|
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,0.0f);
|
|
|
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(1.0f,1.0f);
|
|
|
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_Color1u32(0xFFFFFFFF);
|
2009-12-15 22:32:21 +00:00
|
|
|
GX_TexCoord2f32(0.0f,1.0f);
|
2010-10-05 02:50:44 +00:00
|
|
|
GX_End();
|
2009-12-15 22:32:21 +00:00
|
|
|
GRRLIB_Screen2Texture(0,0,tex_screen,1);
|
|
|
|
a+=0.5f;
|
|
|
|
|
|
|
|
// Switch To 2D Mode to display text
|
|
|
|
GRRLIB_2dMode();
|
2017-06-18 18:29:12 +00:00
|
|
|
const float oldsinx=sinx;
|
2009-12-15 22:32:21 +00:00
|
|
|
for(i=0; i<rmode->efbHeight; i++) {
|
|
|
|
GRRLIB_DrawTile(0+sin(sinx)*60,i,tex_screen,0,1,1,0xFFFFFFFF,i);
|
|
|
|
sinx+=0.02f;
|
|
|
|
}
|
|
|
|
sinx=oldsinx+0.02f;
|
|
|
|
|
|
|
|
GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS A OR B TO ZOOM THE CUBE");
|
2009-12-07 18:29:47 +00:00
|
|
|
|
|
|
|
GRRLIB_Render();
|
|
|
|
}
|
|
|
|
GRRLIB_FreeTexture(tex_girl);
|
|
|
|
GRRLIB_FreeTexture(tex_font);
|
|
|
|
GRRLIB_FreeTexture(tex_screen);
|
2011-03-16 01:24:01 +00:00
|
|
|
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
|
2009-12-07 18:29:47 +00:00
|
|
|
exit(0);
|
|
|
|
}
|