commit dcad58da5a6dd0e438ca6aadc2b9d20bd466aaec
parent 62426a5e951917871d7280f60c87360f24e93b22
Author: amin <dev@aminmesbah.com>
Date: Sat, 15 Jun 2019 23:21:25 +0000
Fix builds broken when we switched to unity build
FossilOrigin-Name: 48203f0db393aa1ce7bcf3f74dc53440193e0b767eb61171a5ac11f58c9e8e4a
Diffstat:
8 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -4,6 +4,6 @@
*.bc
*.o
-build/*
+out/*
tags
diff --git a/Makefile b/Makefile
@@ -2,7 +2,7 @@ CC = clang
CFLAGS = -std=c99 -Ilib -Wall -Wextra -Wshadow -Wswitch-enum -Wno-unused-parameter -Wno-missing-braces
LDFLAGS = -ldl -lglfw -lGL -lm
-SRC_FILES = game.c platform_linux.c
+SRC_FILES = platform_linux.c
SRC = $(addprefix src/, $(SRC_FILES))
EXE_FILE = quaternion_demo
@@ -10,19 +10,19 @@ LIB_FILES = game.c
LIB = $(addprefix src/, $(LIB_FILES))
LIB_NAME = game.so
-DBGDIR = build/debug
+DBGDIR = out/debug
DBGEXE = $(DBGDIR)/$(EXE_FILE)
DBGCFLAGS = -g -Og -Werror
-RELDIR = build/release
+RELDIR = out/release
RELEXE = $(RELDIR)/$(EXE_FILE)
RELLIB = $(RELDIR)/$(LIB_NAME)
RELLIBTMP = $(RELLIB).tmp
RELCFLAGS = -DPLATFORM_HOTLOAD_GAME_CODE -O2 -Os
-EMS_FILES = game.c platform_emscripten.c
+EMS_FILES = platform_emscripten.c
EMSSRC = $(addprefix src/, $(EMS_FILES))
-EMSDIR = build/emscripten
+EMSDIR = out/emscripten
EMSEXE = $(EMSDIR)/$(EXE_FILE).html
EMSCFLAGS = --preload-file shader -s USE_GLFW=3 -s USE_WEBGL2=1
@@ -46,7 +46,7 @@ clean:
rm -f $(RELDIR)/* $(DBGDIR)/*
debug: build_debug
- cgdb $(DBGEXE)
+ gdb $(DBGEXE)
dir_debug:
@mkdir -p $(DBGDIR)
diff --git a/src/game.h b/src/game.h
@@ -7,14 +7,13 @@
#include <stdio.h>
#include <stdlib.h>
-#include "glmth.h"
-
#ifdef GAME_WEBGL
#include "webgl.h"
#else
#include "glad/glad.h"
#endif
+#include "glmth.h"
#include "shader.h"
struct GameState
diff --git a/src/glmth.h b/src/glmth.h
@@ -85,7 +85,7 @@ typedef struct
f32 E[4][4]; // E[row][column]
} m4;
-inline m4 glmth_m4_init_id(void)
+static inline m4 glmth_m4_init_id(void)
{
m4 m = { 0 };
m.E[0][0] = 1.0f;
@@ -95,7 +95,7 @@ inline m4 glmth_m4_init_id(void)
return m;
}
-inline f32 *glmth_m4_valueptr(m4 m)
+static inline f32 *glmth_m4_valueptr(m4 m)
{
f32 *values = malloc(sizeof(m4));
for (u8 v = 0; v < 16; ++v)
@@ -107,7 +107,7 @@ inline f32 *glmth_m4_valueptr(m4 m)
return values;
}
-inline m4 glmth_m4m4_m(m4 mat1, m4 mat2)
+static inline m4 glmth_m4m4_m(m4 mat1, m4 mat2)
{
m4 r = {
.E[0][0] = (mat1.E[0][0] * mat2.E[0][0]) + (mat1.E[0][1] * mat2.E[1][0]) + (mat1.E[0][2] * mat2.E[2][0]) + (mat1.E[0][3] * mat2.E[3][0]),
@@ -133,30 +133,30 @@ inline m4 glmth_m4m4_m(m4 mat1, m4 mat2)
return r;
}
-inline v3 glmth_v3_init(f32 x, f32 y, f32 z)
+static inline v3 glmth_v3_init(f32 x, f32 y, f32 z)
{
v3 v = { .x = x, .y = y, .z = z };
return v;
}
-inline f32 glmth_v3_length(v3 v)
+static inline f32 glmth_v3_length(v3 v)
{
return sqrtf((v.x * v.x) + (v.y * v.y) + (v.z * v.z));
}
-inline v3 glmth_v3_normalize(v3 v)
+static inline v3 glmth_v3_normalize(v3 v)
{
f32 l = glmth_v3_length(v);
v3 r = glmth_v3_init(v.x / l, v.y / l, v.z / l);
return r;
}
-inline f32 glmth_rad(f32 deg)
+static inline f32 glmth_rad(f32 deg)
{
return deg * (M_PI / 180.0f);
}
-inline m4 glmth_rotate(m4 m, f32 rad, v3 axis)
+static inline m4 glmth_rotate(m4 m, f32 rad, v3 axis)
{
axis = glmth_v3_normalize(axis);
@@ -180,7 +180,7 @@ inline m4 glmth_rotate(m4 m, f32 rad, v3 axis)
return glmth_m4m4_m(m, r);
}
-inline m4 glmth_translate(m4 m, v3 v)
+static inline m4 glmth_translate(m4 m, v3 v)
{
m4 r = glmth_m4_init_id();
r.E[0][3] = v.x;
@@ -189,7 +189,7 @@ inline m4 glmth_translate(m4 m, v3 v)
return glmth_m4m4_m(m, r);
}
-inline m4 glmth_projection_perspective(f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far)
+static inline m4 glmth_projection_perspective(f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far)
{
assert(left != right);
assert(bottom != top);
@@ -220,7 +220,7 @@ inline m4 glmth_projection_perspective(f32 left, f32 right, f32 bottom, f32 top,
return r;
}
-inline m4 glmth_projection_perspective_fov(f32 fovy, f32 aspect, f32 near, f32 far)
+static inline m4 glmth_projection_perspective_fov(f32 fovy, f32 aspect, f32 near, f32 far)
{
f32 half_height = tanf(fovy / 2.0f) * near;
f32 half_width = half_height * aspect;
diff --git a/src/platform_emscripten.c b/src/platform_emscripten.c
@@ -1,5 +1,3 @@
-#include "platform_emscripten.h"
-
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
@@ -10,6 +8,8 @@
#define GLFW_INCLUDE_ES3
#include <GLFW/glfw3.h>
+#include "game.c"
+#include "platform_emscripten.h"
void error_callback(int error, const char *description);
void framebuffer_size_callback(GLFWwindow *window, int width, int height);
diff --git a/src/platform_emscripten.h b/src/platform_emscripten.h
@@ -4,9 +4,6 @@
#include <stdbool.h>
#include <time.h>
-#include <GLFW/glfw3.h>
-#include "game.h"
-
#define PLATFORM_SCR_WIDTH 600
#define PLATFORM_SCR_HEIGHT 600
diff --git a/src/platform_linux.c b/src/platform_linux.c
@@ -1,5 +1,3 @@
-#include "platform_linux.h"
-
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
@@ -11,6 +9,8 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
+#include "game.c"
+#include "platform_linux.h"
void error_callback(int error, const char* description);
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
diff --git a/src/platform_linux.h b/src/platform_linux.h
@@ -4,8 +4,6 @@
#include <stdbool.h>
#include <time.h>
-#include "game.h"
-
#define PLATFORM_SCR_WIDTH 600
#define PLATFORM_SCR_HEIGHT 600
@@ -16,7 +14,7 @@
#define PLATFORM_MS_PER_UPDATE (PLATFORM_SECOND / PLATFORM_UPDATES_PER_SECOND)
#ifdef PLATFORM_HOTLOAD_GAME_CODE
-#define PLATFORM_GAME_LIB_PATH "./build/release/game.so"
+#define PLATFORM_GAME_LIB_PATH "./out/release/game.so"
struct GameCode
{
bool is_valid;