rebooting erebus project: initial commit
authorJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 21 Dec 2020 06:46:10 +0000 (08:46 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 21 Dec 2020 06:46:10 +0000 (08:46 +0200)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
erebus/Makefile [new file with mode: 0644]
erebus/src/main.c [new file with mode: 0644]
liberebus/Makefile [new file with mode: 0644]
liberebus/include/erebus.h [new file with mode: 0644]
liberebus/src/erebus.c [new file with mode: 0644]
xerebus/Makefile [new file with mode: 0644]
xerebus/src/main.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..075c304
--- /dev/null
@@ -0,0 +1,6 @@
+*.o
+*.d
+*.swp
+*.a
+erebus/erebus
+xerebus/xerebus
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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 (file)
index 0000000..9e8bdb5
--- /dev/null
@@ -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 (file)
index 0000000..3fed7e6
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+       return 0;
+}
diff --git a/liberebus/Makefile b/liberebus/Makefile
new file mode 100644 (file)
index 0000000..fdcf704
--- /dev/null
@@ -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 (file)
index 0000000..c439e43
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef RENDLIB_H_
+#define RENDLIB_H_
+
+#include <cgmath/cgmath.h>
+
+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 (file)
index 0000000..da07635
--- /dev/null
@@ -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 (file)
index 0000000..6a3101d
--- /dev/null
@@ -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 (file)
index 0000000..3fed7e6
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+       return 0;
+}