polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit 5aaec6dc22b175a81b37507158676f22ba1062d5
parent 08d4282d319a787d2bde6c624156194640a6fad3
Author: William Casarin <jb55@jb55.com>
Date:   Sat, 24 Jul 2021 11:21:59 -0700

wasm

Diffstat:
MMakefile | 7++++---
Mmain.c | 1+
Msrc/debug.h | 2++
Msrc/game.h | 2++
Msrc/gl.h | 4+++-
Msrc/hires.c | 2+-
Msrc/input.h | 2+-
Msrc/mdl.h | 2++
8 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile @@ -7,8 +7,7 @@ DEFS= -DGLFW_INCLUDE_NONE -DDEBUG # CFLAGS = $(DEFS) -ggdb -O0 -I src -Wall -Wextra -std=c99 \ -CFLAGS = $(shell pkg-config --cflags sdl2 gl) \ - $(DEFS) -O1 -g -I src -Wall -Werror -Wextra -std=c99 \ +CFLAGS = $(DEFS) -O1 -g -I src -Wall -Werror -Wextra -std=c99 \ -Wno-unused-function \ -Wno-unused-parameter \ -Wno-unused-variable \ @@ -16,6 +15,8 @@ CFLAGS = $(shell pkg-config --cflags sdl2 gl) \ -Wno-cast-align \ -Wno-padded +EMSCRIPTEN=-I$(shell nix-instantiate --eval --expr 'with import <nixpkgs> {}; "${'"$1"'}"' | sed 's/"//g') + LDFLAGS = -lSDL2 -lGL -lm SRC=src @@ -70,7 +71,7 @@ $(BIN): main.o $(OBJS) @$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ $(BIN).wasm: main.c $(SRCS) - emcc $(CFLAGS) $^ -s WASM=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -o $@ + emcc -I$(EMSCRIPTEN)/share/emscripten/system/include $(CFLAGS) $^ -s WASM=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -o $@ install: $(BIN) install -d $(PREFIX)/bin diff --git a/main.c b/main.c @@ -22,6 +22,7 @@ +#include <stdio.h> #include <assert.h> #include <time.h> diff --git a/src/debug.h b/src/debug.h @@ -4,6 +4,8 @@ #include "gl.h" +#include <stdio.h> + void show_info_log(GLuint shader); // rtassert exists in release builds, use sparingly diff --git a/src/game.h b/src/game.h @@ -15,6 +15,8 @@ #include "texture.h" #include "ui.h" +#include <stdio.h> + #define PLAYER_HEIGHT 1.73 #define MAX_PROGRAMS 12 diff --git a/src/gl.h b/src/gl.h @@ -2,10 +2,12 @@ #define POLYADVENT_GL_H /* #include <epoxy/gl.h> */ -#include <SDL.h> +#include <SDL/SDL.h> #include <GL/gl.h> +/* #include <GL/glx.h> #include <GL/glext.h> +*/ void glGenBuffers(GLsizei n, GLuint * buffers); void glGetShaderiv(GLuint shader, GLenum pname, GLint *params); diff --git a/src/hires.c b/src/hires.c @@ -1,7 +1,7 @@ #include <time.h> #include "common.h" -#include <SDL.h> +#include <SDL/SDL.h> double hires_time_in_seconds() { double ticks_per_sec = (double)SDL_GetPerformanceFrequency(); diff --git a/src/input.h b/src/input.h @@ -3,7 +3,7 @@ #ifndef POLYADVENT_INPUT_H #define POLYADVENT_INPUT_H -#include <SDL.h> +#include <SDL/SDL.h> #include "common.h" /* enum key_state { */ diff --git a/src/mdl.h b/src/mdl.h @@ -5,6 +5,8 @@ #include "geometry.h" #include "model.h" +#include <stdio.h> + enum mdl_tag { MDL_POSITION = 1, MDL_NORMAL,