diff --git a/.gitmodules b/.gitmodules index e396f64..1f14a97 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "webgl"] path = webgl url = https://git.gaetanbrochard.dev/gbrochar/webgl +[submodule "libft"] + path = libft + url = https://git.gaetanbrochard.dev/gbrochar/libft.git diff --git a/Makefile b/Makefile index b067644..8d02c09 100644 --- a/Makefile +++ b/Makefile @@ -41,11 +41,11 @@ SRC = $(addprefix $(SRC_DIR), $(SRC_FILE)) OBJ = $(addprefix $(OBJ_DIR), $(OBJ_FILE)) INC = $(addprefix $(INC_DIR), $(INC_FILE)) -LIB = -lm -lGL -lglfw glew-2.2.0/lib/libGLEW.a +LIB = -lm -lGL -lglfw glew-2.2.0/lib/libGLEW.a libft/libft.a CC = gcc -CFLAGS = -Wall -Werror -Wextra -g3 +CFLAGS = -Wall -Werror -Wextra RED = \033[31m GREEN = \033[32m @@ -58,6 +58,7 @@ all: $(NAME) $(NAME): $(OBJ) $(INC) @make -C glew-2.2.0 + @make -C libft @$(CC) $(CFLAGS) -c $(SRC) -I $(INC_DIR) -I glew-2.2.0/include/ @mv $(OBJ_FILE) $(OBJ_DIR) @$(CC) $(CFLAGS) $(OBJ) -o $(NAME) $(LIB) @@ -71,11 +72,13 @@ $(OBJ_DIR)%.o: $(SRC_DIR)%.c inc/ @echo -e "$(CYAN)[CC]$(WHITE) $<" clean: + @make -C libft clean @rm -rf $(OBJ_DIR) @echo -e "$(RED)[REMOVED]$(WHITE) obj files" fclean: clean @make -C glew-2.2.0 clean + @make -C libft fclean @rm -f $(NAME) @echo -e "$(RED)[REMOVED]$(WHITE) $(NAME)" diff --git a/inc/scop.h b/inc/scop.h index d5a5e33..40ae934 100644 --- a/inc/scop.h +++ b/inc/scop.h @@ -1,6 +1,7 @@ #ifndef SCOP_H # define SCOP_H +# include "../libft/libft.h" # include # include # include diff --git a/libft b/libft new file mode 160000 index 0000000..1ab0cdf --- /dev/null +++ b/libft @@ -0,0 +1 @@ +Subproject commit 1ab0cdf1acf97db0cb8d90940c96a6f1ccb3a7af diff --git a/src/parse_line.c b/src/parse_line.c index 8534b46..c450c9a 100644 --- a/src/parse_line.c +++ b/src/parse_line.c @@ -107,7 +107,7 @@ void parse_triangulate_dispatcher(t_env *e, int vertex_count) { } void strtrim(char *line) { - size_t i = strlen(line) - 1; + size_t i = ft_strlen(line) - 1; while (isspace(line[i])) { line[i] = '\0'; i--; diff --git a/src/parse_token.c b/src/parse_token.c index cb3b77a..62d0b53 100644 --- a/src/parse_token.c +++ b/src/parse_token.c @@ -44,15 +44,15 @@ int parse_append_data_index(t_env *e, char *phrase) { int ret; while ((token = strtok_r(phrase, "/", &phrase))) { - if (strlen(token) > 0 && token_count == 0) { + if (ft_strlen(token) > 0 && token_count == 0) { e->object.properties |= VERTEX_FLAG; ret = parse_append_data_ui(&(e->object.vertices_indices), token); } - else if (strlen(token) > 0 && token_count == 1) { + else if (ft_strlen(token) > 0 && token_count == 1) { e->object.properties |= UV_FLAG; ret = parse_append_data_ui(&(e->object.uvs_indices), token); } - else if (strlen(token) > 0 && token_count == 2) { + else if (ft_strlen(token) > 0 && token_count == 2) { e->object.properties |= NORMAL_FLAG; ret = parse_append_data_ui(&(e->object.normals_indices), token); } diff --git a/src/run.c b/src/run.c index ddd3e21..cbf9b43 100644 --- a/src/run.c +++ b/src/run.c @@ -167,7 +167,7 @@ static void AddShader(GLuint ShaderProgram, const char* pShaderText, GLenum Shad const GLchar* p[1]; p[0] = pShaderText; GLint Lengths[1]; - Lengths[0] = strlen(pShaderText); + Lengths[0] = ft_strlen(pShaderText); glShaderSource(*shader, 1, p, Lengths); glCompileShader(*shader); GLint success;