commit 423b40abf8007d7354083b09765768169fd869fe
parent 45c232302f0824b382a78d08e462a0d651e1a32d
Author: amin <dev@aminmesbah.com>
Date: Tue, 16 Apr 2019 19:53:13 +0000
Give most functions internal linkage
Easy to do since we have a single translation unit.
FossilOrigin-Name: 5bc9d068e3fd34c73a1944441e8fb3fb6843abf0946fb75754f94d2b2d3f43f7
Diffstat:
6 files changed, 38 insertions(+), 42 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,5 +1,5 @@
CC = clang
-CFLAGS = -std=c99 -Ilib -Wall -Wextra -Wshadow -Wswitch-enum -Wno-unused-parameter -Wno-missing-braces
+CFLAGS = -std=c99 -Ilib -Wall -Wextra -Wshadow -Wswitch-enum -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces
LDFLAGS = -ldl -lglfw -lGL -lm
SRC_FILES = platform_linux.c
diff --git a/src/game.c b/src/game.c
@@ -2,7 +2,6 @@
#include "glad.c"
#include "shader.c"
-
#ifdef PLATFORM_HOTLOAD_GAME_CODE
void game_load_opengl_symbols(void)
{
@@ -10,8 +9,7 @@ void game_load_opengl_symbols(void)
}
#endif
-
-void game_init(struct GameState *game_state, v2u framebuffer)
+internal void game_init(struct GameState *game_state, v2u framebuffer)
{
// init player
game_state->player.pos = (v2) { 1.0f, 1.0f };
@@ -64,7 +62,6 @@ void game_init(struct GameState *game_state, v2u framebuffer)
game_state->player.shader = main_shader;
}
-
// NOTE(amin): For now updating and rendering are interleaved. We simulate the
// world at the same rate we render it. Our timestep is not fixed. We may want
// to change this in the future.
@@ -214,8 +211,7 @@ void game_update_and_render(struct GameState *game_state, f32 dt, v2u framebuffe
}
}
-
-void game_cleanup(struct GameState *game_state)
+internal void game_cleanup(struct GameState *game_state)
{
glDeleteVertexArrays(1, &game_state->tiles.vao);
glDeleteBuffers(1, &game_state->tiles.vbo);
diff --git a/src/game.h b/src/game.h
@@ -63,5 +63,5 @@ void game_load_opengl_symbols(void);
typedef void (game_update_and_render_func)(struct GameState *game_state, f32 dt, v2u framebuffer);
void game_update_and_render(struct GameState *game_state, f32 dt, v2u framebuffer);
-void game_init(struct GameState *game_state, v2u framebuffer);
-void game_cleanup(struct GameState *game_state);
+internal void game_init(struct GameState *game_state, v2u framebuffer);
+internal void game_cleanup(struct GameState *game_state);
diff --git a/src/platform_linux.c b/src/platform_linux.c
@@ -9,18 +9,18 @@
#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);
-void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
+internal void error_callback(int error, const char* description);
+internal void framebuffer_size_callback(GLFWwindow* window, int width, int height);
+internal void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
#ifdef PLATFORM_HOTLOAD_GAME_CODE
-time_t file_get_modified_time(char *file_path);
-void unload_game_code(struct GameCode *game_code);
-struct GameCode load_game_code(char *source_lib_path);
+internal time_t file_get_modified_time(char *file_path);
+internal void unload_game_code(struct GameCode *game_code);
+internal struct GameCode load_game_code(char *source_lib_path);
#endif
#ifdef GLAD_DEBUG
-void pre_gl_callback(const char *func_name, void *func_ptr, int len_args, ...)
+internal void pre_gl_callback(const char *func_name, void *func_ptr, int len_args, ...)
{
printf("Calling: %s (%d arguments)\n", func_name, len_args);
}
@@ -131,19 +131,19 @@ int main(void)
}
-void error_callback(int error, const char* description)
+internal void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
-void framebuffer_size_callback(GLFWwindow* window, int width, int height)
+internal void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
-void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
+internal void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
struct GameState* game_state = (struct GameState *)glfwGetWindowUserPointer(window);
@@ -190,7 +190,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
}
-time_t file_get_modified_time(char *file_path)
+internal time_t file_get_modified_time(char *file_path)
{
time_t mtime = 0;
struct stat file_status = {0};
@@ -208,7 +208,7 @@ time_t file_get_modified_time(char *file_path)
#ifdef PLATFORM_HOTLOAD_GAME_CODE
-void unload_game_code(struct GameCode *game_code)
+internal void unload_game_code(struct GameCode *game_code)
{
if (!game_code)
{
@@ -228,7 +228,7 @@ void unload_game_code(struct GameCode *game_code)
// TODO: Add backup dll in case loading fails
-struct GameCode load_game_code(char *source_lib_path)
+internal struct GameCode load_game_code(char *source_lib_path)
{
struct GameCode game_code = {0};
diff --git a/src/shader.c b/src/shader.c
@@ -1,4 +1,4 @@
-char *read_file(char *file_path)
+internal char *read_file(char *file_path)
{
FILE *handle = fopen(file_path, "r");
char *buffer = NULL;
@@ -35,7 +35,7 @@ char *read_file(char *file_path)
}
-struct Shader shader_compile(GLchar *vertex_path, GLchar *fragment_path)
+internal struct Shader shader_compile(GLchar *vertex_path, GLchar *fragment_path)
{
const GLchar *vertex_shader_source = read_file(vertex_path);
const GLchar *fragment_shader_source = read_file(fragment_path);
@@ -99,7 +99,7 @@ struct Shader shader_compile(GLchar *vertex_path, GLchar *fragment_path)
}
-void shader_use(struct Shader *s)
+internal void shader_use(struct Shader *s)
{
if (s)
{
@@ -112,7 +112,7 @@ void shader_use(struct Shader *s)
}
-void shader_setb(struct Shader *s, char *name, bool value)
+internal void shader_setb(struct Shader *s, char *name, bool value)
{
if (s)
{
@@ -125,7 +125,7 @@ void shader_setb(struct Shader *s, char *name, bool value)
}
-void shader_seti(struct Shader *s, char *name, int value)
+internal void shader_seti(struct Shader *s, char *name, int value)
{
if (s)
{
@@ -138,7 +138,7 @@ void shader_seti(struct Shader *s, char *name, int value)
}
-void shader_setf(struct Shader *s, char *name, f32 value)
+internal void shader_setf(struct Shader *s, char *name, f32 value)
{
if (s)
{
@@ -151,7 +151,7 @@ void shader_setf(struct Shader *s, char *name, f32 value)
}
-void shader_setm4(struct Shader *s, char *name, m4 *mat)
+internal void shader_setm4(struct Shader *s, char *name, m4 *mat)
{
if (s)
{
@@ -166,7 +166,7 @@ void shader_setm4(struct Shader *s, char *name, m4 *mat)
}
-void shader_setf3(struct Shader *s, char *name, f32 x, f32 y, f32 z)
+internal void shader_setf3(struct Shader *s, char *name, f32 x, f32 y, f32 z)
{
if (s)
{
@@ -179,7 +179,7 @@ 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)
+internal void shader_setf3_1(struct Shader *s, char *name, f32 f)
{
if (s)
{
@@ -192,7 +192,7 @@ void shader_setf3_1(struct Shader *s, char *name, f32 f)
}
-void shader_setv3(struct Shader *s, char *name, v3 *v)
+internal void shader_setv3(struct Shader *s, char *name, v3 *v)
{
if (s)
{
diff --git a/src/shader.h b/src/shader.h
@@ -3,13 +3,13 @@ struct Shader
u32 program;
};
-char *read_file(char *file_path);
-struct Shader shader_compile(GLchar *vertex_path, GLchar *fragment_path);
-void shader_use(struct Shader *s);
-void shader_setb(struct Shader *s, char *name, bool value);
-void shader_seti(struct Shader *s, char *name, int value);
-void shader_setf(struct Shader *s, char *name, f32 value);
-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);
+internal char *read_file(char *file_path);
+internal struct Shader shader_compile(GLchar *vertex_path, GLchar *fragment_path);
+internal void shader_use(struct Shader *s);
+internal void shader_setb(struct Shader *s, char *name, bool value);
+internal void shader_seti(struct Shader *s, char *name, int value);
+internal void shader_setf(struct Shader *s, char *name, f32 value);
+internal void shader_setm4(struct Shader *s, char *name, m4 *mat);
+internal void shader_setf3(struct Shader *s, char *name, f32 x, f32 y, f32 z);
+internal void shader_setf3_1(struct Shader *s, char *name, f32 f);
+internal void shader_setv3(struct Shader *s, char *name, v3 *v);