mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 06:52:20 +00:00
[CHG] function GRRLIB_3dMode color paramter removed since you now MUST pass vertex color !!
[ADD] Diffuse light function GRRLIB_SetLightDiff [ADD] GRRLIB_SetLightAmbiant [ADD] GRRLIB_SetLightOff [ADD] A simple Diffuse lights sample code (Two lights)
This commit is contained in:
parent
af6f13de76
commit
16c25c1ed2
16 changed files with 500 additions and 26 deletions
|
@ -78,11 +78,10 @@ void GRRLIB_Camera3dSettings(f32 posx, f32 posy, f32 posz,
|
|||
* @param minDist Minimal distance for the camera.
|
||||
* @param maxDist Maximal distance for the camera.
|
||||
* @param fov Field of view for the camera.
|
||||
* @param colormode False, GX won't need vertex colors, True, GX will need vertex colors.
|
||||
* @param texturemode False, GX won't need texture coordinate, True, GX will need texture coordinate.
|
||||
* @param normalmode False, GX won't need normal coordinate, True, GX will need normal coordinate.
|
||||
*/
|
||||
void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool colormode, bool texturemode, bool normalmode) {
|
||||
void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool texturemode, bool normalmode) {
|
||||
Mtx m;
|
||||
|
||||
guLookAt(_GRR_view, &_GRR_cam, &_GRR_up, &_GRR_look);
|
||||
|
@ -95,12 +94,12 @@ void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool colormode, bool textu
|
|||
GX_ClearVtxDesc();
|
||||
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
if(normalmode) GX_SetVtxDesc(GX_VA_NRM, GX_DIRECT);
|
||||
if(colormode) GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
if(texturemode) GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
|
||||
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||
if(normalmode) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0);
|
||||
if(colormode) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
|
||||
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
|
||||
if(texturemode) GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
|
||||
|
||||
if(texturemode) GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
|
||||
|
@ -140,6 +139,13 @@ void GRRLIB_2dMode() {
|
|||
GX_SetNumTevStages(1);
|
||||
|
||||
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||
|
||||
GRRLIB_Settings.lights = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,7 +219,7 @@ void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) {
|
|||
* @param rings Number of rings.
|
||||
* @param filled Wired or not.
|
||||
*/
|
||||
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled) {
|
||||
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col) {
|
||||
int i, j;
|
||||
f32 theta, phi, theta1;
|
||||
f32 cosTheta, sinTheta;
|
||||
|
@ -242,8 +248,10 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled) {
|
|||
|
||||
GX_Position3f32(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||
GX_Normal3f32(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(cosTheta * dist, -sinTheta * dist, r * sinPhi);
|
||||
GX_Normal3f32(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
theta = theta1;
|
||||
|
@ -259,7 +267,7 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled) {
|
|||
* @param longs Number of longitutes.
|
||||
* @param filled Wired or not.
|
||||
*/
|
||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled) {
|
||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) {
|
||||
int i, j;
|
||||
f32 lat0, z0, zr0,
|
||||
lat1, z1, zr1,
|
||||
|
@ -282,8 +290,10 @@ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled) {
|
|||
|
||||
GX_Position3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
||||
GX_Normal3f32(x * zr0 * r, y * zr0 * r, z0 * r);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(x * zr1 * r, y * zr1 * r, z1 * r);
|
||||
GX_Normal3f32(x * zr1 * r, y * zr1 * r, z1 * r);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
}
|
||||
|
@ -294,7 +304,7 @@ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled) {
|
|||
* @param size Size of the cube edge.
|
||||
* @param filled Wired or not.
|
||||
*/
|
||||
void GRRLIB_DrawCube(f32 size, bool filled) {
|
||||
void GRRLIB_DrawCube(f32 size, bool filled, u32 col) {
|
||||
static f32 n[6][3] =
|
||||
{
|
||||
{-1.0, 0.0, 0.0},
|
||||
|
@ -328,15 +338,20 @@ void GRRLIB_DrawCube(f32 size, bool filled) {
|
|||
else GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 5);
|
||||
GX_Position3f32(v[faces[i][0]][0], v[faces[i][0]][1], v[faces[i][0]][2] );
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(v[faces[i][1]][0], v[faces[i][1]][1], v[faces[i][1]][2]);
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(v[faces[i][2]][0], v[faces[i][2]][1], v[faces[i][2]][2]);
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32(v[faces[i][3]][0], v[faces[i][3]][1], v[faces[i][3]][2]);
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Color1u32(col);
|
||||
if(!filled) {
|
||||
GX_Position3f32(v[faces[i][0]][0], v[faces[i][0]][1], v[faces[i][0]][2]);
|
||||
GX_Normal3f32(n[i][0], n[i][1], n[i][2]);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
}
|
||||
|
@ -349,7 +364,7 @@ void GRRLIB_DrawCube(f32 size, bool filled) {
|
|||
* @param d Dencity of slice.
|
||||
* @param filled Wired or not.
|
||||
*/
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled) {
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
|
||||
int i;
|
||||
f32 dx, dy;
|
||||
|
||||
|
@ -360,8 +375,10 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled) {
|
|||
dy = sinf( M_PI * 2.0f * i / d );
|
||||
GX_Position3f32( r * dx, -0.5f * h, r * dy );
|
||||
GX_Normal3f32( dx, 0.0f, dy );
|
||||
GX_Color1u32(col);
|
||||
GX_Position3f32( r * dx, 0.5f * h, r * dy );
|
||||
GX_Normal3f32( dx, 0.0f, dy );
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
|
||||
|
@ -369,9 +386,11 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled) {
|
|||
else GX_Begin(GX_LINESTRIP, GX_VTXFMT0, d+2);
|
||||
GX_Position3f32(0.0f, -0.5f * h, 0.0f);
|
||||
GX_Normal3f32(0.0f, -1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
for(i = 0 ; i <= d ; i++) {
|
||||
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), -0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
||||
GX_Normal3f32(0.0f, -1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
|
||||
|
@ -379,9 +398,62 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled) {
|
|||
else GX_Begin(GX_LINESTRIP, GX_VTXFMT0, d+2);
|
||||
GX_Position3f32(0.0f, 0.5f * h, 0.0f);
|
||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
for(i = 0 ; i <= d ; i++) {
|
||||
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
|
||||
GX_Normal3f32(0.0f, 1.0f, 0.0f);
|
||||
GX_Color1u32(col);
|
||||
}
|
||||
GX_End();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Ambiant Color
|
||||
*/
|
||||
void GRRLIB_SetLightAmbiant(u32 ambiantcolor){
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { R(ambiantcolor), G(ambiantcolor), B(ambiantcolor), 0xFF});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Diffuse Light Parameters
|
||||
* @param num number of the light
|
||||
* @param pos position of the diffuse light (x/y/z)
|
||||
* @param distattn distance attenuation
|
||||
* @param brightness Brightness of the light
|
||||
* @param lightcolor color of the light
|
||||
* @param ambiant anbiant color.
|
||||
*/
|
||||
void GRRLIB_SetLightDiff(int num, guVector pos, float distattn, float brightness , u32 lightcolor){
|
||||
GXLightObj MyLight;
|
||||
guVector lpos={pos.x,pos.y,pos.z};
|
||||
|
||||
GRRLIB_Settings.lights |= (1<<num);
|
||||
|
||||
guVecMultiply(_GRR_view, &lpos, &lpos);
|
||||
GX_InitLightPos(&MyLight, lpos.x, lpos.y, lpos.z);
|
||||
GX_InitLightColor(&MyLight, (GXColor) { R(lightcolor), G(lightcolor), B(lightcolor), 0xFF });
|
||||
GX_InitLightSpot(&MyLight, 0.0f, GX_SP_OFF);
|
||||
GX_InitLightDistAttn(&MyLight, distattn, brightness, GX_DA_MEDIUM); // DistAttn = 20.0 & Brightness=1.0f (full)
|
||||
GX_LoadLightObj(&MyLight, (1<<num));
|
||||
|
||||
/////////////////////// Turn light ON ////////////////////////////////////////////////
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_VTX, GRRLIB_Settings.lights, GX_DF_CLAMP,GX_AF_SPOT); //4th param is where come from the material color (REG(with setChanMatColor or VTX (vertex)) same for ambiant ($
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all Lights Off (like at init);
|
||||
*/
|
||||
void GRRLIB_SetLightOff(void){
|
||||
GX_SetNumTevStages(1);
|
||||
|
||||
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||
|
||||
GRRLIB_Settings.lights = 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -158,6 +158,7 @@ int GRRLIB_Init (void) {
|
|||
// Default settings
|
||||
GRRLIB_Settings.antialias = true;
|
||||
GRRLIB_Settings.blend = GRRLIB_BLEND_ALPHA;
|
||||
GRRLIB_Settings.lights = 0;
|
||||
|
||||
// Schedule cleanup for when program exits
|
||||
is_setup = true;
|
||||
|
|
|
@ -98,6 +98,7 @@ typedef enum GRRLIB_blendMode {
|
|||
typedef struct GRRLIB_drawSettings {
|
||||
bool antialias; /**< AntiAlias is enabled when set to true. */
|
||||
GRRLIB_blendMode blend; /**< Blending Mode. */
|
||||
int lights; /**< active lights */
|
||||
} GRRLIB_drawSettings;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -148,14 +148,17 @@ void GRRLIB_GeckoPrintf (const char *text, ...);
|
|||
// GRRLIB_3D.c - 3D functions for GRRLIB
|
||||
void GRRLIB_SetBackgroundColour(u8 r, u8 g, u8 b, u8 a);
|
||||
void GRRLIB_Camera3dSettings(f32 posx, f32 posy, f32 posz, f32 upx, f32 upy, f32 upz, f32 lookx, f32 looky, f32 lookz);
|
||||
void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool colormode, bool texturemode, bool normalmode);
|
||||
void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool texturemode, bool normalmode);
|
||||
void GRRLIB_2dMode();
|
||||
void GRRLIB_ObjectView(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32 angz, f32 scalx, f32 scaly, f32 scalz);
|
||||
void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep);
|
||||
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled);
|
||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled);
|
||||
void GRRLIB_DrawCube(f32 size, bool filled);
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled);
|
||||
void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col);
|
||||
void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col);
|
||||
void GRRLIB_DrawCube(f32 size, bool filled, u32 col);
|
||||
void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col);
|
||||
void GRRLIB_SetLightAmbiant(u32 ambiantcolor);
|
||||
void GRRLIB_SetLightDiff(int num, guVector pos, float distattn, float brightness , u32 lightcolor);
|
||||
void GRRLIB_SetLightOff(void);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// GRRLIB_ttf.c - FreeType function for GRRLIB
|
||||
|
|
|
@ -277,44 +277,60 @@ int main() {
|
|||
|
||||
|
||||
GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);
|
||||
GRRLIB_3dMode(0.1,3000,45,0,1,0);
|
||||
GRRLIB_3dMode(0.1,3000,45,1,0);
|
||||
GRRLIB_SetTexture(tex_screen,0);
|
||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3,1,1,1);
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0, 16);
|
||||
GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
GX_End();
|
||||
|
||||
|
|
139
examples/3D_Light1/Makefile
Normal file
139
examples/3D_Light1/Makefile
Normal file
|
@ -0,0 +1,139 @@
|
|||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
|
||||
endif
|
||||
|
||||
include $(DEVKITPPC)/wii_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source source/gfx
|
||||
DATA := data
|
||||
INCLUDES :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
CFLAGS = -g -O2 -mrvl -Wall $(MACHDEP) $(INCLUDE)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
LDFLAGS = -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lgrrlib -lfreetype -lpngu -lpng -ljpeg -lz -lfat -lwiiuse -lbte -logc -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CURDIR)/$(GRRLIB)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD := $(CC)
|
||||
else
|
||||
export LD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD) \
|
||||
-I$(LIBOGC_INC)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
-L$(LIBOGC_LIB)
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
run:
|
||||
psoload $(TARGET).dol
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
reload:
|
||||
psoload -r $(TARGET).dol
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).dol: $(OUTPUT).elf
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .jpg extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
67
examples/3D_Light1/source/gfx/font.c
Normal file
67
examples/3D_Light1/source/gfx/font.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
This file was autogenerated by raw2c.
|
||||
Visit http://www.devkitpro.org
|
||||
*/
|
||||
|
||||
const unsigned char font[] = {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
||||
0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x30, 0x08, 0x06, 0x00, 0x00, 0x00, 0x60, 0xc5, 0xa3,
|
||||
0xdf, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
|
||||
0x03, 0x5e, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0x9d, 0xd1, 0xb2, 0xad, 0x20, 0x08, 0x40,
|
||||
0x4f, 0x4d, 0xff, 0xff, 0xcb, 0xdd, 0xa7, 0x3d, 0xd3, 0x6d, 0x6c, 0x54, 0x40, 0x40, 0x5d, 0xeb,
|
||||
0xe9, 0xcc, 0xd9, 0x91, 0x26, 0x48, 0x44, 0x4a, 0xc7, 0xdf, 0x20, 0xee, 0xfb, 0xbe, 0x7f, 0x7f,
|
||||
0x1f, 0xc7, 0x71, 0xfc, 0x81, 0x2b, 0xcf, 0xf1, 0xd7, 0xea, 0xe0, 0x7d, 0xae, 0xf7, 0x39, 0x6b,
|
||||
0xbf, 0x43, 0x4e, 0xbb, 0x78, 0xea, 0xe7, 0x4b, 0x87, 0x5f, 0xd4, 0x74, 0xdb, 0x3b, 0xff, 0xb5,
|
||||
0xed, 0xb7, 0xca, 0xbf, 0xe5, 0x0e, 0xef, 0x81, 0x86, 0x78, 0x63, 0x1f, 0x7d, 0x0e, 0x74, 0x3f,
|
||||
0xaf, 0xf3, 0xfb, 0xd2, 0x57, 0xc9, 0xc1, 0xb4, 0x1e, 0x6b, 0xe9, 0x2c, 0x4b, 0xc7, 0xf6, 0xf6,
|
||||
0xff, 0x79, 0xcc, 0x89, 0x59, 0xc0, 0xca, 0x13, 0xbe, 0x37, 0xb2, 0xe0, 0x66, 0xa8, 0x8b, 0xce,
|
||||
0x66, 0x1b, 0xef, 0x0b, 0xd3, 0xc0, 0xe0, 0x01, 0x5b, 0x68, 0x95, 0xad, 0x39, 0xb8, 0x5a, 0x5a,
|
||||
0x64, 0x44, 0xaa, 0x44, 0x23, 0x8f, 0x03, 0x5c, 0x14, 0x9c, 0x1e, 0x58, 0x3b, 0x3f, 0xaf, 0x7e,
|
||||
0x5a, 0xd8, 0x77, 0xeb, 0xf9, 0x2e, 0x2f, 0x25, 0x30, 0x21, 0xc1, 0x7b, 0xc2, 0x7b, 0x4e, 0x64,
|
||||
0xeb, 0x09, 0xbc, 0xab, 0xf3, 0xb3, 0x6a, 0xab, 0xf5, 0x25, 0xc9, 0x19, 0x69, 0x98, 0x00, 0xb0,
|
||||
0xb7, 0xf3, 0x8b, 0x86, 0x47, 0x60, 0x18, 0x1a, 0xc9, 0x7b, 0x47, 0xff, 0xa5, 0xb7, 0x9b, 0x1e,
|
||||
0xed, 0x67, 0x72, 0x14, 0xd9, 0x9c, 0x5f, 0x8f, 0x0d, 0x78, 0xd8, 0xcb, 0xb3, 0x8d, 0x6b, 0x07,
|
||||
0x83, 0x80, 0xbd, 0x9c, 0xe0, 0x88, 0x27, 0x96, 0x59, 0xfa, 0x6f, 0xe5, 0xc0, 0xac, 0xaf, 0x37,
|
||||
0xab, 0x13, 0x24, 0x02, 0x04, 0xf8, 0x70, 0x00, 0xd1, 0x69, 0x9b, 0xde, 0x08, 0x76, 0x87, 0x47,
|
||||
0x57, 0xe9, 0x3a, 0x40, 0xf7, 0x47, 0xe0, 0x9e, 0x85, 0x93, 0x00, 0x3c, 0x85, 0xe4, 0x88, 0xfc,
|
||||
0xb6, 0xb3, 0x11, 0x1c, 0x20, 0x48, 0x74, 0xf9, 0x75, 0x07, 0x5e, 0xc5, 0x11, 0xcd, 0xe4, 0x50,
|
||||
0xac, 0x77, 0xfc, 0x58, 0xdc, 0x5c, 0x34, 0x3b, 0x47, 0x24, 0x7d, 0xc8, 0xf8, 0x16, 0x1e, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x51, 0x97, 0x93, 0x79, 0xff, 0xd6, 0xd5,
|
||||
0xb8, 0x51, 0x12, 0x33, 0x43, 0x12, 0x55, 0x5a, 0x8f, 0x0c, 0xf4, 0x48, 0xf4, 0x3f, 0x62, 0x9d,
|
||||
0x9b, 0xa7, 0xfd, 0x6a, 0xe7, 0x60, 0xa6, 0xf6, 0x23, 0xe5, 0xcd, 0x1d, 0xe0, 0xa8, 0x7a, 0x5e,
|
||||
0xb3, 0xcb, 0xb3, 0x4c, 0xc1, 0xc7, 0x01, 0x5a, 0x17, 0xea, 0xf4, 0x68, 0x1f, 0xf9, 0x38, 0x79,
|
||||
0xea, 0x01, 0x02, 0xc0, 0xb6, 0xb8, 0xef, 0x04, 0x19, 0x51, 0xfb, 0x6b, 0xf5, 0x55, 0xef, 0x33,
|
||||
0x5c, 0x5f, 0xe4, 0x3a, 0x2c, 0x22, 0xea, 0x79, 0xc6, 0x2a, 0xb2, 0xf6, 0x5f, 0x49, 0xfe, 0xfa,
|
||||
0xfd, 0xf3, 0x67, 0xc0, 0xda, 0xed, 0x3f, 0xda, 0x5c, 0x98, 0x54, 0x5e, 0x33, 0x01, 0x25, 0xd7,
|
||||
0xaf, 0x95, 0x87, 0x75, 0x1c, 0xb0, 0xa6, 0x1f, 0xd6, 0xf2, 0x59, 0xf5, 0x20, 0xd9, 0xce, 0xa7,
|
||||
0xd1, 0x57, 0xcb, 0x38, 0xfe, 0xb7, 0x17, 0x58, 0x53, 0x60, 0xb0, 0xa7, 0x73, 0x4f, 0x47, 0x21,
|
||||
0x89, 0xe6, 0x4a, 0xf2, 0xda, 0xbc, 0x8e, 0x24, 0x87, 0xf0, 0xee, 0xbf, 0x55, 0x81, 0xc6, 0x59,
|
||||
0x23, 0x9b, 0xc8, 0xbe, 0x66, 0xca, 0xaf, 0x6a, 0xed, 0xa0, 0x55, 0x3e, 0xab, 0x6d, 0x44, 0x47,
|
||||
0x78, 0xbd, 0x01, 0x16, 0x39, 0x40, 0x80, 0x0d, 0x22, 0x5e, 0x28, 0x73, 0x66, 0x1b, 0xfc, 0xe8,
|
||||
0x47, 0x08, 0x0f, 0xc3, 0x6a, 0x6d, 0x63, 0xa6, 0x8f, 0xfa, 0xdc, 0x9d, 0xe0, 0x98, 0x90, 0xcf,
|
||||
0x20, 0x7f, 0x66, 0x74, 0x14, 0x38, 0x41, 0xe8, 0x7d, 0xdc, 0xf9, 0x81, 0x13, 0x44, 0xbe, 0x47,
|
||||
0xfe, 0xb2, 0x56, 0xf8, 0x8e, 0x6f, 0xe4, 0x46, 0x5d, 0x3f, 0x39, 0x40, 0xec, 0x6f, 0xb5, 0xb1,
|
||||
0xca, 0xa6, 0x2b, 0x72, 0x80, 0x00, 0xb0, 0xef, 0xd3, 0x83, 0x26, 0xac, 0x8c, 0xd8, 0x4a, 0xd6,
|
||||
0xda, 0xf6, 0xc8, 0x8f, 0x3f, 0x5b, 0xf7, 0x1f, 0xd6, 0x89, 0x6a, 0x6a, 0xfd, 0xa8, 0xed, 0x64,
|
||||
0xc8, 0x32, 0x7f, 0x76, 0x9b, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0,
|
||||
0x26, 0x26, 0xe5, 0x68, 0x34, 0xc7, 0xb5, 0x92, 0xa5, 0x1c, 0x57, 0xed, 0x9c, 0xcd, 0x03, 0xbf,
|
||||
0x69, 0x3d, 0xb8, 0xd2, 0xf8, 0xce, 0x78, 0xfd, 0x52, 0xfb, 0xf1, 0x2c, 0x07, 0x55, 0xda, 0x36,
|
||||
0x97, 0xb1, 0x1c, 0x9c, 0x45, 0x3d, 0x4f, 0x29, 0x7c, 0x17, 0xd8, 0xfa, 0x8e, 0x22, 0xdc, 0x4b,
|
||||
0xac, 0x91, 0xb7, 0xd8, 0xcb, 0x3c, 0xba, 0xfd, 0x5a, 0xbb, 0x91, 0xd7, 0x5f, 0x73, 0xca, 0xbc,
|
||||
0x31, 0xcc, 0x37, 0x7f, 0xac, 0x60, 0x1d, 0x20, 0x00, 0x6c, 0x0b, 0x11, 0x20, 0x10, 0x61, 0xc0,
|
||||
0xb6, 0x3a, 0xb9, 0x46, 0x87, 0x98, 0xde, 0x64, 0xfb, 0x36, 0xc7, 0x4c, 0x45, 0x4d, 0x33, 0x8c,
|
||||
0x9f, 0x34, 0x1f, 0xa8, 0xa9, 0xe7, 0x88, 0x03, 0x8a, 0xaf, 0x87, 0x19, 0xb5, 0x90, 0xf9, 0x8a,
|
||||
0x7e, 0x06, 0x8f, 0xca, 0x21, 0xd4, 0x72, 0x51, 0xdc, 0x8d, 0x73, 0xeb, 0xef, 0x7d, 0x5c, 0x6f,
|
||||
0xc1, 0x4d, 0xf4, 0x5f, 0x9e, 0xd3, 0x11, 0xf5, 0x30, 0x23, 0xf3, 0xad, 0xe4, 0x00, 0x61, 0xe9,
|
||||
0x48, 0x1f, 0xa0, 0xcb, 0x01, 0x8e, 0x30, 0x2c, 0xeb, 0x73, 0xb6, 0xde, 0x4d, 0x22, 0xfa, 0x8a,
|
||||
0xfc, 0x7a, 0x25, 0xe1, 0x7b, 0xfa, 0x94, 0x69, 0xfc, 0x24, 0x25, 0xc2, 0xa2, 0x4b, 0xc1, 0x79,
|
||||
0xeb, 0xff, 0xf4, 0xea, 0x04, 0x4e, 0x10, 0x79, 0x9c, 0x20, 0xe3, 0x9f, 0xcd, 0x09, 0x5e, 0xd9,
|
||||
0x8c, 0x2b, 0x7b, 0x5e, 0x86, 0xf5, 0x61, 0xe8, 0xc4, 0x9a, 0xe7, 0x4b, 0x84, 0x19, 0xaf, 0xd3,
|
||||
0xb3, 0x5f, 0xd6, 0x6d, 0xb1, 0x0c, 0x06, 0xdc, 0x26, 0x39, 0xa3, 0x20, 0x77, 0x82, 0xdc, 0x78,
|
||||
0x17, 0x8e, 0x00, 0xa3, 0x97, 0x31, 0x94, 0x8c, 0x4f, 0xfb, 0xf5, 0xae, 0xe8, 0xc9, 0xe3, 0xd9,
|
||||
0x7f, 0x49, 0xfb, 0x96, 0x7d, 0x58, 0xc5, 0x7e, 0x5a, 0xae, 0xa3, 0x26, 0x17, 0xad, 0x7f, 0xab,
|
||||
0xf1, 0xe7, 0x25, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0xf0, 0x0f,
|
||||
0xab, 0xb9, 0x5f, 0xb5, 0x2f, 0x5e, 0xd2, 0x50, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
|
||||
0xae, 0x42, 0x60, 0x82
|
||||
};
|
||||
const int font_size = sizeof(font);
|
14
examples/3D_Light1/source/gfx/font.h
Normal file
14
examples/3D_Light1/source/gfx/font.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
This file was autogenerated by raw2c.
|
||||
Visit http://www.devkitpro.org
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
#ifndef _font_h_
|
||||
#define _font_h_
|
||||
//---------------------------------------------------------------------------------
|
||||
extern const unsigned char font[];
|
||||
extern const int font_size;
|
||||
//---------------------------------------------------------------------------------
|
||||
#endif //_font_h_
|
||||
//---------------------------------------------------------------------------------
|
BIN
examples/3D_Light1/source/gfx/font.png
Normal file
BIN
examples/3D_Light1/source/gfx/font.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 932 B |
89
examples/3D_Light1/source/main.c
Normal file
89
examples/3D_Light1/source/main.c
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*===========================================
|
||||
NoNameNo
|
||||
Simple Diffuse light sample code
|
||||
============================================*/
|
||||
#include <grrlib.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <malloc.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
|
||||
#include "gfx/font.h"
|
||||
|
||||
extern Mtx _GRR_view;
|
||||
|
||||
int main() {
|
||||
float l1=0,l2=0;
|
||||
float a=0;
|
||||
int camZ=13.0f;
|
||||
|
||||
GRRLIB_Init();
|
||||
WPAD_Init();
|
||||
|
||||
|
||||
GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font);
|
||||
GRRLIB_InitTileSet(tex_font, 16, 16, 32);
|
||||
|
||||
|
||||
GRRLIB_Settings.antialias = true;
|
||||
|
||||
GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);
|
||||
|
||||
while(1) {
|
||||
GRRLIB_2dMode();
|
||||
WPAD_ScanPads();
|
||||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS) camZ++;
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS) camZ--;
|
||||
|
||||
GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);
|
||||
GRRLIB_SetLightAmbiant(0x333333FF);
|
||||
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A){
|
||||
GRRLIB_SetLightOff();
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
GRRLIB_ObjectView(sin(l1)*4.0f,0.0f,cos(l1)*4.0f, 0,0,0,1,1,1);
|
||||
GRRLIB_DrawSphere(0.2f,20,20,true,0xFF0000FF);
|
||||
}
|
||||
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B){
|
||||
GRRLIB_SetLightOff();
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
GRRLIB_ObjectView(0.0f,sin(l2)*4.0f,cos(l2)*4.0f, 0,0,0,1,1,1);
|
||||
GRRLIB_DrawSphere(0.2f,20,20,true,0x00FF00FF);
|
||||
}
|
||||
|
||||
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A){
|
||||
GRRLIB_SetLightDiff(0,(guVector){sin(l1)*4,0.0f,cos(l1)*4.0f},20.0f,1.0f,0xFF0000FF);
|
||||
}
|
||||
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B){
|
||||
GRRLIB_SetLightDiff(1,(guVector){0.0f,sin(l2)*4.0f,cos(l2)*4.0f},20.0f,1.0f,0x00FF00FF);
|
||||
}
|
||||
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
|
||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3,1,1,1);
|
||||
GRRLIB_DrawTorus(1,2,60,60,true,0xFFFFFFFF);
|
||||
|
||||
|
||||
a+=0.5f;
|
||||
|
||||
l1+=0.05f;
|
||||
l2+=0.03f;
|
||||
// Switch To 2D Mode to display text
|
||||
GRRLIB_2dMode();
|
||||
GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS A OR B TO ZOOM THE CUBE");
|
||||
GRRLIB_Printf((640-(16*29))/2, 40, tex_font, 0xFFFFFFFF, 1, "HOLD A - RED / B - GREEN");
|
||||
|
||||
GRRLIB_Render();
|
||||
}
|
||||
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
|
||||
GRRLIB_FreeTexture(tex_font);
|
||||
|
||||
exit(0);
|
||||
}
|
|
@ -34,7 +34,7 @@ int main() {
|
|||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++;
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--;
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,1,0,0);
|
||||
GRRLIB_3dMode(0.1,1000,45,0,0);
|
||||
GRRLIB_ObjectView(0,0,cubeZ, a,a*2,a*3,1,1,1);
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
|
|
|
@ -38,62 +38,86 @@ int main() {
|
|||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++;
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--;
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1,0);
|
||||
GRRLIB_3dMode(0.1,1000,45,1,0);
|
||||
GRRLIB_SetTexture(tex_girl,0);
|
||||
GRRLIB_ObjectView(0,0,cubeZ, a,a*2,a*3,1,1,1);
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
GX_End();
|
||||
a+=0.5f;
|
||||
|
|
|
@ -46,62 +46,86 @@ int main() {
|
|||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++;
|
||||
if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--;
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1,0);
|
||||
GRRLIB_3dMode(0.1,1000,45,1,0);
|
||||
GRRLIB_SetTexture(tex_girl,0);
|
||||
GRRLIB_ObjectView(0,0,cubeZ, a,a*2,a*3,1,1,1);
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
GX_End();
|
||||
GRRLIB_Screen2Texture(0,0,tex_screen,1);
|
||||
|
|
|
@ -32,7 +32,7 @@ int main() {
|
|||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
|
||||
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,1,0,0);
|
||||
GRRLIB_3dMode(0.1,1000,45,0,0);
|
||||
GRRLIB_ObjectView(0,0,-30, a,a*2,a*3,1,1,1);
|
||||
GX_Begin(GX_TRIANGLES, GX_VTXFMT0, logoNbFace * 3);
|
||||
for(i=0; i<logoNbFace*3; i+=3) {
|
||||
|
|
|
@ -50,7 +50,7 @@ GXTexObj texObj;
|
|||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_PLUS) if(demo<5) demo++;
|
||||
if(WPAD_ButtonsDown(0) & WPAD_BUTTON_MINUS) if(demo>0) demo--;
|
||||
|
||||
GRRLIB_3dMode(0.1,1000,45,0,0,1);
|
||||
GRRLIB_3dMode(0.1,1000,45,0,1);
|
||||
|
||||
if(demo==0){
|
||||
/////////////////// DEFINE A DIFUSE LIGHT /////////////////////////////////////////////
|
||||
|
@ -70,7 +70,7 @@ GXTexObj texObj;
|
|||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true,0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
//////////////////////////// Turn light off and Write demo name
|
||||
|
@ -107,7 +107,7 @@ GXTexObj texObj;
|
|||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor) { 0x33, 0x33, 0x33, 0xFF});
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor) { 0xFF, 0xFF, 0xFF, 0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
//////////////////////////// Turn light off and Write demo name
|
||||
|
@ -147,7 +147,7 @@ GXTexObj texObj;
|
|||
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00});
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
//////////////////////////// Turn light off and Write demo name
|
||||
|
@ -187,7 +187,7 @@ GXTexObj texObj;
|
|||
GX_SetChanMatColor(GX_COLOR0, (GXColor) { 0x00, 0x00, 0x00, 0xFF});
|
||||
GX_SetChanAmbColor(GX_COLOR1, (GXColor){0x00,0x00,0x00,0x00});
|
||||
GX_SetChanMatColor(GX_COLOR1, (GXColor){0xFF,0xFF,0xFF,0xFF});
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
//////////////////////////// Turn light off and Write demo name
|
||||
|
@ -213,7 +213,7 @@ GXTexObj texObj;
|
|||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||
|
||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
GRRLIB_2dMode();
|
||||
|
@ -241,7 +241,7 @@ GXTexObj texObj;
|
|||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||
|
||||
GRRLIB_ObjectView(0,0,0, a,a*2,a*3, 1.0f,1.0f,1.0f);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true);
|
||||
GRRLIB_DrawTorus(0.6f, 2.0f, 60, 60,true, 0xFFFFFFFF);
|
||||
a+=0.8f;
|
||||
|
||||
GRRLIB_2dMode();
|
||||
|
|
|
@ -75,7 +75,7 @@ int main() {
|
|||
GRRLIB_2dMode();
|
||||
GRRLIB_DrawImg(0, 0, tex_screen[screen_index], 0, 1, 1, 0xFFFFFFFF);
|
||||
|
||||
GRRLIB_3dMode(0.1, 1000, 45, 0,1,0);
|
||||
GRRLIB_3dMode(0.1, 1000, 45, 1, 0);
|
||||
GRRLIB_SetBlend(GRRLIB_BLEND_ALPHA);
|
||||
|
||||
|
||||
|
@ -84,57 +84,81 @@ int main() {
|
|||
GRRLIB_SetTexture(tex_girl, 0);
|
||||
GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(-1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(-1.0f,1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
|
||||
GX_Position3f32(1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,-1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,0.0f);
|
||||
GX_Position3f32(-1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(1.0f,1.0f);
|
||||
GX_Position3f32(1.0f,-1.0f,1.0f);
|
||||
GX_Color1u32(0xFFFFFFFF);
|
||||
GX_TexCoord2f32(0.0f,1.0f);
|
||||
GX_End();
|
||||
|
||||
|
|
Loading…
Reference in a new issue