Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.o
libgl-matrix.a
.DS_Store
glmatrix.h
56 changes: 39 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,50 @@ LFLAGS=
LIB_PATH=/usr/local/lib
INCLUDE_PATH=/usr/local/include

all: vec3 mat3 mat4 quat str
ar -rcs libgl-matrix.a vec3.o mat3.o mat4.o quat.o str.o
SOURCES=vec2.c vec3.c vec4.c mat3.c mat4.c quat.c str.c
OBJECTS=$(SOURCES:.c=.o)

clean:
rm vec3.o mat3.o mat4.o quat.o str.o
rm libgl-matrix.a

vec3: vec3.c
$(CC) -c vec3.c $(CFLAGS) -o vec3.o
all: libgl-matrix.a glmatrix.h

mat3: mat3.c
$(CC) -c mat3.c $(CFLAGS) -o mat3.o
libgl-matrix.a: $(OBJECTS)
ar -rcs libgl-matrix.a $(OBJECTS)

mat4: mat4.c
$(CC) -c mat4.c $(CFLAGS) -o mat4.o
clean:
-rm $(OBJECTS)
-rm libgl-matrix.a
-rm glmatrix.h

quat: quat.c
$(CC) -c quat.c $(CFLAGS) -o quat.o
.c.o:
$(CC) -c $< $(CFLAGS) -o $@

str: str.c
$(CC) -c str.c $(CFLAGS) -o str.o
vec2.o: vec2.c gl-matrix.h
vec3.o: vec3.c gl-matrix.h
vec4.o: vec4.c gl-matrix.h
mat3.o: mat3.c gl-matrix.h
mat4.o: mat4.c gl-matrix.h
quat.o: quat.c gl-matrix.h
str.o: str.c gl-matrix.h

install:
cp libgl-matrix.a $(LIB_PATH)/libgl-matrix.a
cp gl-matrix.h $(INCLUDE_PATH)/gl-matrix.h
cp gl-matrix.h $(INCLUDE_PATH)/gl-matrix.h

# Single header file library
glmatrix.h: gl-matrix.h $(SOURCES)
@echo Generating $@
@echo '/* Single header library vector and matrix library.' > $@
@echo ' * You need to `#define GL_MATRIX_IMPLEMENTATION` in one of your source files' >> $@
@echo ' * Single header version which can be obtained at <https://github.com/wernsey/gl-matrix.c>' >> $@
@echo ' * Modified from the original C port by Marco Buono <https://github.com/coreh/gl-matrix.c>' >> $@
@echo " * Which was ported to C from Brandon Jones' original JavaScript version <https://github.com/toji/gl-matrix>" >> $@
@echo '' >> $@
@cat LICENSE >> $@
@echo '' >> $@
@echo ' */' >> $@
@cat gl-matrix.h >> $@
@echo '#ifdef GL_MATRIX_IMPLEMENTATION' >> $@
@echo '#include <stdio.h>' >> $@
@echo '#include <stdlib.h>' >> $@
@echo '#include <math.h>' >> $@
@sed '/#include.*$$/d' $(SOURCES) >> $@
@echo '#endif /* GL_MATRIX_IMPLEMENTATION */' >> $@
5 changes: 5 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
This was modified from Marco Buono's https://github.com/coreh/gl-matrix.c
to add support for `vec2_t`, `vec4_t` and single header file library.

The modifications are at https://github.com/wernsey/gl-matrix.c

This is a fairly straightforward port of gl-matrix.js (https://github.com/toji/gl-matrix)
from JavaScript to C.

Expand Down
Loading