diff --git a/Makefile b/Makefile index dbdeadd..fe78659 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ CFLAGS = \ -I./ext/glfw/include \ -Wall -Wno-unused-function -std=c89 -all: $(DOC) $(BIN) $(LIB) +all: $(BIN) $(LIB) $(BIN): $(OBJ) $(LIB) $(CC) -lGL -lglfw -L. -o $(BIN) $(OBJ) @@ -39,10 +39,13 @@ clean: clean-all: rm $(OBJ) $(DOC) $(LIB) $(BIN) -.SUFFIXES: .ms .pdf .c .o +.SUFFIXES: .ms .pdf .html .c .o .ms.pdf: - cat $< | sed -e "s/^\s*//g" -e "/^$$/d" | groff -Tpdf -fC -ms > $@ + cat $< | sed -e "s/^\s*//g" -e "/^$$/d" | tbl| groff -Tpdf -fC -ms > $@ + +.ms.html: + cat $< | sed -e "s/^\s*//g" -e "/^$$/d"| tbl | groff -Thtml -fC -ms > $@ .c.o: $(CC) $(CFLAGS) $< -c -o $@ diff --git a/src/input.c b/src/input.c new file mode 100644 index 0000000..fb272d1 --- /dev/null +++ b/src/input.c @@ -0,0 +1,58 @@ +#include +#include "main.h" +#define inline +#include + +#define ANGLE ((float)0x01/0xff*2*GLM_PI) + +versor q = GLM_QUAT_IDENTITY_INIT; +vec3 axis[3] = +{ + {1,0,0}, + {0,1,0}, + {0,0,1}, +}; + +float * poll_input( window_t window ) +{ + versor p = GLM_QUAT_IDENTITY_INIT; + + if( glfwGetKey( (void*)window, 'Q' ) == GLFW_PRESS ) + { + glm_quatv( p, ANGLE, axis[0] ); + goto end; + } + if( glfwGetKey( (void*)window, 'W' ) == GLFW_PRESS ) + { + glm_quatv( p, -ANGLE, axis[0] ); + goto end; + } + + if( glfwGetKey( (void*)window, 'A' ) == GLFW_PRESS ) + { + glm_quatv( p, ANGLE, axis[1] ); + goto end; + } + if( glfwGetKey( (void*)window, 'S' ) == GLFW_PRESS ) + { + glm_quatv( p, -ANGLE, axis[1] ); + goto end; + } + + if( glfwGetKey( (void*)window, 'Z' ) == GLFW_PRESS ) + { + glm_quatv( p, ANGLE, axis[2] ); + goto end; + } + if( glfwGetKey( (void*)window, 'X' ) == GLFW_PRESS ) + { + glm_quatv( p, -ANGLE, axis[2] ); + goto end; + } +end: + glm_quat_mul( p, q, q ); + glm_quat_rotatev( p, axis[0], axis[0] ); + glm_quat_rotatev( p, axis[1], axis[1] ); + glm_quat_rotatev( p, axis[2], axis[2] ); + return q; +}