transparent-cube

Minimal cross-platform native/wasm graphics example.
git clone git://git.amin.space/transparent-cube.git
Log | Files | Refs | README | LICENSE

commit 0f78c5c0fc6764dbd0e5760c510273c2a145797b
parent 3f3078509ffe54340c759c36f838702f5f0412f9
Author: amin <dev@aminmesbah.com>
Date:   Sat, 15 Jun 2019 22:18:08 +0000

Switch to unity build

FossilOrigin-Name: 37fa6a4ce393ba8e816487821b0c699fbc7adb7fbd0cb5d9d8c3f49db55a8377
Diffstat:
MMakefile | 6+++---
Msrc/game.c | 11++++-------
Msrc/game.h | 12++++++++----
Msrc/glmth.h | 12+-----------
Msrc/shader.c | 7-------
Msrc/shader.h | 11+----------
6 files changed, 17 insertions(+), 42 deletions(-)

diff --git a/Makefile b/Makefile @@ -2,11 +2,11 @@ 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 glad.c platform_linux.c shader.c +SRC_FILES = game.c platform_linux.c SRC = $(addprefix src/, $(SRC_FILES)) EXE_FILE = quaternion_demo -LIB_FILES = game.c glad.c shader.c +LIB_FILES = game.c LIB = $(addprefix src/, $(LIB_FILES)) LIB_NAME = game.so @@ -20,7 +20,7 @@ RELLIB = $(RELDIR)/$(LIB_NAME) RELLIBTMP = $(RELLIB).tmp RELCFLAGS = -DPLATFORM_HOTLOAD_GAME_CODE -O2 -Os -EMS_FILES = game.c platform_emscripten.c shader.c +EMS_FILES = game.c platform_emscripten.c EMSSRC = $(addprefix src/, $(EMS_FILES)) EMSDIR = build/emscripten EMSEXE = $(EMSDIR)/$(EXE_FILE).html diff --git a/src/game.c b/src/game.c @@ -1,15 +1,12 @@ #include "game.h" -#include <assert.h> -#include <math.h> - // TODO: remove references to emscripten -#ifdef __EMSCRIPTEN__ -#include <GLES3/gl3.h> -#else -#include "glad/glad.h" +#ifndef __EMSCRIPTEN__ +#include "glad.c" #endif +#include "shader.c" + #ifdef PLATFORM_HOTLOAD_GAME_CODE void game_load_opengl_symbols(void) { diff --git a/src/game.h b/src/game.h @@ -1,5 +1,11 @@ -#ifndef GAME_H -#define GAME_H +#pragma once + +#include <assert.h> +#include <math.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> // TODO: remove references to emscripten #ifdef __EMSCRIPTEN__ @@ -33,5 +39,3 @@ void game_update_and_render(struct GameState *game_state, float dt, uint32_t scr void game_init(struct GameState *game_state, uint32_t screen_width, uint32_t screen_height); void game_cleanup(struct GameState *game_state); - -#endif diff --git a/src/glmth.h b/src/glmth.h @@ -1,12 +1,4 @@ -#ifndef GLMTH_H -#define GLMTH_H - -#include <assert.h> -#include <math.h> -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> +#pragma once #ifndef M_PI #define M_PI 3.14159265359f @@ -239,5 +231,3 @@ inline m4 glmth_projection_perspective_fov(f32 fovy, f32 aspect, f32 near, f32 f return glmth_projection_perspective(left, right, bottom, top, near, far); } - -#endif diff --git a/src/shader.c b/src/shader.c @@ -1,12 +1,5 @@ #include "shader.h" -#ifdef __EMSCRIPTEN__ -#include <GLES3/gl3.h> -#else -#include "glad/glad.h" -#endif - - char *read_file(char *file_path) { FILE *handle = fopen(file_path, "r"); diff --git a/src/shader.h b/src/shader.h @@ -1,11 +1,4 @@ -#ifndef SHADER_H -#define SHADER_H - -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> - -#include "glmth.h" +#pragma once struct Shader { @@ -22,5 +15,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