2020-12-22 18:15:25 +00:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* env.c :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: gbrochar <gbrochar@student.42.fr> +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2020/12/22 18:56:21 by gbrochar #+# #+# */
|
2020-12-23 20:27:00 +00:00
|
|
|
/* Updated: 2020/12/23 21:14:28 by gbrochar ### ########.fr */
|
2020-12-22 18:15:25 +00:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#include "scop.h"
|
|
|
|
|
|
|
|
void free_env(t_env *e)
|
|
|
|
{
|
|
|
|
free(e->file_name);
|
|
|
|
free(e->object.vertices.data);
|
|
|
|
free(e->object.uvs.data);
|
|
|
|
free(e->object.normals.data);
|
|
|
|
free(e->object.indices.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_window(t_env *e)
|
|
|
|
{
|
|
|
|
e->window.width = 640;
|
|
|
|
e->window.height = 480;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_camera(t_env *e)
|
|
|
|
{
|
|
|
|
e->camera.fov = 45;
|
|
|
|
e->camera.near = 0.001;
|
|
|
|
e->camera.far = 1000;
|
|
|
|
e->camera.aspect = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_object(t_env *e)
|
|
|
|
{
|
2020-12-22 19:16:36 +00:00
|
|
|
e->object.vertices.data = (double *)malloc(sizeof(double) * BUFFER_SIZE);
|
|
|
|
e->object.uvs.data = (double *)malloc(sizeof(double) * BUFFER_SIZE);
|
|
|
|
e->object.normals.data = (double *)malloc(sizeof(double) * BUFFER_SIZE);
|
2020-12-23 20:27:00 +00:00
|
|
|
e->object.indices.data = (unsigned int *)malloc(
|
|
|
|
sizeof(unsigned int) * BUFFER_SIZE);
|
2020-12-22 19:16:36 +00:00
|
|
|
e->object.vertices.ptr = 0;
|
|
|
|
e->object.uvs.ptr = 0;
|
|
|
|
e->object.normals.ptr = 0;
|
|
|
|
e->object.indices.ptr = 0;
|
|
|
|
e->object.vertices.len = BUFFER_SIZE;
|
|
|
|
e->object.uvs.len = BUFFER_SIZE;
|
|
|
|
e->object.normals.len = BUFFER_SIZE;
|
|
|
|
e->object.indices.len = BUFFER_SIZE;
|
2020-12-22 18:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void init_env(t_env *e)
|
|
|
|
{
|
|
|
|
init_window(e);
|
|
|
|
init_camera(e);
|
|
|
|
init_object(e);
|
|
|
|
}
|