diff --git a/.gitmodules b/.gitmodules index 97b2b40..662a95b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "ext/glfw"] path = ext/glfw url = https://github.com/glfw/glfw +[submodule "ext/nuklear"] + path = ext/nuklear + url = https://github.com/Immediate-Mode-UI/Nuklear diff --git a/Makefile b/Makefile index 4f2f2d6..3e4dcce 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ OBJ = \ CFLAGS = \ -I./ext/cglm/include \ -I./ext/glfw/include \ - -Wall -Wno-unused-function -std=c99 -D_GNU_SOURCE \ + -Wall -Wno-unused-function -std=c99 -D_POSIX_C_SOURCE \ WAYLAND-LIB = \ xdg-shell \ @@ -31,8 +31,7 @@ help: @echo "Para compilar el proyecto a tu sistema operativo" @echo "porfavor usa uno de los siguientes comandos:" @echo " $(MAKE) windows" - @echo " $(MAKE) linux-x11" - @echo " $(MAKE) linux-wayland" + @echo " $(MAKE) linux" @echo " $(MAKE) cocoa" @echo "Para limpiar los archivos compilados se puede usar" @echo " $(MAKE) clean" @@ -49,17 +48,13 @@ glfw.dll: $(CC) -fPIC -shared -D_GLFW_WIN32 -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o $@ -lgdi32 # LINUX -linux-x11: $(OBJ) - $(MAKE) BKN=_GLFW_X11 libglfw.so - $(CC) -o $(BIN) $(OBJ) -L. -lGLEW -lGL -lglfw -lm - -linux-wayland: $(OBJ) +linux: $(OBJ) for i in $(WAYLAND-LIB); \ do \ wayland-scanner client-header ext/glfw/deps/wayland/$$i.xml ext/glfw/deps/wayland/$$i-client-protocol.h; \ wayland-scanner private-code ext/glfw/deps/wayland/$$i.xml ext/glfw/deps/wayland/$$i-client-protocol-code.h; \ done - $(MAKE) BKN=_GLFW_WAYLAND libglfw.so + $(MAKE) DFLAGS="-D_GLFW_WAYLAND -D_GLFW_X11" libglfw.so $(CC) -o $(BIN) $(OBJ) -L. -lGLEW -lGL -lglfw -lm run-linux: @@ -67,11 +62,11 @@ run-linux: # COCOA cocoa: $(OBJ) - $(MAKE) BKN=_GLFW_COCOA libglfw.so + $(MAKE) DFLAGS="-D_GLFW_COCOA" libglfw.so $(CC) -framework OpenGL -o $(BIN) $(OBJ) -L. -lGLEW -lGL -lglfw libglfw.so: - $(CC) -fPIC -shared -D$(BKN) -D_GLFW_BUILD_DLL -Iext/glfw/deps/wayland ./ext/glfw/src/*.c -o $@ + $(CC) -fPIC -shared $(DFLAGS)-D_GLFW_BUILD_DLL -Iext/glfw/deps/wayland ./ext/glfw/src/*.c -o $@ clean: rm $(OBJ) $(BIN) ext/glfw/deps/wayland/*.h diff --git a/README.md b/README.md index 3d19d24..a69920c 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,8 @@ Para poder compilar el proyecto hace falta lo siguiente. - `glfw`: A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input. - `cglm`: Highly Optimized 2D / 3D Graphics Math (glm) for C. ### Linux -Para compilar `glfw` en linux hacen falta las siguientes librerías según el caso. (no incluidas) -- `x11`: libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel -- `wayland`: libwayland-dev libxkbcommon-dev wayland-protocols +Para compilar `glfw` en linux hacen falta las siguientes librerías. (no incluidas) +- libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel libwayland-dev libxkbcommon-dev wayland-protocols # Descargas - [git](https://git-scm.com/downloads/win) @@ -43,8 +42,7 @@ Los siguientes comandos sirven para compilar `manigraph` deacuerdo al sistema op ``` make windows -make linux-x11 -make linux-wayland +make linux make cocoa ``` @@ -62,8 +60,7 @@ cc -fPIC -shared -D_GLFW_WIN32 -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o glfw.dll #### Linux ``` -cc -fPIC -shared -D_GLFW_X11 -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o libglfw.so -cc -fPIC -shared -D_GLFW_WAYLAND -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o libglfw.so +cc -fPIC -shared -D_GLFW_X11 -D_GLFW_WAYLAND -D_GLFW_BUILD_DLL ./ext/glfw/src/*.c -o libglfw.so ``` #### Mac diff --git a/ext/nuklear b/ext/nuklear new file mode 160000 index 0000000..6566d90 --- /dev/null +++ b/ext/nuklear @@ -0,0 +1 @@ +Subproject commit 6566d9075d5fed48af014c93f87c4aed8c4bd21c diff --git a/src/mesh.c b/src/mesh.c index 0150b5f..83c38bf 100644 --- a/src/mesh.c +++ b/src/mesh.c @@ -25,7 +25,7 @@ void set_projection_mesh(struct projection projection) glVertexAttribPointer(3, 1, GL_FLOAT, 0, projection.m * sizeof(float), (float *)(projection.w * sizeof(float))); - glBindBuffer(GL_ARRAY_BUFFER, p->n_vbo); + glBindBuffer(GL_UNIFORM_BUFFER, p->n_vbo); glVertexAttribPointer(4, 1, GL_FLOAT, 0, projection.m * sizeof(float), (float *)(projection.x * sizeof(float))); glVertexAttribPointer(5, 1, GL_FLOAT, 0, projection.m * sizeof(float), @@ -63,8 +63,8 @@ mesh_t create_mesh(float *d, float *n, unsigned char m) if (n) { glGenBuffers(1, &p->n_vbo); - glBindBuffer(GL_ARRAY_BUFFER, p->n_vbo); - glBufferData(GL_ARRAY_BUFFER, p->vertex * m * sizeof(float), n + 1, + glBindBuffer(GL_UNIFORM_BUFFER, p->n_vbo); + glBufferData(GL_UNIFORM_BUFFER, p->vertex * m * sizeof(float), n + 1, GL_STATIC_DRAW); } diff --git a/src/texture.c b/src/texture.c index e4e11dc..fb1bfd8 100644 --- a/src/texture.c +++ b/src/texture.c @@ -25,7 +25,7 @@ void destroy_texture(unsigned int texture) return glDeleteTextures(1, &texture); } -id_t create_palette_texture(const unsigned char *colors, unsigned char n) +id_t create_palette_texture(const unsigned char colors[][4], unsigned char n) { id_t texture = __config_texture(TYPE); glTexImage3D(