Fix #17, Add nuklear, Unified linux compilation

This commit is contained in:
PedroEdiaz
2024-10-27 16:09:29 -06:00
parent 3fa4eed366
commit 8c565ffd25
6 changed files with 18 additions and 22 deletions

3
.gitmodules vendored
View File

@@ -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

View File

@@ -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

View File

@@ -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

1
ext/nuklear Submodule

Submodule ext/nuklear added at 6566d9075d

View File

@@ -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);
}

View File

@@ -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(