scop/inc/scop.h

110 lines
2.5 KiB
C
Raw Normal View History

2020-12-22 18:15:25 +00:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* scop.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbrochar <gbrochar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/22 12:08:22 by gbrochar #+# #+# */
/* Updated: 2020/12/22 19:13:41 by gbrochar ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SCOP_H
# define SCOP_H
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# define SUCCESS 0
# define FAILURE -1
# define BREAK 1
# define TRUE 1
# define FALSE 0
typedef enum e_gl_buf_type t_gl_buf_type;
enum e_gl_buf_type
{
VERTEX,
UV,
NORMAL,
INDEX,
OTHER
};
typedef struct s_cam t_cam;
typedef struct s_window t_window;
typedef struct s_buf_d t_buf_d;
typedef struct s_buf_i t_buf_i;
typedef struct s_buf_s t_buf_s;
typedef struct s_obj t_obj;
typedef struct s_env t_env;
struct s_cam
{
double fov;
double aspect;
double near;
double far;
};
struct s_window
{
int width;
int height;
};
struct s_buf_d
{
double *data;
};
struct s_buf_i
{
int *data;
};
struct s_buf_s
{
short *data;
};
struct s_obj
{
t_buf_d vertices;
t_buf_d uvs;
t_buf_d normals;
t_buf_s indices;
int vertices_ptr;
int uvs_ptr;
int normals_ptr;
int indices_ptr;
};
struct s_env
{
char *file_name;
t_cam camera;
t_window window;
t_obj object;
};
int parse(t_env *e, int argc, char **argv);
void set_params(t_env *e, int argc, char **argv);
int parse_file(t_env *e);
int parse_line(t_env *e, char *line);
t_gl_buf_type parse_gl_buf_type(char *token);
int parse_append_data_d(t_buf_d *buffer, char *token);
int parse_append_data_s(t_buf_s *buffer, char *token);
void free_env(t_env *e);
void init_window(t_env *e);
void init_camera(t_env *e);
void init_object(t_env *e);
void init_env(t_env *e);
#endif