2022-05-28 05:27:55 +00:00
|
|
|
/*===========================================
|
|
|
|
NoNameNo
|
|
|
|
|
|
|
|
A little Specular light sample code
|
|
|
|
============================================*/
|
|
|
|
#include <grrlib.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ogc/pad.h>
|
|
|
|
|
|
|
|
#include "font9x12_png.h"
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
f32 rot = 0.0f;
|
|
|
|
float shininess = 10.0f;
|
|
|
|
|
|
|
|
GRRLIB_Init();
|
|
|
|
PAD_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) {
|
|
|
|
GRRLIB_Camera3dSettings(0.0f,0.0f,10.0f, 0,1,0, 0,0,0);
|
|
|
|
|
|
|
|
PAD_ScanPads();
|
|
|
|
|
|
|
|
if(PAD_ButtonsDown(0) & PAD_BUTTON_START) break;
|
|
|
|
if(PAD_ButtonsHeld(0) & PAD_BUTTON_A) shininess+=1;
|
|
|
|
if(PAD_ButtonsHeld(0) & PAD_BUTTON_B) shininess-=1;
|
|
|
|
|
|
|
|
GRRLIB_3dMode(0.1,1000,45,0,1);
|
|
|
|
|
|
|
|
// dir param of GRRLIB_SetLightSpec function have to be a crazy 0,0,0 value
|
|
|
|
// there is a bug in libogc about this
|
|
|
|
// https://devkitpro.org/viewtopic.php?f=7&t=1933
|
|
|
|
// we are waiting for a fix from libogc devs
|
|
|
|
GRRLIB_SetLightAmbient(0x404040FF);
|
|
|
|
GRRLIB_SetLightSpec(0, (guVector){0.0f,0.0f,0.0f}, shininess, 0xFFFFFFFF, 0xFFFFFFFF);
|
|
|
|
|
|
|
|
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);
|
2022-05-28 05:27:55 +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);
|
2022-05-28 05:27:55 +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);
|
2022-05-28 05:27:55 +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);
|
2022-05-28 05:27:55 +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);
|
2022-05-28 05:27:55 +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);
|
2022-05-28 05:27:55 +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);
|
|
|
|
}
|