Example #1
0
void					lst_print(t_lst *lst, void (*print_f)(void *), int mode)
{
	t_node				*cursor;
	size_t				i;
	size_t				lsize;

	cursor = lst_node_front(lst);
	i = 0;
	lsize = lst_get_size(lst);
	while (i++ < lsize)
	{
		if (mode == 1)
		{
			puts("----------");
			printf("Position : ");
			printf("%d\n", (int)(i - 1));
			printf("Data : ");
		}
		print_f(cursor->data);
		if (mode == 0)
			puts("");
		if (mode == 1)
			puts("\n----------");
		cursor = cursor->next;
	}
	if (mode == 1)
		print_size(lst);
}
Example #2
0
static void		fill_vertex_normal(const char **tokens, t_vertex *vertx, int nt)
{
	int			i;
	t_lst		*normals;
	t_vec3		*normal;

	normals = g_current_data->normals;
	i = token_to_int(tokens, 2);
	if (nt)
		i = token_to_int(tokens, 1);
	normal = lst_data_at(normals, i);
	if (normal)
	{
		vertx->normal.x = normal->x;
		vertx->normal.y = normal->y;
		vertx->normal.z = normal->z;
	}
	else if (i == DEFAULT_CODE || (i >= 0 && lst_get_size(normals) > (size_t)i))
	{
		vertx->normal.x = FLT_MAX;
		vertx->normal.y = FLT_MAX;
		vertx->normal.z = FLT_MAX;
	}
	else
		parser_die("Invalid index for normal.");
}
Example #3
0
void			fill_infos(void)
{
	struct winsize	ws;
	INF				*infos;

	infos = get_infos();
	if (infos->fd == 0)
		infos->fd = open(ttyname(0), O_WRONLY);
	if (!infos->load_cap)
		enable_env();
	ioctl(infos->fd, TIOCGWINSZ, &ws);
	infos->nb_lines = ws.ws_row - 3;
	infos->nb_params = lst_get_size(lst_get_first());
	infos->col_size = lst_get_size_line(lst_get_first()) + 5;
	infos->height = ws.ws_row;
	infos->width = ws.ws_col;
	check_size(infos);
	set_params(*(lst_get_first()), infos);
}
Example #4
0
static void		fill_vertex_color(const char **tokens, t_vertex *vertex, int nt)
{
	int			i;
	t_lst		*colors;
	t_vec2		*color;

	colors = g_current_data->uvs;
	i = DEFAULT_CODE;
	if (!nt)
		i = token_to_int(tokens, 1);
	color = lst_data_at(colors, i);
	if (color)
	{
		vertex->uv.x = color->x;
		vertex->uv.y = color->y;
	}
	else if (i == DEFAULT_CODE || (i >= 0 && lst_get_size(colors) > (size_t)i))
	{
		vertex->uv.x = FLT_MAX;
		vertex->uv.y = FLT_MAX;
	}
	else
		parser_die("Invalid index for color.");
}
Example #5
0
static void		fill_vertex_position(const char **tokens, t_vertex *vertex)
{
	int			index;
	t_lst		*positions;
	t_vec3		*pos;

	index = token_to_int(tokens, 0);
	positions = g_current_data->positions;
	pos = lst_data_at(positions, index);
	if (pos)
	{
		vertex->position.x = pos->x;
		vertex->position.y = pos->y;
		vertex->position.z = pos->z;
	}
	else if (index >= 0 && lst_get_size(positions) > (size_t)index)
	{
		vertex->position.x = FLT_MAX;
		vertex->position.y = FLT_MAX;
		vertex->position.z = FLT_MAX;
	}
	else
		parser_die("Invalid index for a position.");
}
Example #6
0
static void				print_size(t_lst *lst)
{
	printf("Total size : ");
	printf("%d\n", (int)lst_get_size(lst));
}