summaryrefslogtreecommitdiff
path: root/kon
diff options
context:
space:
mode:
authorKonAki <konaki@anokonaki.org>2026-10-11 21:57:22 +0800
committerKonAki <konaki@anokonaki.org>2026-10-11 21:57:22 +0800
commit95bd48a7b0556adab5250cae766ee9dd9c6b2cde (patch)
treea29b83a4f436d6c58321a44977e4eb6d30f7c8d8 /kon
parent42630ebee76996a37f5104e6e11b860f31634dab (diff)
konsofren: 3D is opt-in with KONSOFREN_3D, build.sh sets it for 3d, model and sector
Diffstat (limited to 'kon')
-rw-r--r--kon/kon3d.h4
-rw-r--r--kon/konmodel.h4
-rw-r--r--kon/konsector.h11
-rw-r--r--kon/konsofren.h18
4 files changed, 28 insertions, 9 deletions
diff --git a/kon/kon3d.h b/kon/kon3d.h
index 726df26..f45f985 100644
--- a/kon/kon3d.h
+++ b/kon/kon3d.h
@@ -29,6 +29,10 @@
#include "konprogram.h"
#include "kontile.h"
+#ifndef KONSOFREN_HAS_3D
+#error "this needs the 3D part of konsofren, define KONSOFREN_3D before the first include of konsofren.h (build.sh does it for -m 3d, model and sector)"
+#endif
+
/*** definition ***/
/* a first person body on a tilemap. the world is one unit per tile, y is up, yaw 0 looks up the map (towards row 0) */
diff --git a/kon/konmodel.h b/kon/konmodel.h
index 8ce36c8..9120194 100644
--- a/kon/konmodel.h
+++ b/kon/konmodel.h
@@ -33,6 +33,10 @@
#include "konsofren.h"
#include "konassets.h"
+#ifndef KONSOFREN_HAS_3D
+#error "this needs the 3D part of konsofren, define KONSOFREN_3D before the first include of konsofren.h (build.sh does it for -m 3d, model and sector)"
+#endif
+
/*** definition ***/
#define KON_MODEL_MAX_BONES 128
diff --git a/kon/konsector.h b/kon/konsector.h
index c7a71e3..fa65a0e 100644
--- a/kon/konsector.h
+++ b/kon/konsector.h
@@ -24,7 +24,8 @@
*/
/* a map made of rooms: loading, saving, looking things up, building a mesh and drawing it. it needs konsofren.h and konmath.h next to it
- * and nothing else, so it is copy and paste like the other single header libs. in exactly one .c file:
+ * and nothing else, so it is copy and paste like the other single header libs. it turns on the 3D part of konsofren, so include it
+ * before konsofren.h or define KONSOFREN_3D yourself. in exactly one .c file:
*
* #define KONSOFREN_IMPLEMENTATION (once, wherever konsofren is)
* #define KONSECTOR_IMPLEMENTATION
@@ -37,9 +38,17 @@
#include <stddef.h>
+#ifndef KONSOFREN_3D
+#define KONSOFREN_3D
+#endif
+
#include "konmath.h"
#include "konsofren.h"
+#ifndef KONSOFREN_HAS_3D
+#error "this needs the 3D part of konsofren, define KONSOFREN_3D before the first include of konsofren.h (build.sh does it for -m 3d, model and sector)"
+#endif
+
/*** definition ***/
/* a map is rooms seen from above. every room (sector) is a polygon of vertices with a floor and a ceiling height, and every
diff --git a/kon/konsofren.h b/kon/konsofren.h
index d7f3570..4e29e56 100644
--- a/kon/konsofren.h
+++ b/kon/konsofren.h
@@ -26,8 +26,8 @@
#ifndef KONSOFREN_H
#define KONSOFREN_H
-/* define KONSOFREN_NO_3D (in every file that includes this, and where the implementation is) for a 2D game, the cameras,
- triangles, meshes and billboards are left out. 3D is on by default */
+/* the 3D part (cameras, triangles, meshes, billboards, mipmaps, fog) is only there if you ask for it. define KONSOFREN_3D
+ before this header in every file that includes it, and in the one with the implementation. a 2D game compiles without it */
#include <stdint.h>
#include <stdlib.h>
@@ -77,7 +77,9 @@ typedef struct kon_display {
kon_filter_t filter;
} kon_display_t;
-#ifndef KONSOFREN_NO_3D
+#ifdef KONSOFREN_3D
+
+#define KONSOFREN_HAS_3D
typedef enum kon_projection {
KON_PROJECTION_PERSPECTIVE = 0,
@@ -152,7 +154,7 @@ typedef struct kon_mesh {
int triangleCount;
} kon_mesh_t;
-#endif /* KONSOFREN_NO_3D */
+#endif /* KONSOFREN_3D */
/*** 2D declarations ***/
@@ -208,7 +210,7 @@ void kon_presentDisplay(kon_display_t *display);
/* returns 0 if the window position is on a bar, outside the game image */
int kon_windowToGame(const kon_display_t *display, int windowX, int windowY, int *gameX, int *gameY);
-#ifndef KONSOFREN_NO_3D
+#ifdef KONSOFREN_3D
/*** 3D declarations ***/
@@ -250,7 +252,7 @@ int kon_drawBillboard(kon_framebuffer_t *fb, kon_mat4_t viewProjection, kon_vec3
/* cube from -1 to 1 with every face mapped to the whole texture */
extern const kon_mesh_t kon_cubeMesh;
-#endif /* KONSOFREN_NO_3D */
+#endif /* KONSOFREN_3D */
/*** implementation ***/
@@ -996,7 +998,7 @@ int kon_windowToGame(const kon_display_t *display, int windowX, int windowY, int
return 1;
}
-#ifndef KONSOFREN_NO_3D
+#ifdef KONSOFREN_3D
/*** 3D implementation ***/
@@ -1650,7 +1652,7 @@ int kon_drawBillboard(kon_framebuffer_t *fb, kon_mat4_t viewProjection, kon_vec3
return 1;
}
-#endif /* KONSOFREN_NO_3D */
+#endif /* KONSOFREN_3D */
#endif /* end of KONSOFREN_IMPLEMENTATION */
#endif