aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2023-11-22 20:32:48 +0100
committervimene <vincent.menegaux@gmail.com>2023-11-22 20:32:48 +0100
commit4558a2a704bf75266f7262f8dd41bb1c9b094e1d (patch)
tree3042dedc701d0458d5ede0a85d554ec174c61a6f
parent6322e8d7e6e4ddb1c0a0b3a00a1b516d1a84df49 (diff)
downloadengine-4558a2a704bf75266f7262f8dd41bb1c9b094e1d.tar.gz
code refactoring
-rw-r--r--.gitignore11
-rw-r--r--Makefile.am5
-rw-r--r--src/engine.cpp14
-rw-r--r--src/fb/chfb.cpp (renamed from src/chfb.cpp)10
-rw-r--r--src/fb/chfb.h (renamed from src/chfb.h)10
-rw-r--r--src/fb/pixfb.cpp (renamed from src/pixfb.cpp)10
-rw-r--r--src/fb/pixfb.h (renamed from src/pixfb.h)10
-rw-r--r--src/math/math_vector.cpp (renamed from src/math_vector.cpp)2
-rw-r--r--src/math/math_vector.h (renamed from src/math_vector.h)6
-rw-r--r--src/o3d/obj3d.cpp (renamed from src/obj3d.cpp)6
-rw-r--r--src/o3d/obj3d.h (renamed from src/obj3d.h)10
-rw-r--r--src/o3d/tri_vertex.cpp (renamed from src/tri_vertex.cpp)10
-rw-r--r--src/o3d/tri_vertex.h (renamed from src/tri_vertex.h)8
-rw-r--r--src/o3d/vertex.cpp (renamed from src/vertex.cpp)6
-rw-r--r--src/o3d/vertex.h (renamed from src/vertex.h)10
-rw-r--r--src/o3d/vertex_data.cpp (renamed from src/vertex_data.cpp)2
-rw-r--r--src/o3d/vertex_data.h (renamed from src/vertex_data.h)6
17 files changed, 74 insertions, 62 deletions
diff --git a/.gitignore b/.gitignore
index bbb34b8..f0fcf1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,11 +9,20 @@ m4/pkg.m4
configure
configure~
src/.deps/
+src/.dirstamp
src/*.o
+src/fb/.deps/
+src/fb/.dirstamp
+src/fb/*.o
+src/math/.deps/
+src/math/.dirstamp
+src/math/*.o
+src/o3d/.deps/
+src/o3d/.dirstamp
+src/o3d/*.o
src/config.h
src/config.h.in
src/config.h.in~
-src/.dirstamp
src/stamp-h1
autom4te.cache
config.log
diff --git a/Makefile.am b/Makefile.am
index 6c8ff00..0f451ca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,10 @@ ACLOCAL_AMFLAGS = -Im4 --install
AM_CPPFLAGS = $(DEPS_CFLAGS)
bin_PROGRAMS = engine
-engine_SOURCES = src/chfb.cpp src/chfb.h src/engine.cpp src/math_vector.cpp src/math_vector.h src/obj3d.cpp src/obj3d.h src/pixfb.cpp src/pixfb.h src/tri_vertex.cpp src/tri_vertex.h src/vertex.cpp src/vertex_data.cpp src/vertex_data.h src/vertex.h
+engine_SOURCES = src/engine.cpp
+engine_SOURCES += src/fb/chfb.h src/fb/chfb.cpp src/fb/pixfb.h src/fb/pixfb.cpp
+engine_SOURCES += src/math/math_vector.h src/math/math_vector.cpp
+engine_SOURCES += src/o3d/obj3d.h src/o3d/obj3d.cpp src/o3d/tri_vertex.h src/o3d/tri_vertex.cpp src/o3d/vertex.h src/o3d/vertex.cpp src/o3d/vertex_data.h src/o3d/vertex_data.cpp
engine_LDADD = $(DEPS_LIBS)
EXTRA_DIST = m4/NOTES
diff --git a/src/engine.cpp b/src/engine.cpp
index 840d2f9..292f167 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -13,13 +13,13 @@
#include <cstdint>
#include <vector>
#include <SDL.h>
-#include "chfb.h"
-#include "pixfb.h"
-#include "obj3d.h"
-#include "math_vector.h"
-#include "vertex.h"
-#include "vertex_data.h"
-#include "tri_vertex.h"
+#include "fb/chfb.h"
+#include "fb/pixfb.h"
+#include "o3d/obj3d.h"
+#include "o3d/vertex.h"
+#include "o3d/vertex_data.h"
+#include "o3d/tri_vertex.h"
+#include "math/math_vector.h"
#define MKEY_Z 122
#define MKEY_Q 113
diff --git a/src/chfb.cpp b/src/fb/chfb.cpp
index 249fb16..7ac1626 100644
--- a/src/chfb.cpp
+++ b/src/fb/chfb.cpp
@@ -1,11 +1,11 @@
-#include "chfb.h"
+#include "fb/chfb.h"
#include <array>
#include <cmath>
#include <vector>
-#include "math_vector.h"
-#include "vertex.h"
-#include "tri_vertex.h"
-#include "vertex_data.h"
+#include "math/math_vector.h"
+#include "o3d/vertex.h"
+#include "o3d/tri_vertex.h"
+#include "o3d/vertex_data.h"
CharacterFrameBuffer::CharacterFrameBuffer(unsigned int w, unsigned int h) {
resize(w, h);
diff --git a/src/chfb.h b/src/fb/chfb.h
index 66fd79c..a3d2ed5 100644
--- a/src/chfb.h
+++ b/src/fb/chfb.h
@@ -1,9 +1,9 @@
-#ifndef CHFB_H
-#define CHFB_H
+#ifndef FB_CHFB_H
+#define FB_CHFB_H
#include <vector>
-#include "math_vector.h"
-#include "tri_vertex.h"
+#include "math/math_vector.h"
+#include "o3d/tri_vertex.h"
class CharacterFrameBuffer {
public:
@@ -25,4 +25,4 @@ class CharacterFrameBuffer {
char face_char() const;
};
-#endif // CHFB_H
+#endif // FB_CHFB_H
diff --git a/src/pixfb.cpp b/src/fb/pixfb.cpp
index f84bf2f..d4563ca 100644
--- a/src/pixfb.cpp
+++ b/src/fb/pixfb.cpp
@@ -1,12 +1,12 @@
-#include "pixfb.h"
+#include "fb/pixfb.h"
#include <array>
#include <cmath>
#include <vector>
#include <cstdint>
-#include "math_vector.h"
-#include "vertex.h"
-#include "tri_vertex.h"
-#include "vertex_data.h"
+#include "math/math_vector.h"
+#include "o3d/vertex.h"
+#include "o3d/tri_vertex.h"
+#include "o3d/vertex_data.h"
PixelFrameBuffer::PixelFrameBuffer(unsigned int w, unsigned int h) {
resize(w, h);
diff --git a/src/pixfb.h b/src/fb/pixfb.h
index c54b5fb..f5f8bde 100644
--- a/src/pixfb.h
+++ b/src/fb/pixfb.h
@@ -1,10 +1,10 @@
-#ifndef PIXFB_H
-#define PIXFB_H
+#ifndef FB_PIXFB_H
+#define FB_PIXFB_H
#include <vector>
#include <cstdint>
-#include "math_vector.h"
-#include "tri_vertex.h"
+#include "math/math_vector.h"
+#include "o3d/tri_vertex.h"
class PixelFrameBuffer {
public:
@@ -26,4 +26,4 @@ class PixelFrameBuffer {
uint32_t face_color() const;
};
-#endif // PIXFB_H
+#endif // FB_PIXFB_H
diff --git a/src/math_vector.cpp b/src/math/math_vector.cpp
index 60081bf..baa2448 100644
--- a/src/math_vector.cpp
+++ b/src/math/math_vector.cpp
@@ -1,4 +1,4 @@
-#include "math_vector.h"
+#include "math/math_vector.h"
#include <cmath>
MathVector2::MathVector2() {
diff --git a/src/math_vector.h b/src/math/math_vector.h
index 336c3fe..668a3f3 100644
--- a/src/math_vector.h
+++ b/src/math/math_vector.h
@@ -1,5 +1,5 @@
-#ifndef MATH_VECTOR_H
-#define MATH_VECTOR_H
+#ifndef MATH_MATH_VECTOR_H
+#define MATH_MATH_VECTOR_H
class MathVector2 {
public:
@@ -66,4 +66,4 @@ MathVector4 operator*(float n, MathVector4 other);
MathVector4 operator*(MathVector4 other, float n);
MathVector4 operator/(MathVector4 other, float n);
-#endif // MATH_VECTOR_H
+#endif // MATH_MATH_VECTOR_H
diff --git a/src/obj3d.cpp b/src/o3d/obj3d.cpp
index 3902d30..46f4db6 100644
--- a/src/obj3d.cpp
+++ b/src/o3d/obj3d.cpp
@@ -1,8 +1,8 @@
-#include "obj3d.h"
+#include "o3d/obj3d.h"
#include <vector>
#include <array>
-#include "vertex.h"
-#include "tri_vertex.h"
+#include "o3d/vertex.h"
+#include "o3d/tri_vertex.h"
Object3D::TriangleVertex3Iterator::TriangleVertex3Iterator(const Object3D* obj, int face_ind) : obj{obj}, face_ind{face_ind} {
}
diff --git a/src/obj3d.h b/src/o3d/obj3d.h
index b76f06d..559ed63 100644
--- a/src/obj3d.h
+++ b/src/o3d/obj3d.h
@@ -1,11 +1,11 @@
-#ifndef OBJ3D_H
-#define OBJ3D_H
+#ifndef O3D_OBJ3D_H
+#define O3D_OBJ3D_H
#include <vector>
#include <array>
#include <iterator>
-#include "vertex.h"
-#include "tri_vertex.h"
+#include "o3d/vertex.h"
+#include "o3d/tri_vertex.h"
class Object3D {
public:
@@ -39,4 +39,4 @@ class Object3D {
std::vector<std::array<int, 3>> faces;
};
-#endif // OBJ3D_H
+#endif // O3D_OBJ3D_H
diff --git a/src/tri_vertex.cpp b/src/o3d/tri_vertex.cpp
index cd07770..7b6b379 100644
--- a/src/tri_vertex.cpp
+++ b/src/o3d/tri_vertex.cpp
@@ -1,9 +1,9 @@
-#include "tri_vertex.h"
+#include "o3d/tri_vertex.h"
#include <vector>
-#include "math_vector.h"
-#include "vertex_data.h"
-#include "vertex.h"
-#include "tri_vertex.h"
+#include "math/math_vector.h"
+#include "o3d/vertex_data.h"
+#include "o3d/vertex.h"
+#include "o3d/tri_vertex.h"
TriangleVertex3::TriangleVertex3(Vertex3 vertex1, Vertex3 vertex2, Vertex3 vertex3) : vertex1{vertex1}, vertex2{vertex2}, vertex3{vertex3} {
}
diff --git a/src/tri_vertex.h b/src/o3d/tri_vertex.h
index 5bbdd40..91e20f5 100644
--- a/src/tri_vertex.h
+++ b/src/o3d/tri_vertex.h
@@ -1,7 +1,7 @@
-#ifndef TRI_VERTEX_H
-#define TRI_VERTEX_H
+#ifndef O3D_TRI_VERTEX_H
+#define O3D_TRI_VERTEX_H
-#include "vertex.h"
+#include "o3d/vertex.h"
#include <vector>
class TriangleVertex3 {
@@ -26,4 +26,4 @@ class TriangleVertex4 {
TriangleVertex3 div_by_w() const;
};
-#endif // TRI_VERTEX_H
+#endif // O3D_TRI_VERTEX_H
diff --git a/src/vertex.cpp b/src/o3d/vertex.cpp
index d136754..c3bddef 100644
--- a/src/vertex.cpp
+++ b/src/o3d/vertex.cpp
@@ -1,6 +1,6 @@
-#include "vertex.h"
-#include "math_vector.h"
-#include "vertex_data.h"
+#include "o3d/vertex.h"
+#include "math/math_vector.h"
+#include "o3d/vertex_data.h"
Vertex3::Vertex3(MathVector3 point, VertexData data) : point{point}, data{data} {
}
diff --git a/src/vertex.h b/src/o3d/vertex.h
index 92b7dcb..27ca56a 100644
--- a/src/vertex.h
+++ b/src/o3d/vertex.h
@@ -1,8 +1,8 @@
-#ifndef VERTEX_H
-#define VERTEX_H
+#ifndef O3D_VERTEX_H
+#define O3D_VERTEX_H
-#include "math_vector.h"
-#include "vertex_data.h"
+#include "math/math_vector.h"
+#include "o3d/vertex_data.h"
class Vertex3 {
public:
@@ -22,4 +22,4 @@ class Vertex4 {
Vertex3 div_by_w() const;
};
-#endif // VERTEX_H
+#endif // O3D_VERTEX_H
diff --git a/src/vertex_data.cpp b/src/o3d/vertex_data.cpp
index 23c8b03..8d6f77b 100644
--- a/src/vertex_data.cpp
+++ b/src/o3d/vertex_data.cpp
@@ -1,4 +1,4 @@
-#include "vertex_data.h"
+#include "o3d/vertex_data.h"
VertexData VertexData::lerp(VertexData& vd1, VertexData& vd2, float s) {
return {};
diff --git a/src/vertex_data.h b/src/o3d/vertex_data.h
index e35d65a..0000dda 100644
--- a/src/vertex_data.h
+++ b/src/o3d/vertex_data.h
@@ -1,5 +1,5 @@
-#ifndef VERTEX_DATA_H
-#define VERTEX_DATA_H
+#ifndef O3D_VERTEX_DATA_H
+#define O3D_VERTEX_DATA_H
class VertexData {
public:
@@ -9,4 +9,4 @@ class VertexData {
VertexData();
};
-#endif // VERTEX_DATA_H
+#endif // O3D_VERTEX_DATA_H