GRRLIB/examples/3D_Light3/source/main.c

104 lines
3.3 KiB
C
Raw Permalink Normal View History

/*===========================================
NoNameNo
A little Specular light sample code
============================================*/
#include <grrlib.h>
#include <stdlib.h>
#include <wiiuse/wpad.h>
#include "font9x12_png.h"
int main() {
2010-05-01 18:02:42 +00:00
f32 rot = 0.0f;
float shininess = 10.0f;
GRRLIB_Init();
WPAD_Init();
GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font9x12_png);
GRRLIB_InitTileSet(tex_font, 9, 12, 32);
GRRLIB_Settings.antialias = true;
GRRLIB_SetBackgroundColour(0x40, 0x40, 0x40, 0xFF);
while(1) {
2010-05-01 18:02:42 +00:00
GRRLIB_Camera3dSettings(0.0f,0.0f,10.0f, 0,1,0, 0,0,0);
WPAD_ScanPads();
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) shininess+=1;
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) shininess-=1;
GRRLIB_3dMode(0.1,1000,45,0,1);
2010-05-01 18:02:42 +00:00
// dir param of GRRLIB_SetLightSpec function have to be a crazy 0,0,0 value
// there is a bug in libogc about this
2021-06-26 17:14:43 +00:00
// https://devkitpro.org/viewtopic.php?f=7&t=1933
// we are waiting for a fix from libogc devs
2010-05-01 18:02:42 +00:00
GRRLIB_SetLightAmbient(0x404040FF);
GRRLIB_SetLightSpec(0, (guVector){0.0f,0.0f,0.0f}, shininess, 0xFFFFFFFF, 0xFFFFFFFF);
2010-05-01 18:02:42 +00:00
GRRLIB_ObjectViewBegin();
GRRLIB_ObjectViewTrans(0.0f,1.3f,0.0f);
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
GRRLIB_ObjectViewEnd();
2022-11-20 19:40:19 +00:00
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
2010-05-01 18:02:42 +00:00
GRRLIB_ObjectViewBegin();
GRRLIB_ObjectViewRotate(0.0f,0.0f,90.0f);
GRRLIB_ObjectViewTrans(-1.3f,0.0f,0.0f);
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
GRRLIB_ObjectViewEnd();
2022-11-20 19:40:19 +00:00
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
2010-05-01 18:02:42 +00:00
GRRLIB_ObjectViewBegin();
GRRLIB_ObjectViewRotate(0.0f,0.0f,180.0f);
GRRLIB_ObjectViewTrans(0.0f,-1.3f,0.0f);
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
GRRLIB_ObjectViewEnd();
2022-11-20 19:40:19 +00:00
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
2010-05-01 18:02:42 +00:00
GRRLIB_ObjectViewBegin();
GRRLIB_ObjectViewRotate(0.0f,0.0f,-90.0f);
GRRLIB_ObjectViewTrans(1.3f,0.0f,0.0f);
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
GRRLIB_ObjectViewEnd();
2022-11-20 19:40:19 +00:00
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
2010-05-01 18:02:42 +00:00
GRRLIB_ObjectViewBegin();
GRRLIB_ObjectViewRotate(-90.0f,0.0f,0.0f);
GRRLIB_ObjectViewTrans(0.0f,0.0f,-1.3f);
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
GRRLIB_ObjectViewEnd();
2022-11-20 19:40:19 +00:00
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
2010-05-01 18:02:42 +00:00
GRRLIB_ObjectViewBegin();
GRRLIB_ObjectViewRotate(90.0f,0.0f,0.0f);
GRRLIB_ObjectViewTrans(0.0f,0.0f,1.3f);
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
GRRLIB_ObjectViewEnd();
2022-11-20 19:40:19 +00:00
GRRLIB_DrawCone(0.6f, 2.6f, 60, true, 0x502010FF);
2010-05-01 18:02:42 +00:00
GRRLIB_ObjectViewBegin();
GRRLIB_ObjectViewRotate(rot,rot*2,rot*3);
GRRLIB_ObjectViewEnd();
GRRLIB_DrawCube( 0.6f, true, 0x102050FF);
rot+=0.8f;
GRRLIB_2dMode();
GRRLIB_Printf(50, 60, tex_font, 0xFFFFFFFF, 1, "Use ( A / B ) to change the shininess value: %d", (int)shininess);
GRRLIB_Render();
}
GRRLIB_FreeTexture(tex_font);
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
exit(0);
}