diff --git a/README.md b/README.md index 7f6ee54..721f2eb 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,33 @@ ImGui for Nintendo 3ds... # Example ## Building -``` +```powershell git submodule update --init --recursive cd example make ``` +# Portlib +## Building +```powershell +git submodule update --init --recursive +cd portlib +make +``` +## Installing +Copy the generated `include/` and `lib/` folders `portlib/` to the 3ds portlibs folder of your DEVKITPRO instalation +```shell +${DEVKITPRO}\portlibs\3ds +``` +Then, in your project's Makefile, add `-limgui-impl-ctr` and its dependencies to your `LIBS` option. +```makefile +LIBS := -limgui-impl-ctr -lstdc++ -lcitro3d -lctru -lm +``` ## Info The example is based on imgui v1.87 but you can use any other version ass well by just teting if it works... # TODO - [ ] Support ttf fonts/build font atlas # Credits +- [Mathaeuz](https://github.com/Mathaeuz) : portlib fork - [Tobi-D7](https://github.com/Tobi-D7) : make the code more imgui_impl like - [mtheall](https://github.com/mtheall) : ftpd's imgui code - [devkitpro](https://github.com/devkitPro) : libctru, citro3d \ No newline at end of file diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..de43ed5 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,5 @@ +/build +/imgui/* +*.3dsx +*.elf +*.smdh \ No newline at end of file diff --git a/portlib/.gitignore b/portlib/.gitignore new file mode 100644 index 0000000..af4af22 --- /dev/null +++ b/portlib/.gitignore @@ -0,0 +1,3 @@ +/lib +/include +/build \ No newline at end of file diff --git a/portlib/Makefile b/portlib/Makefile new file mode 100644 index 0000000..6dcf99d --- /dev/null +++ b/portlib/Makefile @@ -0,0 +1,148 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITARM)),) +$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") +endif + +include $(DEVKITARM)/3ds_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 +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#--------------------------------------------------------------------------------- +TARGET := $(shell basename $(dir $(CURDIR))) +BUILD := build +SOURCES := ../impl ../example/imgui +DATA := data +INCLUDES := ../impl ../example/imgui + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft + +CFLAGS := -g -Wall -O2 -mword-relocations \ + -ffunction-sections \ + $(ARCH) + +CFLAGS += $(INCLUDE) -D__3DS__ -DIMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions + +ASFLAGS := -g $(ARCH) + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(CTRULIB) + +#--------------------------------------------------------------------------------- +# 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)/lib/lib$(TARGET).a + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica))) +HFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.h))) +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +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 +#--------------------------------------------------------------------------------- +SHADER_OFILES := $(PICAFILES:.v.pica=.shbin.o) + +SHADER_HFILES := $(PICAFILES:.v.pica=_shbin.h) + +export OFILES := $(addsuffix .o,$(BINFILES)) \ + $(SHADER_OFILES) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +HFILES := $(HFILES) $(SHADER_HFILES) + +.PHONY: $(BUILD) clean all copy-includes + +#--------------------------------------------------------------------------------- +all: $(BUILD) copy-includes + +lib: + @[ -d $@ ] || mkdir -p $@ + +copy-includes: + @mkdir -p include/ + @cp $(foreach dir,$(INCLUDES),$(wildcard $(dir)/*.h)) ./include + +$(BUILD): lib + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) lib + @rm -fr include + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT) : $(OFILES) + +$(SHADER_OFILES) : $(SHADER_HFILES) + +#--------------------------------------------------------------------------------- +%.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +.PRECIOUS : %.shbin +#--------------------------------------------------------------------------------- +#--------------------------------------------------------------------------------- +%.shbin.o %_shbin.h : %.shbin +#--------------------------------------------------------------------------------- + $(SILENTMSG) $(notdir $<) + $(bin2o) + +-include $(DEPSDIR)/*.d + +#--------------------------------------------------------------------------------------- +endif +#---------------------------------------------------------------------------------------