diff --git a/examples/3D_Light4/Makefile b/examples/3D_Light4/Makefile new file mode 100644 index 0000000..694bb69 --- /dev/null +++ b/examples/3D_Light4/Makefile @@ -0,0 +1,147 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=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 +DATA := data +INCLUDES := + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- + +CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) +CXXFLAGS = $(CFLAGS) + +LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +# the order can-be/is critical +#--------------------------------------------------------------------------------- +LIBS := -lgrrlib -lfreetype -lpngu -lpng -ljpeg -lz -lfat +LIBS += -lwiiuse +#LIBS += -lmodplay -lasnd +LIBS += -lbte -logc -lm + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := + +#--------------------------------------------------------------------------------- +# 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: + wiiload $(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) + +#--------------------------------------------------------------------------------- +# This rule links in binary data with the .png extension +#--------------------------------------------------------------------------------- +%.png.o : %.png +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + $(bin2o) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/examples/3D_Light4/source/font.c b/examples/3D_Light4/source/font.c new file mode 100644 index 0000000..d1e37af --- /dev/null +++ b/examples/3D_Light4/source/font.c @@ -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, 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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); diff --git a/examples/3D_Light4/source/font.h b/examples/3D_Light4/source/font.h new file mode 100644 index 0000000..b5ca4a6 --- /dev/null +++ b/examples/3D_Light4/source/font.h @@ -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_ +//--------------------------------------------------------------------------------- diff --git a/examples/3D_Light4/source/font.png b/examples/3D_Light4/source/font.png new file mode 100644 index 0000000..ac5131a Binary files /dev/null and b/examples/3D_Light4/source/font.png differ diff --git a/examples/3D_Light4/source/main.c b/examples/3D_Light4/source/main.c new file mode 100644 index 0000000..a3b247d --- /dev/null +++ b/examples/3D_Light4/source/main.c @@ -0,0 +1,54 @@ +/*=========================================== + GRRLIB + Spot Light Sample Code +============================================*/ +#include + +#include +#include + +#include "font.h" + +extern Mtx _GRR_view; + +int main(int argc, char **argv) { + f32 lightx=0.0f; + + GRRLIB_Init(); + + GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font); + GRRLIB_InitTileSet(tex_font, 16, 16, 32); + + WPAD_Init(); + + GRRLIB_SetBackgroundColour(0x40, 0x40, 0x40, 0xFF); + + while(1) { + GRRLIB_2dMode(); + WPAD_ScanPads(); + if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break; + + GRRLIB_Camera3dSettings(0.0f,0.0f,3.0f, 0,1,0, 0,0,0); + + GRRLIB_SetLightAmbient(0x404040FF); + + GRRLIB_SetLightSpot(1, (guVector){ sin(lightx)*2.5f, 0.8f, 0 }, (guVector){ sin(lightx)*2.5f, 0.0f, 0.0f }, -4.0f, 5.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0x0000FFFF); + GRRLIB_SetLightSpot(2, (guVector){ -sin(lightx)*2.5f, 0.8f, 0 }, (guVector){ -sin(lightx)*2.5f, 0.0f, 0.0f }, -4.0f, 5.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0xFF0000FF); + + GRRLIB_3dMode(0.1,1000,45,0,1); + GRRLIB_ObjectView(0,-0.8,0, -90,0,0,1,1,1); + GRRLIB_DrawTessPanel(6.2f,0.17f,3.7f,0.1f,0,0xFFFFFFFF); + + lightx+=0.05f; + + GRRLIB_2dMode(); + GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFFFF, 1, "GRRLIB SPOT LIGHT SAMPLE 1"); + + + GRRLIB_Render(); + } + + GRRLIB_Exit(); + + exit(0); +}