From 44b3014bce798789e795242d1556cb7449e6386a Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Wed, 13 Jul 2011 00:15:39 -0600 Subject: [PATCH] pch support --- Makefile | 222 +++++++++++++++++++++------------ build/arch/gentoo/yoink.ebuild | 4 +- options.lua | 13 ++ src/Animation.hh | 10 +- src/GameState.hh | 10 +- src/Hud.cc | 2 +- src/Hud.hh | 11 +- src/TilemapFont.hh | 7 +- src/moof/aabb.cc | 3 + src/moof/aabb.hh | 12 +- src/moof/application.cc | 6 +- src/moof/application.hh | 13 +- src/moof/backend.cc | 2 +- src/moof/backend.hh | 1 - src/moof/camera.hh | 10 +- src/moof/contact.hh | 6 +- src/moof/cullable.hh | 1 - src/moof/debug.hh | 10 +- src/moof/dispatcher.hh | 10 +- src/moof/drawable.hh | 6 +- src/moof/entity.hh | 10 +- src/moof/event.hh | 6 +- src/moof/frustum.hh | 9 +- src/moof/hash.hh | 10 +- src/moof/image.cc | 95 ++++++++++---- src/moof/image.hh | 10 +- src/moof/interpolator.hh | 6 +- src/moof/line.hh | 10 +- src/moof/log.hh | 10 +- src/moof/manager.hh | 13 +- src/moof/math.hh | 21 ++-- src/moof/mesh.hh | 10 +- src/moof/modal_dialog.hh | 12 +- src/moof/network.hh | 8 +- src/moof/opengl.hh | 12 +- src/moof/packet.cc | 9 +- src/moof/packet.hh | 12 +- src/moof/plane.hh | 8 +- src/moof/precompile.hh | 59 +++++++++ src/moof/ray.hh | 12 +- src/moof/resource.cc | 10 +- src/moof/resource.hh | 10 +- src/moof/rigid_body.hh | 10 +- src/moof/rules.mk | 13 +- src/moof/runloop.hh | 10 +- src/moof/script.hh | 20 +-- src/moof/service.hh | 10 +- src/moof/settings.hh | 10 +- src/moof/shape.hh | 11 +- src/moof/socket.hh | 11 +- src/moof/sound.cc | 5 +- src/moof/sound.hh | 10 +- src/moof/sphere.hh | 12 +- src/moof/sprite.cc | 1 + src/moof/sprite.hh | 10 +- src/moof/string.cc | 2 +- src/moof/string.hh | 10 +- src/moof/thread.hh | 10 +- src/moof/timer.hh | 10 +- src/moof/video.hh | 10 +- src/rules.mk | 13 +- src/stlplus/rules.mk | 2 +- src/yoink.hh | 15 ++- 63 files changed, 568 insertions(+), 358 deletions(-) create mode 100644 src/moof/precompile.hh diff --git a/Makefile b/Makefile index a0c754b..dfdfaeb 100644 --- a/Makefile +++ b/Makefile @@ -4,39 +4,57 @@ # Use this file with GNU make to compile and install Yoink. # -# Set V to `1' to echo each build command in full. The default behavior -# will keep output minimal. +# Set V to `1' to echo each build command in full. The default behavior will +# keep output minimal so that warnings are clearly visible. V = 0 SHELL = /bin/sh ifeq (menuconfig,$(MAKECMDGOALS)) +# If all we want is to bring up the configure script, then we really don't +# need to define any other functions or recipes process anything else. menuconfig: ./configure --interactive .PHONY: menuconfig else +# Recipe to create `config.h' which is included by some source files. config.h: config.mk $(Q)$(configure) --export-header=$@ +# Recipe to create `config.sed' which is used by some recipes to search and +# replace certain terms in some files, usually with a `.in' suffix. config.sed: config.mk $(Q)$(configure) --export-terms=$@ +# Recipe to create `config.mk' which is the makefile with important configure +# options set. config.mk: $(Q)$(configure) --interactive --print-instructions=no + +# Include the configure makefile; fail if it doesn't exist. include config.mk -# -# Define some useful functions. -# +# This simple variable will be appended with targets which must be built +# before the `install-data' target. +data_targets := -DATA_TARGETS := -EXEC_TARGETS := -SUBDIRS := +# This simple variable will be appended with targets which must be built +# before the `install-exec' target. +exec_targets := +# This simple variable will be appended with subdirectories which contain +# rules as well as their corresponding subdirectories under the build +# directory, any directory which might have files to be installed. +subdirs := + +# Function to include rules from subdirectories. This is the core of the +# non-recursive make method this build system uses. It works by managing +# several stacks and helping to append the appropriate values to the simple +# variables defined above. define include_func = ifeq (,$$d) dir := $1 @@ -51,14 +69,14 @@ d := $$(dir) data := exec := include $$(dir)/rules.mk -SUBDIRS += $$d $$b -data := $$(sort $$(data) $$(appdir_$$b) $$(mandir_$$b) $$(pkgdatadir_$$b) $$(desktop_$$b)) +subdirs += $$d $$b +data := $$(sort $$(data) $$(mandir_$$b) $$(datadir_$$b) $$(pkgdatadir_$$b) $$(desktop_$$b)) exec := $$(sort $$(exec) $$(bindir_$$b) $$(libdir_$$b)) -deps := $$(filter %.d,$$(exec:%.o=%.d)) +deps := $$(filter %.d,$$(call depfile,$$(exec))) clean := $$(clean) $$(deps) $$(exec) $$(data) DEPFILE := $$(DEPFILE) $$(deps) -DATA_TARGETS += $$(data) -EXEC_TARGETS += $$(exec) +data_targets += $$(data) +exec_targets += $$(exec) d := $$(dirstack_$$(sp)) data := $$(datstack_$$(sp)) exec := $$(exestack_$$(sp)) @@ -66,11 +84,16 @@ sp := $$(basename $$(sp)) endef include = $(foreach i,$1,$(eval $(call include_func,$i))) -targets = $(EXEC_TARGETS) $(DATA_TARGETS) +# These shortcut variables are meant to be used to simplify included rules. builddir = build/obj b = $(builddir)/$(d) this = $(d)/rules.mk +# Function to convert object file paths to dependency file paths. This also +# supports pre-compiled header files. +depfile = $(patsubst %.h.gch,%.d,$(patsubst %.hh.gch,%.d,$(1:%.o=%.d))) + +# Determine the suffix that installed manual pages should have. ifeq (gzip,$(manCompression)) MANEXT=.gz else @@ -79,42 +102,64 @@ MANEXT=.bz2 endif endif - -# -# Include the subdirectories--order is not important. -# - +# Now do the actual inclusion of the rules from these subdirectories. $(call include,src data doc) --include build/arch/$(platform)/rules.mk - -# -# Define some common rules. -# +# Also include platform-specific rules, if they exist. +-include build/arch/$(platform)/rules.mk +# Handle automatic tracking of dependencies, if enabled. This adds overhead +# and should be disabled if not needed. ifeq (true,$(tracking)) -PKG_CFLAGS += -MD -MP -MF $(@:%.o=%.d) -MT $@ +PKG_CFLAGS += -MT $@ -MMD -MP -MF $(call depfile,$@) -include $(DEPFILE) endif +# Handle the inclusion of a PCH file, if enabled. Using a PCH file can +# improve build times in some (but not all) cases. The rules should also +# define the `pchfile' variable to the path of the PCH file. Only one PCH +# file can be used. If the PCH file has a `.h' suffix, it is included only +# when compiling C sources, otherwise it will be included only when compiling +# C++ sources. +ifeq (true,$(pch)) +ifneq (,$(pchfile)) +PCH_FLAGS = -Winvalid-pch -include $(pchfile) +endif +endif + # Include current directory to allow sources to include config.h. override CPPFLAGS += -I. -DHAVE_CONFIG_H=1 + +# The target C++ flags should mirror the target C flags by default. TGT_CXXFLAGS = $(TGT_CFLAGS) + +# Define the default flags passed to the library archiver. ARFLAGS = rc + +# Define the default install program. INSTALL = install +# Define the `tarname' to be used as a base filename for distributable +# archives. tarname = $(TARNAME)-$(VERSION) -cmd_compile_c = $(CC) $(PKG_CFLAGS) $(TGT_CFLAGS) $(CFLAGS) $(CPPFLAGS) \ +# Define the commands needed to make several different types of files. Don't +# used these commands directly because they don't account for verbosity; +# instead use the commands without the `cmd_' prefix (defined below). +cmd_compile_c = $(CC) $(PKG_CFLAGS) $(TGT_CFLAGS) $(PCH_CFLAGS) $(CFLAGS) $(MYCFLAGS) $(CPPFLAGS) \ $(TARGET_ARCH) -c $(OUTPUT_OPTION) $< -cmd_compile_cc = $(CXX) $(PKG_CXXFLAGS) $(TGT_CXXFLAGS) $(CXXFLAGS) $(CPPFLAGS) \ +cmd_compile_cc = $(CXX) $(PKG_CXXFLAGS) $(TGT_CXXFLAGS) $(PCH_CXXFLAGS) $(CXXFLAGS) $(MYCXXFLAGS) $(CPPFLAGS) \ $(TARGET_ARCH) -c $(OUTPUT_OPTION) $< -cmd_link_c = $(CC) $(PKG_CFLAGS) $(TGT_CFLAGS) $(CFLAGS) $(CPPFLAGS) \ - $(PKG_LDFLAGS) $(TGT_LDFLAGS) $(LDFLAGS) \ +cmd_link_c = $(CC) $(PKG_CFLAGS) $(TGT_CFLAGS) $(PCH_CFLAGS) $(CFLAGS) $(MYCFLAGS) $(CPPFLAGS) \ + $(PKG_LDFLAGS) $(TGT_LDFLAGS) $(LDFLAGS) $(MYLDFLAGS) \ $(TARGET_ARCH) $^ $(LOADLIBES) $(PKG_LDLIBS) $(TGT_LDLIBS) $(LDLIBS) -o $@ -cmd_link_cc = $(CXX) $(PKG_CXXFLAGS) $(TGT_CXXFLAGS) $(CXXFLAGS) $(CPPFLAGS) \ - $(PKG_LDFLAGS) $(TGT_LDFLAGS) $(LDFLAGS) \ +cmd_link_cc = $(CXX) $(PKG_CXXFLAGS) $(TGT_CXXFLAGS) $(PCH_CXXFLAGS) $(CXXFLAGS) $(MYCXXFLAGS) $(CPPFLAGS) \ + $(PKG_LDFLAGS) $(TGT_LDFLAGS) $(LDFLAGS) $(MYLDFLAGS) \ $(TARGET_ARCH) $^ $(LOADLIBES) $(PKG_LDLIBS) $(TGT_LDLIBS) $(LDLIBS) -o $@ +cmd_compile_pch = $(CC) $(PKG_CFLAGS) $(TGT_CFLAGS) $(CFLAGS) $(MYCFLAGS) $(CPPFLAGS) \ + $(TARGET_ARCH) -c $(OUTPUT_OPTION) $< +cmd_compile_pchh = $(CXX) $(PKG_CXXFLAGS) $(TGT_CXXFLAGS) $(CXXFLAGS) $(MYCXXFLAGS) $(CPPFLAGS) \ + $(TARGET_ARCH) -c $(OUTPUT_OPTION) $< cmd_ar = $(AR) $(ARFLAGS) $@ $^; $(RANLIB) $@ cmd_compile_rc = $(WINDRES) $(CPPFLAGS) $(TARGET_ARCH) $(OUTPUT_OPTION) -i $< cmd_sed = sed -f config.sed <$< >$@ @@ -126,26 +171,40 @@ cmd_xxd = id=$(subst .,_,$(notdir $<)); \ xxd -i <$< >>$@; \ printf ", 0x00\n};\n" >>$@ cmd_configure = ./configure -func_install = mkdir -p $(DESTDIR)$3 && $(INSTALL) -m $1 $2 $(DESTDIR)$3 + +# Define some useful functions. Don't use these functions directly because +# they don't account for verbosity; instead use the functions without the +# `func_' prefix (defined below). func_remove = rm -f $1 +func_install = mkdir -p $(DESTDIR)$3 && $(INSTALL) -m $1 $2 $(DESTDIR)$3 func_dist = git archive HEAD --prefix='$(tarname)/' | $1 >"$(tarname).tar.$2" && \ - (md5 "$(tarname).tar.$2" 2>/dev/null || md5sum "$(tarname).tar.$2") - -compile_c = $(call func_print,CC,$@) $(cmd_compile_c) -compile_cc = $(call func_print,CXX,$@) $(cmd_compile_cc) -compile_rc = $(call func_print,RC,$@) $(cmd_compile_rc) -link_c = $(call func_print,LINK,$@) $(cmd_link_c) -link_cc = $(call func_print,LINK,$@) $(cmd_link_cc) -ar = $(call func_print,AR,$@) $(cmd_ar) -sed = $(call func_print,SED,$@) $(cmd_sed) -gzip = $(call func_print,GZIP,$@) $(cmd_gzip) -bzip2 = $(call func_print,BZIP2,$@) $(cmd_bzip2) -xxd = $(call func_print,XXD,$@) $(cmd_xxd) -configure = $(call func_print,MAKE,$@) $(cmd_configure) -dist = $(call func_print,DIST,$1) $(func_dist) + (openssl md5 "$(tarname).tar.$2" 2>/dev/null || \ + md5 "$(tarname).tar.$2" 2>/dev/null || \ + md5sum "$(tarname).tar.$2" 2>/dev/null) + +# These commands and functions should be used in most recipes to compile +# sources, link objects, compress files, create distfiles, install files, etc. +compile_c = $(call func_print,CC,$@) $(cmd_compile_c) +compile_cc = $(call func_print,CXX,$@) $(cmd_compile_cc) +compile_rc = $(call func_print,RC,$@) $(cmd_compile_rc) +link_c = $(call func_print,LINK,$@) $(cmd_link_c) +link_cc = $(call func_print,LINK,$@) $(cmd_link_cc) +compile_pch = $(call func_print,CC,$@) $(cmd_compile_pch) +compile_pchh = $(call func_print,CXX,$@) $(cmd_compile_pchh) +ar = $(call func_print,AR,$@) $(cmd_ar) +sed = $(call func_print,SED,$@) $(cmd_sed) +gzip = $(call func_print,GZIP,$@) $(cmd_gzip) +bzip2 = $(call func_print,BZIP2,$@) $(cmd_bzip2) +xxd = $(call func_print,XXD,$@) $(cmd_xxd) +configure = $(call func_print,MAKE,$@) $(cmd_configure) +dist = $(call func_print,DIST,$1) $(func_dist) +remove = $(call func_print,RM,$1) $(func_remove) install = $(call func_print,CP,$(DESTDIR:%/=%)$(3:%/=%)/$(notdir $2)) $(func_install) -remove = $(call func_print,RM,$1) $(func_remove) +# The mechanism used by this makefile to handle verbosity simply requires (by +# convention) commands in rules to be prefixed with `$Q' and the commands and +# functions defined above will then print a single line describing the command +# instead of the entire command. ifeq (1,$V) Q = func_print = @@ -155,16 +214,18 @@ func_print = printf "\x20\x20$1\t%s\n" $2; endif -# -# Define the implicit rules. -# - +# Define the implicit rules. Targets and sources which match do not need to +# be explicitly stated in the rule definitions. +%.o: %.c + $(Q)$(compile_c) +%.h.gch: %.h + $(Q)$(compile_pch) %.o: %.cc $(Q)$(compile_cc) %.o: %.cpp $(Q)$(compile_cc) -%.o: %.c - $(Q)$(compile_c) +%.hh.gch: %.hh + $(Q)$(compile_pchh) %.o: %.rc $(Q)$(compile_rc) %: %.in @@ -174,6 +235,10 @@ endif %.bz2: % $(Q)$(bzip2) +# More explicit rules which allow targets in the build directory to be made +# directly. A special rules is also defined to create directories or copy +# files under the build directory to match the structure of the source +# directory. $(builddir)/%.o: %.cc $(Q)$(compile_cc) $(builddir)/%.o: %.cpp @@ -192,65 +257,66 @@ $(builddir)/%: % $(Q)if [ -d $< ]; then mkdir -p $@; elif [ -f $< ]; then cp -f $< $@; fi -# -# Define the phony targets. -# - +# Define the default target(s). This should `make' just about everything. .DEFAULT_GOAL := -all: $(targets) +all: $(exec_targets) $(data_targets) +# Define the recipe to clean the targets. This will remove the target files +# and the empty directories of the build hierarchy. clean: $(Q)$(foreach f,$(clean),$(call remove,$f);) $(Q)if [ -d $(builddir) ]; then find $(builddir) -type d -empty -delete; fi +# Make the project even cleaner by removing files created by configuration. distclean: clean $(Q)cd build && $(MAKE) clean $(Q)$(call remove,config.h);$(call remove,config.mk);$(call remove,config.sed) - +# Installation happens in two separated phases, installing the executable +# (i.e. platform-specific) files and installing the data files. install: install-data install-exec -install-data: $(DATA_TARGETS) - $(Q)$(foreach d,$(SUBDIRS),$(foreach f,$(pkgdatadir_$d),\ +# Recipe to install the data files. Right now, that includes files destined +# for `pkgdatadir' and `mandir'. +install-data: $(data_targets) + $(Q)$(foreach d,$(subdirs),$(foreach f,$(pkgdatadir_$d),\ $(call install,644,$f,$(dir $(f:$d%=$(pkgdatadir)%)));)) - $(Q)$(foreach d,$(SUBDIRS),$(foreach f,$(mandir_$d),\ + $(Q)$(foreach d,$(subdirs),$(foreach f,$(mandir_$d),\ $(call install,644,$f,\ $(dir $(f:$d%=$(mandir)/man$(shell echo "$f" | sed 's/[^.]*\.\([^.]*\).*/\1/')%)));)) -install-exec: $(EXEC_TARGETS) - $(Q)$(foreach d,$(SUBDIRS),$(foreach f,$(bindir_$d),\ +# Recipe to install executable files. Right now, that includes files destined +# for `bindir'. +install-exec: $(exec_targets) + $(Q)$(foreach d,$(subdirs),$(foreach f,$(bindir_$d),\ $(call install,755,$f,$(dir $(f:$d%=$(bindir)%)));)) -install-desktop-entry: $(DATA_TARGETS) - $(Q)$(foreach d,$(SUBDIRS),$(foreach f,$(desktop_$d),\ +# Recipe to install desktop entry file(s) to /usr/share/applications. +install-desktop-entry: $(data_targets) + $(Q)$(foreach d,$(subdirs),$(foreach f,$(desktop_$d),\ $(call install,644,$f,/usr/share/applications);)) - +# Target used to create distfiles in all the supported compression formats. dist-all: dist-bzip2 dist-gzip dist-lzma dist-xz +# Separate targets to create distfiles in the corresponding formats. dist-bzip2: $(Q)$(call dist,bzip2,bz2) - dist-gzip: $(Q)$(call dist,gzip,gz) - dist-lzma: $(Q)$(call dist,lzma,lzma) - dist-xz: $(Q)$(call dist,xz,xz) +# The `dist' target will create the distfile in whatever format was set in the +# configuration. dist: dist-$(archiveFormat) -# -# Prevent make from removing any build targets. -# - -.SECONDARY: $(clean) - -.PHONY: all clean distclean install install-data install-exec -.PHONY: install-desktop-entry +# Define which targets do not actually correspond to real files. +.PHONY: all clean distclean +.PHONY: install install-data install-exec install-desktop-entry .PHONY: dist dist-all dist-gzip dist-bzip2 dist-xz dist-lzma endif # menuconfig diff --git a/build/arch/gentoo/yoink.ebuild b/build/arch/gentoo/yoink.ebuild index b27524e..b69232c 100644 --- a/build/arch/gentoo/yoink.ebuild +++ b/build/arch/gentoo/yoink.ebuild @@ -29,11 +29,11 @@ DEPEND="${RDEPEND} src_configure() { egamesconf --disable-dependency-tracking \ - --install-icon=no \ - --print-instructions=no \ + --install-icon=no --print-instructions=no \ $(use_enable debug) \ $(use_enable double-precision) \ $(use_enable hotload) \ + $(use_enable pch) \ $(use_enable threads) \ $(use_with gtk) \ $(use_with qt4) diff --git a/options.lua b/options.lua index 4839144..429c5b8 100644 --- a/options.lua +++ b/options.lua @@ -294,6 +294,19 @@ rebuilt when you run make. This may add some overhead to the build process. If in doubt, say Yes. +]] + }, + { + symbol = "pch", + value = false, + cmdline = "--enable-pch", + name = "Use Precompiled Header", + caption = "Enable building and using a precompiled header.", + help = [[ +Recent versions of GCC can use precompiled headers +which may improve compile times. + +If in doubt, say No. ]] }, { diff --git a/src/Animation.hh b/src/Animation.hh index c8cdca8..d49dfb5 100644 --- a/src/Animation.hh +++ b/src/Animation.hh @@ -10,11 +10,6 @@ #ifndef _ANIMATION_HH_ #define _ANIMATION_HH_ -/** - * @file Animation.hh - * Motion picture!! - */ - #include #include @@ -22,6 +17,11 @@ #include +/** + * \file Animation.hh + * Motion picture!! + */ + class Animation; typedef boost::shared_ptr AnimationP; diff --git a/src/GameState.hh b/src/GameState.hh index ecf9e05..76ecc34 100644 --- a/src/GameState.hh +++ b/src/GameState.hh @@ -10,11 +10,6 @@ #ifndef _GAMESTATE_HH_ #define _GAMESTATE_HH_ -/** - * \file GameState.hh - * The data. - */ - #include #include @@ -29,6 +24,11 @@ #include "Scene.hh" +/** + * \file GameState.hh + * The data. + */ + struct GameState { moof::script script; diff --git a/src/Hud.cc b/src/Hud.cc index dde53ee..20d6b4e 100644 --- a/src/Hud.cc +++ b/src/Hud.cc @@ -8,7 +8,7 @@ *****************************************************************************/ #include -#include +#include #include #include diff --git a/src/Hud.hh b/src/Hud.hh index 05882ed..905d6e1 100644 --- a/src/Hud.hh +++ b/src/Hud.hh @@ -10,11 +10,6 @@ #ifndef _HUD_HH_ #define _HUD_HH_ -/** - * @file Hud.hh - * Heads-up Display - */ - #include #include //#include @@ -23,6 +18,12 @@ #include "GameState.hh" +/** + * \file Hud.hh + * Heads-up Display + */ + + // forward declarations class rectangle; diff --git a/src/TilemapFont.hh b/src/TilemapFont.hh index b3759a9..89c7ffe 100644 --- a/src/TilemapFont.hh +++ b/src/TilemapFont.hh @@ -10,13 +10,14 @@ #ifndef _TILEMAPFONT_HH_ #define _TILEMAPFONT_HH_ +#include + + /** - * @file TilemapFont.hh + * \file TilemapFont.hh * Text on the screen. */ -#include - /* class TilemapFont : public moof::texture diff --git a/src/moof/aabb.cc b/src/moof/aabb.cc index f403f7a..61e16ea 100644 --- a/src/moof/aabb.cc +++ b/src/moof/aabb.cc @@ -10,11 +10,14 @@ #include "aabb.hh" #include "script.hh" + namespace moof { + void import_aabb_class(script& script) { } + } // namepsace moof diff --git a/src/moof/aabb.hh b/src/moof/aabb.hh index 3228b5a..8a677f4 100644 --- a/src/moof/aabb.hh +++ b/src/moof/aabb.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_AABB_HH_ #define _MOOF_AABB_HH_ -/** - * \file aabb.hh - * Axis-aligned Bounding Box - */ - #include #include #include @@ -26,6 +21,11 @@ #include +/** + * \file aabb.hh + * Axis-aligned Bounding Box + */ + namespace moof { @@ -256,7 +256,7 @@ inline bool aabb<3>::is_visible(const frustum& frustum) const } typedef aabb<2> aabb2; -typedef aabb2 rectangle; +typedef aabb<2> rectangle; typedef aabb<3> aabb3; diff --git a/src/moof/application.cc b/src/moof/application.cc index e0b73b7..84f1a24 100644 --- a/src/moof/application.cc +++ b/src/moof/application.cc @@ -7,16 +7,14 @@ * *****************************************************************************/ -#include // exit, srand -#include +#include // exit, srand #include -#include "fastevents.h" #include "application.hh" +#include "fastevents.h" #include "log.hh" #include "settings.hh" -#include "timer.hh" #include "video.hh" diff --git a/src/moof/application.hh b/src/moof/application.hh index 5c80867..e961987 100644 --- a/src/moof/application.hh +++ b/src/moof/application.hh @@ -10,19 +10,18 @@ #ifndef _MOOF_APPLICATION_HH_ #define _MOOF_APPLICATION_HH_ -/** - * \file application.hh - * The main loop. - */ - -#include - #include #include #include +#include #include +/** + * \file application.hh + * The main loop. + */ + namespace moof { diff --git a/src/moof/backend.cc b/src/moof/backend.cc index fa3ad31..5b995c5 100644 --- a/src/moof/backend.cc +++ b/src/moof/backend.cc @@ -14,9 +14,9 @@ #include #include -#include "fastevents.h" #include "backend.hh" +#include "fastevents.h" #include "log.hh" diff --git a/src/moof/backend.hh b/src/moof/backend.hh index b25e53a..6711de8 100644 --- a/src/moof/backend.hh +++ b/src/moof/backend.hh @@ -15,7 +15,6 @@ * Initialize the backend libraries and subsystems. */ - namespace moof { diff --git a/src/moof/camera.hh b/src/moof/camera.hh index 43e5471..7484e4e 100644 --- a/src/moof/camera.hh +++ b/src/moof/camera.hh @@ -10,17 +10,17 @@ #ifndef _MOOF_CAMERA_HH_ #define _MOOF_CAMERA_HH_ -/** - * \file camera.hh - * Classes related to managing the modelview and perspective matrices. - */ - #include #include #include #include +/** + * \file camera.hh + * Classes related to managing the modelview and perspective matrices. + */ + namespace moof { diff --git a/src/moof/contact.hh b/src/moof/contact.hh index 1d1998e..42e93bb 100644 --- a/src/moof/contact.hh +++ b/src/moof/contact.hh @@ -10,14 +10,14 @@ #ifndef _MOOF_CONTACT_HH_ #define _MOOF_CONTACT_HH_ +#include + + /** * \file contact.hh * Represents a collision between entities. */ -#include - - namespace moof { diff --git a/src/moof/cullable.hh b/src/moof/cullable.hh index 3f0169a..e3a2bb7 100644 --- a/src/moof/cullable.hh +++ b/src/moof/cullable.hh @@ -15,7 +15,6 @@ * Representation for an object that may or may not be visible. */ - namespace moof { diff --git a/src/moof/debug.hh b/src/moof/debug.hh index baa0304..ef42dff 100644 --- a/src/moof/debug.hh +++ b/src/moof/debug.hh @@ -10,16 +10,16 @@ #ifndef _MOOF_DEBUG_HH_ #define _MOOF_DEBUG_HH_ +#include + +#include + + /** * \file debug.hh * Debugging facilities. */ -#include // exit - -#include - -#include #undef ASSERT diff --git a/src/moof/dispatcher.hh b/src/moof/dispatcher.hh index f2613e8..7a1a081 100644 --- a/src/moof/dispatcher.hh +++ b/src/moof/dispatcher.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_DISPATCH_HH_ #define _MOOF_DISPATCH_HH_ -/** - * \file dispatcher.hh - * Classes that deal with message dispatching. - */ - #include #include @@ -23,6 +18,11 @@ #include +/** + * \file dispatcher.hh + * Classes that deal with message dispatching. + */ + namespace moof { diff --git a/src/moof/drawable.hh b/src/moof/drawable.hh index 2f5c6cd..4caf0ca 100644 --- a/src/moof/drawable.hh +++ b/src/moof/drawable.hh @@ -10,14 +10,14 @@ #ifndef _MOOF_DRAWABLE_HH_ #define _MOOF_DRAWABLE_HH_ +#include + + /** * \file drawable.hh * Representation for an object that can be drawn to the screen. */ -#include - - namespace moof { diff --git a/src/moof/entity.hh b/src/moof/entity.hh index 92b4dc5..c86dc9a 100644 --- a/src/moof/entity.hh +++ b/src/moof/entity.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_ENTITY_HH_ #define _MOOF_ENTITY_HH_ -/** - * \file entity.hh - * Interface class for cullable and drawable objects. - */ - #include #include @@ -23,6 +18,11 @@ #include +/** + * \file entity.hh + * Interface class for cullable and drawable objects. + */ + namespace moof { diff --git a/src/moof/event.hh b/src/moof/event.hh index 8635e5f..7b76873 100644 --- a/src/moof/event.hh +++ b/src/moof/event.hh @@ -10,14 +10,14 @@ #ifndef _MOOF_EVENT_HH_ #define _MOOF_EVENT_HH_ +#include + + /** * \file event.hh * Defines an event object. */ -#include - - namespace moof { diff --git a/src/moof/frustum.hh b/src/moof/frustum.hh index c603a97..8386d70 100644 --- a/src/moof/frustum.hh +++ b/src/moof/frustum.hh @@ -10,16 +10,18 @@ #ifndef _MOOF_FRUSTUM_HH_ #define _MOOF_FRUSTUM_HH_ +#include +#include + + /** * \file frustum.hh * All things related to frustums! */ -#include -#include - namespace moof { + template class aabb; template class sphere; @@ -61,6 +63,7 @@ private: plane planes_[6]; // left, right, bottom, top, near, far }; + } // namespace moof #endif // _MOOF_FRUSTUM_HH_ diff --git a/src/moof/hash.hh b/src/moof/hash.hh index 8b14ac5..810a128 100644 --- a/src/moof/hash.hh +++ b/src/moof/hash.hh @@ -10,16 +10,16 @@ #ifndef _MOOF_HASH_HH_ #define _MOOF_HASH_HH_ -/** - * \file hash.hh - * Hash tables and functions. - */ - #include #include +/** + * \file hash.hh + * Hash tables and functions. + */ + namespace moof { diff --git a/src/moof/image.cc b/src/moof/image.cc index 09f797c..77b15c1 100644 --- a/src/moof/image.cc +++ b/src/moof/image.cc @@ -7,14 +7,16 @@ * *****************************************************************************/ -#include // strncmp #include #include - #include + #include +#include + #include "backend.hh" +#include "debug.hh" #include "image.hh" #include "log.hh" #include "opengl.hh" @@ -25,38 +27,83 @@ namespace moof { +MOOF_REGISTER_RESOURCE(image, bmp, textures); MOOF_REGISTER_RESOURCE(image, png, textures); -//static int power_of_two(int input) -//{ - //int value = 1; - - //while (value < input) - //{ - //value <<= 1; - //} - //return value; -//} - -unsigned image::global_object_ = 0; +static int higher_power_of_two(int input) +{ + int value = 2; + while (value <= input) value <<= 1; + return value; +} -static void read_from_stream(png_structp context, png_bytep data, png_size_t length) +static void read_from_stream(png_structp context, + png_bytep data, png_size_t length) { std::istream& stream(*(std::istream*)png_get_io_ptr(context)); stream.read((char*)data, length); } -image::image(const std::string& path) : - pixels_(0), - object_(0), - min_filter_(GL_NEAREST), - mag_filter_(GL_NEAREST), - tile_s_(1), - tile_t_(1), - wrap_s_(GL_CLAMP), - wrap_t_(GL_CLAMP) +struct texture_attributes +{ + texture_attributes() : + min_filter(GL_NEAREST), + mag_filter(GL_NEAREST), + tile_s(1), + tile_t(1), + wrap_s(GL_CLAMP_TO_EDGE), + wrap_t(GL_CLAMP_TO_EDGE) {} + + void init(const std::string& info) + { + script script; + log::import(script); + + script::slot g = script.globals(); +#define EXPORT_CONSTANT(K) g.set_field(#K, GL_##K) + EXPORT_CONSTANT(CLAMP); + EXPORT_CONSTANT(CLAMP_TO_EDGE); + EXPORT_CONSTANT(REPEAT); + EXPORT_CONSTANT(LINEAR); + EXPORT_CONSTANT(NEAREST); + EXPORT_CONSTANT(LINEAR_MIPMAP_LINEAR); + EXPORT_CONSTANT(LINEAR_MIPMAP_NEAREST); + EXPORT_CONSTANT(NEAREST_MIPMAP_LINEAR); + EXPORT_CONSTANT(NEAREST_MIPMAP_NEAREST); +#undef export_constant + + if (script.do_string(info) != script::success) + { + std::string str; + script[-1].get(str); + log_warning(str); + } + else + { + log_info("loading texture information..."); + + script::slot globals = script.globals(); + globals.get(min_filter, "min_filter"); + globals.get(mag_filter, "mag_filter"); + globals.get(tile_s, "tile_s"); + globals.get(tile_t, "tile_t"); + globals.get(wrap_s, "wrap_s"); + globals.get(wrap_t, "wrap_t"); + } + } + + GLuint min_filter; + GLuint mag_filter; + int tile_s; + int tile_t; + GLuint wrap_s; + GLuint wrap_t; +}; + + +static SDL_Surface* load_png(const std::string& path, texture_attributes& attribs) { std::ifstream file(path.c_str(), std::ifstream::binary); if (!file.good()) diff --git a/src/moof/image.hh b/src/moof/image.hh index 62f8699..4dee19f 100644 --- a/src/moof/image.hh +++ b/src/moof/image.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_IMAGE_HH_ #define _MOOF_IMAGE_HH_ -/** - * \file image.hh - * Defines classes for loading and manipulating images. - */ - #include #include @@ -22,6 +17,11 @@ #include +/** + * \file image.hh + * Defines classes for loading and manipulating images. + */ + namespace moof { diff --git a/src/moof/interpolator.hh b/src/moof/interpolator.hh index 83dd0c9..5078578 100644 --- a/src/moof/interpolator.hh +++ b/src/moof/interpolator.hh @@ -10,14 +10,14 @@ #ifndef _MOOF_INTERPOLATOR_HH_ #define _MOOF_INTERPOLATOR_HH_ +#include + + /** * \file interpolator.hh * Functions and classes concerning interpolations between values. */ -#include - - namespace moof { diff --git a/src/moof/line.hh b/src/moof/line.hh index 8f5794d..60a0b34 100644 --- a/src/moof/line.hh +++ b/src/moof/line.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_LINE_HH_ #define _MOOF_LINE_HH_ -/** - * \file line.hh - * Classes related to line segments. - */ - #include #include #include @@ -26,6 +21,11 @@ #include +/** + * \file line.hh + * Classes related to line segments. + */ + namespace moof { diff --git a/src/moof/log.hh b/src/moof/log.hh index addf37c..1069126 100644 --- a/src/moof/log.hh +++ b/src/moof/log.hh @@ -10,6 +10,11 @@ #ifndef _MOOF_LOG_HH_ #define _MOOF_LOG_HH_ +#include // exit +#include +#include + + /** * \file log.hh * Functions related to logging the process. The logging functions are @@ -17,11 +22,6 @@ * least critical. */ -#include // exit -#include -#include - - namespace moof { diff --git a/src/moof/manager.hh b/src/moof/manager.hh index a3963e8..907815f 100644 --- a/src/moof/manager.hh +++ b/src/moof/manager.hh @@ -10,6 +10,12 @@ #ifndef _MOOF_MANAGER_HH_ #define _MOOF_MANAGER_HH_ +#include +#include + +#include + + /** * \file manager.hh * A manager is a collection of named objects of the same type. Libraries @@ -17,13 +23,6 @@ * have any interested code. */ -#include - -#include - -#include - - namespace moof { diff --git a/src/moof/math.hh b/src/moof/math.hh index e7cd3f0..e72dec0 100644 --- a/src/moof/math.hh +++ b/src/moof/math.hh @@ -10,19 +10,17 @@ #ifndef _MOOF_MATH_HH_ #define _MOOF_MATH_HH_ -/** - * \file math.hh - * General math-related types and functions. - */ +#include + +#include +#include + +#include #if HAVE_CONFIG_H #include "config.h" #endif -#include - -#include -#include #if ENABLE_DOUBLE_PRECISION typedef GLdouble GLscalar; @@ -35,6 +33,11 @@ typedef GLfloat GLscalar; #endif +/** + * \file math.hh + * General math-related types and functions. + */ + namespace moof { @@ -137,7 +140,7 @@ inline void rk4(S& state, scalar t, scalar dt) D b = evaluate(state, t, dt * SCALAR(0.5), a); D c = evaluate(state, t, dt * SCALAR(0.5), b); D d = evaluate(state, t, dt, c); - state.step((a + (b + c) * SCALAR(2.0) + d) * SCALAR(1.0/6.0), dt); + state.step((a + (b + c) * SCALAR(2.0) + d) * (SCALAR(1.0)/SCALAR(6.0)), dt); } diff --git a/src/moof/mesh.hh b/src/moof/mesh.hh index 26accec..3f0dc24 100644 --- a/src/moof/mesh.hh +++ b/src/moof/mesh.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_MESH_HH_ #define _MOOF_MESH_HH_ -/** - * \file mesh.hh - * Defines classes for loading and manipulating meshes. - */ - #include #include #include @@ -29,6 +24,11 @@ #include +/** + * \file mesh.hh + * Defines classes for loading and manipulating meshes. + */ + namespace moof { diff --git a/src/moof/modal_dialog.hh b/src/moof/modal_dialog.hh index 4afeb39..392f3ab 100644 --- a/src/moof/modal_dialog.hh +++ b/src/moof/modal_dialog.hh @@ -10,12 +10,6 @@ #ifndef _MOOF_MODAL_DIALOG_HH_ #define _MOOF_MODAL_DIALOG_HH_ -/** - * \file modal_dialog.hh - * A class for creating and running modal dialogs. Several toolkits are - * supported, but only one can be used as determined at build time. - */ - #if HAVE_CONFIG_H #include "config.h" #endif @@ -36,6 +30,12 @@ #include +/** + * \file modal_dialog.hh + * A class for creating and running modal dialogs. Several toolkits are + * supported, but only one can be used as determined at build time. + */ + namespace moof { diff --git a/src/moof/network.hh b/src/moof/network.hh index 998473b..7a544e6 100644 --- a/src/moof/network.hh +++ b/src/moof/network.hh @@ -10,16 +10,16 @@ #ifndef _MOOF_NETWORK_HH_ #define _MOOF_NETWORK_HH_ +#include +#include + + /** * \file network.hh * Builds a high-level protocol and match-making system on top of network * sockets for multiplayer support. */ -#include -#include - - namespace moof { diff --git a/src/moof/opengl.hh b/src/moof/opengl.hh index 6eeb553..7c80200 100644 --- a/src/moof/opengl.hh +++ b/src/moof/opengl.hh @@ -10,12 +10,6 @@ #ifndef _MOOF_OPENGL_HH_ #define _MOOF_OPENGL_HH_ -/** - * \file opengl.hh - * Defines macros for OpenGL functions that operate on scalars, vectors, and - * matrices. - */ - #if HAVE_CONFIG_H #include "config.h" #endif @@ -27,6 +21,12 @@ #include +/** + * \file opengl.hh + * Defines macros for OpenGL functions that operate on scalars, vectors, and + * matrices. + */ + // generic function arguments #define ARGS_P const GLscalar* p diff --git a/src/moof/packet.cc b/src/moof/packet.cc index 9cfb5bb..782e609 100644 --- a/src/moof/packet.cc +++ b/src/moof/packet.cc @@ -9,20 +9,23 @@ * **************************************************************************/ +#if HAVE_CONFIG_H #include "config.h" +#endif #include +#include + +#include + #if HAVE_BYTESWAP_H #include #endif -#include #if HAVE_ARPA_INET_H #include #endif -#include - #include "packet.hh" diff --git a/src/moof/packet.hh b/src/moof/packet.hh index 55dd96c..c238915 100644 --- a/src/moof/packet.hh +++ b/src/moof/packet.hh @@ -12,22 +12,22 @@ #ifndef _MOOF_PACKET_HH_ #define _MOOF_PACKET_HH_ -/** - * \file packet.hh - * Classes for building and interpreting datagram packets. - */ - #include #include +#include #include #include - #ifndef PAGE_SIZE #define PAGE_SIZE 4096 #endif +/** + * \file packet.hh + * Classes for building and interpreting datagram packets. + */ + namespace moof { diff --git a/src/moof/plane.hh b/src/moof/plane.hh index 83b5517..258feb9 100644 --- a/src/moof/plane.hh +++ b/src/moof/plane.hh @@ -10,15 +10,15 @@ #ifndef _MOOF_PLANE_HH_ #define _MOOF_PLANE_HH_ +#include +#include + + /** * \file plane.hh * Classes and functions related to planes. */ -#include -#include - - namespace moof { diff --git a/src/moof/precompile.hh b/src/moof/precompile.hh new file mode 100644 index 0000000..dafa1d5 --- /dev/null +++ b/src/moof/precompile.hh @@ -0,0 +1,59 @@ + +/*] Copyright (c) 2009-2011, Charles McGarvey [***************************** +**] All rights reserved. +* +* Distributable under the terms and conditions of the 2-clause BSD license; +* see the file COPYING for a complete text of the license. +* +*****************************************************************************/ + +#ifndef _MOOF_PRECOMPILE_HH_ +#define _MOOF_PRECOMPILE_HH_ + +/** + * \file precompile.hh + * PCH includes for quicker compiles. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // _MOOF_PRECOMPILE_HH_ + diff --git a/src/moof/ray.hh b/src/moof/ray.hh index b992903..71d1e7a 100644 --- a/src/moof/ray.hh +++ b/src/moof/ray.hh @@ -10,18 +10,18 @@ #ifndef _MOOF_RAY_HH_ #define _MOOF_RAY_HH_ -/** - * \file ray.hh - * A class for lines that start at one point and go to infinity in some - * direction. - */ - #include #include #include #include +/** + * \file ray.hh + * A class for lines that start at one point and go to infinity in some + * direction. + */ + namespace moof { diff --git a/src/moof/resource.cc b/src/moof/resource.cc index 7a60d0e..8188313 100644 --- a/src/moof/resource.cc +++ b/src/moof/resource.cc @@ -13,16 +13,18 @@ #include +#include +#include + +#include + #if ENABLE_HOTLOADING #include #include #endif -#include -#include -#include - #include "hash.hh" +#include "log.hh" #include "resource.hh" #ifndef BUF_SIZE diff --git a/src/moof/resource.hh b/src/moof/resource.hh index 41dfd61..d4f4162 100644 --- a/src/moof/resource.hh +++ b/src/moof/resource.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_RESOURCE_HH_ #define _MOOF_RESOURCE_HH_ -/** - * \file resource.hh - * Interface for textures, sounds, and other types of resources. - */ - #include #include #include @@ -23,8 +18,11 @@ #include #include -#include +/** + * \file resource.hh + * Interface for textures, sounds, and other types of resources. + */ namespace moof { diff --git a/src/moof/rigid_body.hh b/src/moof/rigid_body.hh index 67e12dd..b8b9048 100644 --- a/src/moof/rigid_body.hh +++ b/src/moof/rigid_body.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_RIGID_BODY_HH_ #define _MOOF_RIGID_BODY_HH_ -/** - * \file rigid_body.hh - * Classes and functions for simulating rigid body physics. - */ - #include #include @@ -24,6 +19,11 @@ #include +/** + * \file rigid_body.hh + * Classes and functions for simulating rigid body physics. + */ + namespace moof { diff --git a/src/moof/rules.mk b/src/moof/rules.mk index 5bae72c..a970bc4 100644 --- a/src/moof/rules.mk +++ b/src/moof/rules.mk @@ -4,12 +4,21 @@ # objects = $(patsubst %.c,$(builddir)/%.o,$(patsubst %.cc,$(builddir)/%.o,$(wildcard $d/*.c $d/*.cc))) -$(objects): TGT_CFLAGS := -I$d -I$d/.. -$(objects): config.h $(this) | $b +$(objects): TGT_CFLAGS := -I$b -I$b/.. -I$d -I$d/.. +$(objects): config.h | $b library = $b/libmoof.a $(library): $(objects) $(Q)$(ar) +ifeq (true,$(pch)) +pchfile := $b/precompile.hh +exec += $(pchfile) $(pchfile).gch +$(pchfile).gch: TGT_CFLAGS := -I$b -I$b/.. -I$d -I$d/.. +$(pchfile).gch: $(pchfile) +$(pchfile): config.mk | $b +$(objects): $(pchfile).gch +endif + exec += $(objects) $(library) diff --git a/src/moof/runloop.hh b/src/moof/runloop.hh index 6d56d83..43d4ea2 100644 --- a/src/moof/runloop.hh +++ b/src/moof/runloop.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_RUNLOOP_HH_ #define _MOOF_RUNLOOP_HH_ -/** - * \file runloop.hh - * Thread timer management class. - */ - #include #include @@ -22,6 +17,11 @@ #include +/** + * \file runloop.hh + * Thread timer management class. + */ + namespace moof { diff --git a/src/moof/script.hh b/src/moof/script.hh index 79412ac..ae582fc 100644 --- a/src/moof/script.hh +++ b/src/moof/script.hh @@ -10,16 +10,6 @@ #ifndef _MOOF_SCRIPT_HH_ #define _MOOF_SCRIPT_HH_ -/** - * \file script.hh - * A thin wrapper over Lua 5.1. This is not meant as a complicated binding - * package between C++ and Lua. It is not meant to obscure the division - * between C++ and Lua but rather to clarify it and make it more manageable. - * It does not hide the concept of the Lua stack, but rather provides that - * mechanism with a certain level of abstraction while also providing a - * cleaner, more consistent API. - */ - #include #include #include @@ -35,6 +25,16 @@ #include +/** + * \file script.hh + * A thin wrapper over Lua 5.1. This is not meant as a complicated binding + * package between C++ and Lua. It is not meant to obscure the division + * between C++ and Lua but rather to clarify it and make it more manageable. + * It does not hide the concept of the Lua stack, but rather provides that + * mechanism with a certain level of abstraction while also providing a + * cleaner, more consistent API. + */ + namespace moof { diff --git a/src/moof/service.hh b/src/moof/service.hh index c0ca674..1a8b363 100644 --- a/src/moof/service.hh +++ b/src/moof/service.hh @@ -10,17 +10,17 @@ #ifndef _MOOF_SERVICE_HH_ #define _MOOF_SERVICE_HH_ -/** - * \file service.hh - * Classes for publishing and finding network services. - */ - #include #include #include +/** + * \file service.hh + * Classes for publishing and finding network services. + */ + namespace moof { diff --git a/src/moof/settings.hh b/src/moof/settings.hh index c8459cf..0b8ccc2 100644 --- a/src/moof/settings.hh +++ b/src/moof/settings.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_SETTINGS_HH_ #define _MOOF_SETTINGS_HH_ -/** - * \file settings.hh - * Load, store, save program settings. - */ - #include #include @@ -23,6 +18,11 @@ #include +/** + * \file settings.hh + * Load, store, save program settings. + */ + namespace moof { diff --git a/src/moof/shape.hh b/src/moof/shape.hh index 9af106b..1d6d736 100644 --- a/src/moof/shape.hh +++ b/src/moof/shape.hh @@ -10,16 +10,17 @@ #ifndef _MOOF_SHAPE_HH_ #define _MOOF_SHAPE_HH_ -/** - * \file shape.hh - * Declares an interface for shapes. - */ - #include #include #include #include + +/** + * \file shape.hh + * Declares an interface for shapes. + */ + // frustum // plane (can construct from triangle2) // ray diff --git a/src/moof/socket.hh b/src/moof/socket.hh index 08a5f50..a7d02f9 100644 --- a/src/moof/socket.hh +++ b/src/moof/socket.hh @@ -12,11 +12,6 @@ #ifndef _MOOF_SOCKET_HH_ #define _MOOF_SOCKET_HH_ -/** - * \file socket.hh - * Network-related classes, including a reinterpreted sockets API. - */ - #include #include #include @@ -44,7 +39,6 @@ #include #include - #ifndef AI_ADDRCONFIG #define AI_ADDRCONFIG 0 #endif @@ -54,6 +48,11 @@ #endif +/** + * \file socket.hh + * Network-related classes, including a reinterpreted sockets API. + */ + namespace moof { diff --git a/src/moof/sound.cc b/src/moof/sound.cc index 8b22c47..bcd8667 100644 --- a/src/moof/sound.cc +++ b/src/moof/sound.cc @@ -18,13 +18,14 @@ #include #include -#include "log.hh" +#include "debug.hh" #include "sound.hh" #include "resource.hh" #include "runloop.hh" #include "thread.hh" #include "timer.hh" + #ifndef BUF_SIZE #define BUF_SIZE 8192 #endif @@ -94,12 +95,12 @@ int sound_backend::retain_count = 0; ALCdevice* sound_backend::al_device; ALCcontext* sound_backend::al_context; + class sound_resource; typedef resource_handle sound_handle; MOOF_REGISTER_RESOURCE(sound_resource, ogg, sounds); - class sound_resource : public boost::noncopyable { public: diff --git a/src/moof/sound.hh b/src/moof/sound.hh index 1f7fcfe..3639d7b 100644 --- a/src/moof/sound.hh +++ b/src/moof/sound.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_SOUND_HH_ #define _MOOF_SOUND_HH_ -/** - * \file sound.hh - * Load and play sounds, currently supports ogg vorbis. - */ - #include #include @@ -22,6 +17,11 @@ #include +/** + * \file sound.hh + * Load and play sounds, currently supports ogg vorbis. + */ + namespace moof { diff --git a/src/moof/sphere.hh b/src/moof/sphere.hh index 75c5808..15a8031 100644 --- a/src/moof/sphere.hh +++ b/src/moof/sphere.hh @@ -10,12 +10,6 @@ #ifndef _MOOF_SPHERE_HH_ #define _MOOF_SPHERE_HH_ -/** - * \file sphere.hh - * A round shape like a circle or sphere. - * TODO: This class needs some work. - */ - #include #include #include @@ -25,6 +19,12 @@ #include +/** + * \file sphere.hh + * A round shape like a circle or sphere. + * TODO: This class needs some work. + */ + namespace moof { diff --git a/src/moof/sprite.cc b/src/moof/sprite.cc index b71a4b9..602fc2c 100644 --- a/src/moof/sprite.cc +++ b/src/moof/sprite.cc @@ -13,6 +13,7 @@ #include #include + #include #include "dispatcher.hh" diff --git a/src/moof/sprite.hh b/src/moof/sprite.hh index 88029e5..b88b007 100644 --- a/src/moof/sprite.hh +++ b/src/moof/sprite.hh @@ -10,17 +10,17 @@ #ifndef _MOOF_SPRITE_HH_ #define _MOOF_SPRITE_HH_ -/** - * \file sprite.hh - * Image-loading and OpenGL texture loading. - */ - #include #include #include +/** + * \file sprite.hh + * Image-loading and OpenGL texture loading. + */ + namespace moof { diff --git a/src/moof/string.cc b/src/moof/string.cc index a73bcd0..995553c 100644 --- a/src/moof/string.cc +++ b/src/moof/string.cc @@ -11,9 +11,9 @@ #include -#include "ConvertUTF.h" #include "script.hh" #include "string.hh" +#include "ConvertUTF.h" namespace moof { diff --git a/src/moof/string.hh b/src/moof/string.hh index 4194abb..25a7360 100644 --- a/src/moof/string.hh +++ b/src/moof/string.hh @@ -10,16 +10,16 @@ #ifndef _MOOF_STRING_HH_ #define _MOOF_STRING_HH_ -/** - * \file string.hh - * Functions and classes related to string manipulation. - */ - #include #include +/** + * \file string.hh + * Functions and classes related to string manipulation. + */ + namespace moof { diff --git a/src/moof/thread.hh b/src/moof/thread.hh index 17d3170..af251e1 100644 --- a/src/moof/thread.hh +++ b/src/moof/thread.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_THREAD_HH_ #define _MOOF_THREAD_HH_ -/** - * \file thread.hh - * Light C++ wrapper around the SDL threads API. - */ - #include #include #include @@ -24,6 +19,11 @@ #include +/** + * \file thread.hh + * Light C++ wrapper around the SDL threads API. + */ + namespace moof { diff --git a/src/moof/timer.hh b/src/moof/timer.hh index edd1de2..a429ba9 100644 --- a/src/moof/timer.hh +++ b/src/moof/timer.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_TIMER_HH_ #define _MOOF_TIMER_HH_ -/** - * \file timer.hh - * Functions for measuring time in a friendly unit. - */ - #include #include #include @@ -23,6 +18,11 @@ #include +/** + * \file timer.hh + * Functions for measuring time in a friendly unit. + */ + namespace moof { diff --git a/src/moof/video.hh b/src/moof/video.hh index 6b4980e..9ec795f 100644 --- a/src/moof/video.hh +++ b/src/moof/video.hh @@ -10,11 +10,6 @@ #ifndef _MOOF_VIDEO_HH_ #define _MOOF_VIDEO_HH_ -/** - * \file video.hh - * Classes for managing a video context. - */ - #include #include @@ -25,6 +20,11 @@ #include +/** + * \file video.hh + * Classes for managing a video context. + */ + namespace moof { diff --git a/src/rules.mk b/src/rules.mk index 16ebea6..cbf2776 100644 --- a/src/rules.mk +++ b/src/rules.mk @@ -13,17 +13,24 @@ endif ifeq (true,$(includeConfig)) objects += $b/config.o # Also compile in the configuration. +exec += $b/config.gz exec += $b/config.c # Make config.c a build target. -$b/config.c: config.mk +$b/config.gz: config.mk + $(Q)$(gzip) +$b/config.c: $b/config.gz $(Q)$(xxd) endif -$(objects): TGT_CFLAGS := -I$d -$(objects): config.h $(this) | $b +$(objects): TGT_CFLAGS := -I$b -I$d +$(objects): config.h | $b # Make all objects depend on config.h; it's excessive, but config.h won't be # remade otherwise if dependencies are not being generated. The alternative # is to maintain an accurate list of objects with a dependency on config.h. +ifeq (true,$(pch)) +$(objects): $b/moof/precompile.hh.gch +endif + exec += $(objects) # Make the objects build targets. bindir_$b := $b/$(projectName)$(EXEEXT) # Install executable to bindir. diff --git a/src/stlplus/rules.mk b/src/stlplus/rules.mk index b15fa52..3e4f41d 100644 --- a/src/stlplus/rules.mk +++ b/src/stlplus/rules.mk @@ -5,7 +5,7 @@ objects = $(patsubst %.cpp,$(builddir)/%.o,$(shell find $d -name "*.cpp")) $(objects): TGT_CFLAGS := -I$d -I$d/containers -I$d/portability -$(objects): config.mk $(this) | $b/containers $b/portability +$(objects): config.mk | $b/containers $b/portability library = $b/libstlplus.a $(library): $(objects) diff --git a/src/yoink.hh b/src/yoink.hh index edd38bf..8a2a28c 100644 --- a/src/yoink.hh +++ b/src/yoink.hh @@ -10,23 +10,17 @@ #ifndef _YOINK_HH_ #define _YOINK_HH_ -/** - * \file yoink.hh - * This is the big enchilada. - */ - #include #include #include #include -#include -#include - #include // TODO +#include #include #include +#include #include #include @@ -34,6 +28,11 @@ #include "Hud.hh" +/** + * \file yoink.hh + * This is the big enchilada. + */ + class yoink { public: -- 2.45.2