From c8b13dff969d8104c178d9362aa21cefb9d61fe8 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 21 Dec 2020 08:46:10 +0200 Subject: [PATCH] rebooting erebus project: initial commit --- .gitignore | 6 ++++ Makefile | 86 ++++++++++++++++++++++++++++++++++++++++++++ erebus/Makefile | 33 +++++++++++++++++ erebus/src/main.c | 6 ++++ liberebus/Makefile | 36 +++++++++++++++++++ liberebus/include/erebus.h | 44 +++++++++++++++++++++++ liberebus/src/erebus.c | 10 ++++++ xerebus/Makefile | 34 ++++++++++++++++++ xerebus/src/main.c | 6 ++++ 9 files changed, 261 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 erebus/Makefile create mode 100644 erebus/src/main.c create mode 100644 liberebus/Makefile create mode 100644 liberebus/include/erebus.h create mode 100644 liberebus/src/erebus.c create mode 100644 xerebus/Makefile create mode 100644 xerebus/src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..075c304 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.o +*.d +*.swp +*.a +erebus/erebus +xerebus/xerebus diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1c27c0a --- /dev/null +++ b/Makefile @@ -0,0 +1,86 @@ +PREFIX ?= /usr/local +opt_targ = erebus xerebus +opt_opt = -ffast-math +opt_dbg = -g +# -------------------------- +export PREFIX +export opt_opt +export opt_dbg + +.PHONY: all +all: liberebus $(opt_targ) + +.PHONY: clean +clean: liberebus-clean erebus-clean xerebus-clean + +.PHONY: cleandep +cleandep: liberebus-cleandep erebus-cleandep xerebus-cleandep + +.PHONY: install +install: liberebus-install erebus-install xerebus-install + +.PHONY: uninstall +uninstall: liberebus-uninstall erebus-uninstall xerebus-uninstall + +# --- liberebus --- +.PHONY: liberebus +liberebus: + $(MAKE) -C liberebus + +.PHONY: liberebus-clean +liberebus-clean: + $(MAKE) -C liberebus clean + +.PHONY: liberebus-cleandep +liberebus-cleandep: + $(MAKE) -C liberebus cleandep + +.PHONY: liberebus-install +liberebus-install: + $(MAKE) -C liberebus install + +.PHONY: liberebus-uninstall +liberebus-uninstall: + $(MAKE) -C liberebus uninstall + +# --- erebus --- +.PHONY: erebus +erebus: + $(MAKE) -C erebus + +.PHONY: erebus-clean +erebus-clean: + $(MAKE) -C erebus clean + +.PHONY: erebus-cleandep +erebus-cleandep: + $(MAKE) -C erebus cleandep + +.PHONY: erebus-install +erebus-install: + $(MAKE) -C erebus install + +.PHONY: erebus-uninstall +erebus-uninstall: + $(MAKE) -C erebus uninstall + +# --- xerebus --- +.PHONY: xerebus +xerebus: + $(MAKE) -C xerebus + +.PHONY: xerebus-clean +xerebus-clean: + $(MAKE) -C xerebus clean + +.PHONY: xerebus-cleandep +xerebus-cleandep: + $(MAKE) -C xerebus cleandep + +.PHONY: xerebus-install +xerebus-install: + $(MAKE) -C xerebus install + +.PHONY: xerebus-uninstall +xerebus-uninstall: + $(MAKE) -C xerebus uninstall diff --git a/erebus/Makefile b/erebus/Makefile new file mode 100644 index 0000000..9e8bdb5 --- /dev/null +++ b/erebus/Makefile @@ -0,0 +1,33 @@ +src = $(wildcard src/*.c) +obj = $(src:.c=.o) +dep = $(src:.c=.d) + +bin = erebus + +incdir = -I../liberebus/include +libdir = -L../liberebus + +CFLAGS = -pedantic -Wall $(opt_dbg) $(opt_opt) $(incdir) +LDFLAGS = $(libdir) -lerebus + +$(bin): $(obj) + $(CC) -o $@ $(obj) $(LDFLAGS) + +-include $(dep) + +.PHONY: clean +clean: + rm -f $(obj) $(bin) + +.PHONY: cleandep +cleandep: + rm -f $(dep) + +.PHONY: install +install: $(bin) + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp $(bin) $(DESTDIR)$(PREFIX)/bin/$(bin) + +.PHONY: uninstall +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/$(bin) diff --git a/erebus/src/main.c b/erebus/src/main.c new file mode 100644 index 0000000..3fed7e6 --- /dev/null +++ b/erebus/src/main.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/liberebus/Makefile b/liberebus/Makefile new file mode 100644 index 0000000..fdcf704 --- /dev/null +++ b/liberebus/Makefile @@ -0,0 +1,36 @@ +src = $(wildcard src/*.c) +obj = $(src:.c=.o) +dep = $(src:.c=.d) + +name = erebus +alib = lib$(name).a + +incdir = -Iinclude + +CFLAGS = -pedantic -Wall $(opt_dbg) $(opt_opt) $(incdir) +LDFLAGS = -lm + +$(alib): $(obj) + $(AR) rcs $@ $(obj) + +-include $(dep) + +.PHONY: clean +clean: + rm -f $(obj) $(alib) + +.PHONY: cleandep +cleandep: + rm -f $(dep) + +.PHONY: install +install: $(alib) + mkdir -p $(DESTDIR)$(PREFIX)/include/erebus $(DESTDIR)$(PREFIX)/lib + cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib) + cp include/*.h $(DESTDIR)$(PREFIX)/include/erebus/ + +.PHONY: uninstall +uninstall: + rm -f $(DESTDIR)$(PREFIX)/lib/$(alib) + rm -f $(DESTDIR)$(PREFIX)/include/erebus/*.h + rmdir $(DESTDIR)$(PREFIX)/include/erebus diff --git a/liberebus/include/erebus.h b/liberebus/include/erebus.h new file mode 100644 index 0000000..c439e43 --- /dev/null +++ b/liberebus/include/erebus.h @@ -0,0 +1,44 @@ +#ifndef RENDLIB_H_ +#define RENDLIB_H_ + +#include + +struct erb_node; +struct erb_surf; +struct erb_ray; +struct erb_hit; + +typedef int (*erb_intersect_func)(struct erb_surf *surf, struct erb_ray *ray, struct erb_hit *hit); +typedef void (*erb_sample_func)(struct erb_surf *surf, cgm_vec3 *pos); + +struct erb_node { + struct erb_node *par; /* parent node */ + struct erb_node *clist; /* child nodes */ + struct erb_surf *surflist; /* surfaces in this node */ + float xform[16], inv_xform[16]; /* global transformation */ + float node_xform[16], inv_node_xform[16]; /* local transformation */ +}; + +struct erb_surf { + struct erb_node *node; /* transformation node for this surface */ + + erb_intersect_func isect; /* intersection routine */ + erb_sample_func sample; /* random sample generation */ +}; + +struct erb_ray { + cgm_vec3 o, d; /* origin and direction */ + float tmin, tmax; /* segment bounds */ + float ior; /* IOR of the medium through which this ray travels */ + float total_dist; /* travel distance accumulator */ +}; + +struct erb_hit { + float t, err; + struct erb_surf *surf; +}; + +int erb_init(void); +void erb_cleanup(void); + +#endif /* RENDLIB_H_ */ diff --git a/liberebus/src/erebus.c b/liberebus/src/erebus.c new file mode 100644 index 0000000..da07635 --- /dev/null +++ b/liberebus/src/erebus.c @@ -0,0 +1,10 @@ +#include "erebus.h" + +int erb_init(void) +{ + return 0; +} + +void erb_cleanup(void) +{ +} diff --git a/xerebus/Makefile b/xerebus/Makefile new file mode 100644 index 0000000..6a3101d --- /dev/null +++ b/xerebus/Makefile @@ -0,0 +1,34 @@ +src = $(wildcard src/*.c) +obj = $(src:.c=.o) +dep = $(src:.c=.d) + +bin = xerebus + +def = -DMINIGLUT_USE_LIBC +incdir = -I../liberebus/include +libdir = -L../liberebus + +CFLAGS = -pedantic -Wall $(opt_dbg) $(opt_opt) $(def) $(incdir) +LDFLAGS = $(libdir) -lerebus -lGL -lX11 + +$(bin): $(obj) + $(CC) -o $@ $(obj) $(LDFLAGS) + +-include $(dep) + +.PHONY: clean +clean: + rm -f $(obj) $(bin) + +.PHONY: cleandep +cleandep: + rm -f $(dep) + +.PHONY: install +install: $(bin) + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp $(bin) $(DESTDIR)$(PREFIX)/bin/$(bin) + +.PHONY: uninstall +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/$(bin) diff --git a/xerebus/src/main.c b/xerebus/src/main.c new file mode 100644 index 0000000..3fed7e6 --- /dev/null +++ b/xerebus/src/main.c @@ -0,0 +1,6 @@ +#include + +int main(int argc, char **argv) +{ + return 0; +} -- 1.7.10.4