diff --git a/Makefile b/Makefile index f44fbc0..8962547 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ EXAMPLES = \ example/basic \ example/riemman \ example/n-cube \ + example/n-hilbert-cube \ example/lens CFLAGS = \ @@ -24,17 +25,6 @@ CFLAGS = \ -I./include \ -Wall -Wno-unused-function -std=c99 -D_GNU_SOURCE \ -WAYLAND-LIB = \ - xdg-shell \ - relative-pointer-unstable-v1 \ - xdg-decoration-unstable-v1 \ - pointer-constraints-unstable-v1 \ - viewporter \ - idle-inhibit-unstable-v1 \ - fractional-scale-v1 \ - xdg-activation-v1 \ - wayland - help: @echo "Usage:" @echo " $(MAKE) windows" @@ -59,11 +49,11 @@ glfw.dll: # LINUX linux-wayland: $(OBJ) cd ext; $(MAKE) -f glfw.mk linux-wayland; cd - - $(CC) -o $(BIN) $(OBJ) ext/libglfw.a -lGL -lm + $(CC) -o $(BIN) $(OBJ) ext/libglfw.a -lm linux-x11: $(OBJ) cd ext; $(MAKE) -f glfw.mk linux-x11; cd - - $(CC) -o $(BIN) $(OBJ) ext/libglfw.a -lGL -lm + $(CC) -o $(BIN) $(OBJ) ext/libglfw.a -lm cocoa: $(OBJ) cd ext; $(MAKE) -f glfw.mk cocoa; cd - @@ -73,9 +63,6 @@ wasm: $(OBJ) $(CC) -sUSE_WEBGL2=1 -sUSE_GLFW=3 -o $(BIN).html $(OBJ) chmod -x $(BIN).wasm -libglfw.so: - $(CC) -fPIC -shared $(DFLAGS) -D_GLFW_BUILD_DLL -Iext/glfw/deps/wayland ./ext/glfw/src/*.c -o $@ - clean: rm $(OBJ) $(BIN) $(EXAMPLES) cd ext; $(MAKE) -f glfw.mk clean; cd - @@ -89,5 +76,4 @@ examples: $(EXAMPLES) $(CC) -Wno-implicit-function-declaration $(CFLAGS) -c -o $@ $< .c: - $(CC) -lm -Wno-implicit-function-declaration $(CFLAGS) -c -o $@ $< - + $(CC) -I include -o $@ $< -lm diff --git a/include/klein/klein.h b/include/klein/klein.h index 6265adf..663c8f1 100644 --- a/include/klein/klein.h +++ b/include/klein/klein.h @@ -39,8 +39,8 @@ int klein_export_file(struct klein klein, const char * filename) fwrite("\0", 1, 1, file); fwrite(&klein.dim, 1, 1, file); fwrite(&klein.vertex_size, 8, 1, file); - fwrite(klein.vertex, 16, klein.vertex_size * klein.dim, file); - fwrite(klein.normals, 16, klein.vertex_size * klein.dim, file); + fwrite(klein.vertex, 4, klein.vertex_size * klein.dim, file); + fwrite(klein.normals, 4, klein.vertex_size * klein.dim, file); fclose(file); return 0; diff --git a/src/input.c b/src/input.c index 8a0f1a8..9a4f60e 100644 --- a/src/input.c +++ b/src/input.c @@ -1,4 +1,5 @@ #include "main.h" +#include #include #include #include @@ -21,6 +22,12 @@ vec3 axis[3] = { extern struct projection projection; +void __error_callback_input(int x, const char * msg ) +{ + mlog("[GLFW] "); + mlog(msg); + mlog("\n"); +} void __key_callback_input( GLFWwindow *window, int key, int scancode, int action, int mods) { diff --git a/src/klein.c b/src/klein.c index 8add64b..f2a747d 100644 --- a/src/klein.c +++ b/src/klein.c @@ -35,10 +35,10 @@ int create_surface_klein(unsigned char *path, struct surface *surface) size = surface->dim * surface->vertex; - surface->data = malloc(16 * size); - fread(surface->data, 16, size, file); + surface->data = malloc(4 * size); + fread(surface->data, 4, size, file); - surface->norm = malloc(16 * size); - fread(surface->norm, 16, size, file); + surface->norm = malloc(4 * size); + fread(surface->norm, 4, size, file); return 0; } diff --git a/src/main.h b/src/main.h index 6ae5ebd..8e62051 100644 --- a/src/main.h +++ b/src/main.h @@ -5,6 +5,7 @@ */ #define DEBUG +#define GLFW_INCLUDE_NONE typedef const void *window_t; typedef unsigned int id_t; diff --git a/src/window.c b/src/window.c index 521e673..97bf753 100644 --- a/src/window.c +++ b/src/window.c @@ -8,6 +8,7 @@ void __mouse_callback_input(GLFWwindow *, int, int, int); void __scroll_callback_input(GLFWwindow *, double, double); void __key_callback_input(GLFWwindow *, int, int, int, int); void __drop_callback_input(GLFWwindow *, int, const char **); +void __error_callback_input(int, const char *); window_t init_window(unsigned int w, unsigned int h, const char *name); @@ -44,6 +45,7 @@ static void __limit_fps_window(int max_fps) window_t init_window(unsigned int width, unsigned int height, const char *title) { window_t window; + glfwSetErrorCallback(__error_callback_input); if (!glfwInit()) return NULL; @@ -51,6 +53,7 @@ window_t init_window(unsigned int width, unsigned int height, const char *title) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, 1); window = (window_t)glfwCreateWindow(width, height, title, NULL, NULL); if (!(window)) @@ -67,8 +70,6 @@ window_t init_window(unsigned int width, unsigned int height, const char *title) glfwSetKeyCallback((GLFWwindow *)window, __key_callback_input); glfwSetDropCallback((GLFWwindow *)window, __drop_callback_input); - __window_callback_input((GLFWwindow *)window, width, height); - return window; }