From 6623e7fbdb4307536d3f5920c267c74f8bc6a989 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 11 May 2020 02:19:18 +0200 Subject: Generating triangles for polygon face in .obj file, opengl error/initialisation --- src/parse.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/parse.c') diff --git a/src/parse.c b/src/parse.c index fa9f2b5..b83d9e8 100644 --- a/src/parse.c +++ b/src/parse.c @@ -6,27 +6,37 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/05/09 11:02:00 by charles #+# #+# */ -/* Updated: 2020/05/10 22:04:05 by charles ### ########.fr */ +/* Updated: 2020/05/11 01:29:13 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "scop.h" -#define SCOP_VEC_DEFAULT_SIZE 32 +#define SCOP_VEC_DEFAULT_SIZE 64 static int st_parse_face(char **indexes_strs, t_ftvec *indices) { size_t i; size_t len; + unsigned int first; unsigned int tmp; len = ft_split_len(indexes_strs); - i = -1; - while (++i < len) + first = ft_atoi(indexes_strs[0]); + /* if (ft_vecpush(indices, *(void**)&first) == NULL) */ + /* return (-1); */ + i = 1; + while (i < len - 1) { + if (ft_vecpush(indices, *(void**)&first) == NULL) + return (-1); tmp = ft_atoi(indexes_strs[i]); if (ft_vecpush(indices, *(void**)&tmp) == NULL) return (-1); + tmp = ft_atoi(indexes_strs[i + 1]); + if (ft_vecpush(indices, *(void**)&tmp) == NULL) + return (-1); + i++; } return (0); } -- cgit