mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-10 10:22:20 +00:00
102 lines
2.6 KiB
C
102 lines
2.6 KiB
C
|
/*===========================================
|
||
|
NoNameNo Simple 3D cube Sample Code
|
||
|
============================================*/
|
||
|
#include <grrlib.h>
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
#include <math.h>
|
||
|
#include <malloc.h>
|
||
|
#include <wiiuse/wpad.h>
|
||
|
|
||
|
extern GXRModeObj *rmode;
|
||
|
|
||
|
int main() {
|
||
|
float a=0;
|
||
|
u32 col[3];
|
||
|
col[0]=0xFFFFFFFF;
|
||
|
col[1]=0xAAAAAAFF;
|
||
|
col[2]=0x666666FF;
|
||
|
int cubeZ=0;
|
||
|
|
||
|
GRRLIB_Init();
|
||
|
WPAD_Init();
|
||
|
|
||
|
GRRLIB_Settings.antialias = true;
|
||
|
|
||
|
GRRLIB_setBackgroundColour(0x00, 0x00, 0x00, 0xFF);
|
||
|
GRRLIB_camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0);
|
||
|
|
||
|
while(1) {
|
||
|
GRRLIB_2dMode();
|
||
|
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--;
|
||
|
|
||
|
GRRLIB_3dMode(0.1,1000,45,0);
|
||
|
GRRLIB_objectView(0,0,cubeZ, a,a*2,a*3);
|
||
|
GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
|
||
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||
|
GX_Color1u32(col[0]);
|
||
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||
|
GX_Color1u32(col[0]);
|
||
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||
|
GX_Color1u32(col[0]);
|
||
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||
|
GX_Color1u32(col[0]);
|
||
|
|
||
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||
|
GX_Color1u32(col[0]);
|
||
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||
|
GX_Color1u32(col[0]);
|
||
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||
|
GX_Color1u32(col[0]);
|
||
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
||
|
GX_Color1u32(col[0]);
|
||
|
|
||
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||
|
GX_Color1u32(col[1]);
|
||
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
||
|
GX_Color1u32(col[1]);
|
||
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||
|
GX_Color1u32(col[1]);
|
||
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||
|
GX_Color1u32(col[1]);
|
||
|
|
||
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||
|
GX_Color1u32(col[1]);
|
||
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||
|
GX_Color1u32(col[1]);
|
||
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||
|
GX_Color1u32(col[1]);
|
||
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||
|
GX_Color1u32(col[1]);
|
||
|
|
||
|
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||
|
GX_Color1u32(col[2]);
|
||
|
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||
|
GX_Color1u32(col[2]);
|
||
|
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||
|
GX_Color1u32(col[2]);
|
||
|
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||
|
GX_Color1u32(col[2]);
|
||
|
|
||
|
GX_Position3f32(1.0f,1.0f,1.0f);
|
||
|
GX_Color1u32(col[2]);
|
||
|
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||
|
GX_Color1u32(col[2]);
|
||
|
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||
|
GX_Color1u32(col[2]);
|
||
|
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||
|
GX_Color1u32(col[2]);
|
||
|
GX_End();
|
||
|
|
||
|
a+=0.5f;
|
||
|
GRRLIB_Render();
|
||
|
}
|
||
|
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
|
||
|
|
||
|
exit(0);
|
||
|
}
|
||
|
|