commit 642c0708354d8b1cf8b2fd9d790a7a959f8e40da
parent ecffa4be5c0b8ae0ef99e1a7e3e1b27bbc91f742
Author: amin <dev@aminmesbah.com>
Date: Sun, 3 Mar 2019 23:02:59 +0000
Switch to a unity build
FossilOrigin-Name: 8ea44ed71685dedaf48d965f54dcb17a3b9b994f9aaa03f56feb8c740203cad4
Diffstat:
10 files changed, 18 insertions(+), 62 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,6 +1,6 @@
*.out
*.swp
-build/*
+out/*
tags
diff --git a/Makefile b/Makefile
@@ -2,19 +2,19 @@ CC = clang
CFLAGS = -std=c99 -Ilib -Wall -Wextra -Wshadow -Wswitch-enum -Wno-unused-parameter -Wno-missing-braces
LDFLAGS = -ldl -lglfw -lGL -lGLEW -lm
-SRC_FILES = game.c glad.c glmth.c platform_linux.c shader.c
+SRC_FILES = platform_linux.c
SRC = $(addprefix src/, $(SRC_FILES))
EXE_FILE = a_game
-LIB_FILES = game.c glad.c glmth.c shader.c
+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
diff --git a/src/game.c b/src/game.c
@@ -1,9 +1,7 @@
#include "game.h"
-
-#include <assert.h>
-#include <math.h>
-
-#include <glad/glad.h>
+#include "glmth.c"
+#include "glad.c"
+#include "shader.c"
#ifdef PLATFORM_HOTLOAD_GAME_CODE
diff --git a/src/game.h b/src/game.h
@@ -1,7 +1,11 @@
-#ifndef GAME_H
-#define GAME_H
+#include <assert.h>
+#include <math.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <glad/glad.h>
-#include "glad/glad.h"
#include "glmth.h"
#include "shader.h"
@@ -47,5 +51,3 @@ void game_update_and_render(struct GameState *game_state, float dt, v2u framebuf
void game_init(struct GameState *game_state, v2u framebuffer);
void game_cleanup(struct GameState *game_state);
-
-#endif
diff --git a/src/glmth.c b/src/glmth.c
@@ -1,8 +1,3 @@
-#include "glmth.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
m4 glmth_m4_init_id()
{
m4 m = { 0 };
diff --git a/src/glmth.h b/src/glmth.h
@@ -1,11 +1,3 @@
-#ifndef GLMTH_H
-#define GLMTH_H
-
-#include <assert.h>
-#include <math.h>
-#include <stdbool.h>
-#include <stdint.h>
-
#ifndef M_PI
#define M_PI 3.14159265359f
#endif
@@ -147,5 +139,3 @@ m4 glmth_projection_ortho(f32 left, f32 right, f32 bottom, f32 top, f32 near, f3
m4 glmth_projection_perspective(f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far);
m4 glmth_projection_perspective_fov(f32 fovy, f32 aspect, f32 near, f32 far);
m4 glmth_camera_look_at(v3 camera_pos, v3 camera_target, v3 up);
-
-#endif
diff --git a/src/platform_linux.c b/src/platform_linux.c
@@ -1,8 +1,3 @@
-#include "platform_linux.h"
-
-#include <inttypes.h>
-#include <stdint.h>
-#include <stdio.h>
#include <time.h>
#include <dlfcn.h>
@@ -11,7 +6,8 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
-#include "glmth.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
@@ -1,11 +1,3 @@
-#ifndef PLATFORM_LINUX_H
-#define PLATFORM_LINUX_H
-
-#include <stdbool.h>
-#include <time.h>
-
-#include "game.h"
-
#define PLATFORM_SCR_WIDTH 600u
#define PLATFORM_SCR_HEIGHT 600u
@@ -16,7 +8,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;
@@ -26,5 +18,3 @@ struct GameCode
game_update_and_render_func *game_update_and_render;
};
#endif // PLATFORM_HOTLOAD_GAME_CODE
-
-#endif // PLATFORM_LINUX_H
diff --git a/src/shader.c b/src/shader.c
@@ -1,6 +1,3 @@
-#include "shader.h"
-
-
char *read_file(char *file_path)
{
FILE *handle = fopen(file_path, "r");
diff --git a/src/shader.h b/src/shader.h
@@ -1,13 +1,3 @@
-#ifndef SHADER_H
-#define SHADER_H
-
-#include <glad/glad.h> // get opengl headers
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "glmth.h"
-
struct Shader
{
uint32_t program;
@@ -23,5 +13,3 @@ void shader_setm4(struct Shader *s, char *name, m4 *mat);
void shader_setf3(struct Shader *s, char *name, f32 x, f32 y, f32 z);
void shader_setf3_1(struct Shader *s, char *name, f32 f);
void shader_setv3(struct Shader *s, char *name, v3 *v);
-
-#endif