diff options
| -rwxr-xr-x | build.sh | 6 | ||||
| -rw-r--r-- | kon/konsofren.h | 14 |
2 files changed, 20 insertions, 0 deletions
@@ -110,6 +110,12 @@ case " $modules " in *" 3d "*) need tile ;; esac case " $modules " in *" model "*) need assets ;; esac case " $DEFS " in *" -DKON_MODULE_ASSETS "*) need pack ;; esac +# 2D games do not get the 3D renderer, the 3d, model and sector modules turn it on +case " $DEFS " in +*" -DKON_MODULE_3D "*|*" -DKON_MODULE_MODEL "*|*" -DKON_MODULE_SECTOR "*) ;; +*) DEFS="$DEFS -DKONSOFREN_NO_3D" ;; +esac + case " $modules " in *" debug "*) [ $developer = 1 ] || echo "note: debug module does nothing without -d or -D" ;; esac diff --git a/kon/konsofren.h b/kon/konsofren.h index 9b71a64..d7f3570 100644 --- a/kon/konsofren.h +++ b/kon/konsofren.h @@ -26,6 +26,9 @@ #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 */ + #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -74,6 +77,8 @@ typedef struct kon_display { kon_filter_t filter; } kon_display_t; +#ifndef KONSOFREN_NO_3D + typedef enum kon_projection { KON_PROJECTION_PERSPECTIVE = 0, KON_PROJECTION_ORTHOGRAPHIC @@ -147,6 +152,8 @@ typedef struct kon_mesh { int triangleCount; } kon_mesh_t; +#endif /* KONSOFREN_NO_3D */ + /*** 2D declarations ***/ /*** framebuffer declarations ***/ @@ -201,6 +208,8 @@ 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 + /*** 3D declarations ***/ /*** camera declarations ***/ @@ -241,6 +250,8 @@ 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 */ + /*** implementation ***/ #ifdef KONSOFREN_IMPLEMENTATION @@ -985,6 +996,8 @@ int kon_windowToGame(const kon_display_t *display, int windowX, int windowY, int return 1; } +#ifndef KONSOFREN_NO_3D + /*** 3D implementation ***/ @@ -1637,6 +1650,7 @@ int kon_drawBillboard(kon_framebuffer_t *fb, kon_mat4_t viewProjection, kon_vec3 return 1; } +#endif /* KONSOFREN_NO_3D */ #endif /* end of KONSOFREN_IMPLEMENTATION */ #endif |
