scop/inc/scop.h

116 lines
2.0 KiB
C
Raw Permalink Normal View History

2020-12-22 18:15:25 +00:00
#ifndef SCOP_H
# define SCOP_H
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
2020-12-23 21:23:23 +00:00
# include <assert.h>
# include <math.h>
2024-04-25 08:20:20 +00:00
# include <float.h>
# include <GL/glew.h>
2020-12-25 13:58:25 +00:00
# include <GLFW/glfw3.h>
2020-12-26 08:48:19 +00:00
# include "vec3.h"
2020-12-22 18:15:25 +00:00
# define SUCCESS 0
# define FAILURE -1
# define BREAK 1
# define TRUE 1
# define FALSE 0
2020-12-22 19:16:36 +00:00
# define BUFFER_SIZE 4096
2020-12-23 16:06:42 +00:00
# define EPSILON 0.000001
2024-04-24 18:40:56 +00:00
typedef enum e_gl_buf_type t_gl_buf_type;
2020-12-22 18:15:25 +00:00
2024-04-24 18:40:56 +00:00
enum e_gl_buf_type {
2020-12-22 18:15:25 +00:00
VERTEX,
UV,
NORMAL,
INDEX,
OTHER
};
2024-04-24 18:40:56 +00:00
typedef struct s_cam t_cam;
typedef struct s_window t_window;
typedef struct s_buf_d t_buf_d;
typedef struct s_buf_ui t_buf_ui;
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;
2020-12-22 18:15:25 +00:00
};
2024-04-24 18:40:56 +00:00
struct s_window {
int width;
int height;
2020-12-22 18:15:25 +00:00
};
2024-04-24 18:40:56 +00:00
struct s_buf_d {
double *data;
size_t ptr;
size_t len;
2020-12-22 18:15:25 +00:00
};
2024-04-24 18:40:56 +00:00
struct s_buf_ui {
unsigned int *data;
size_t ptr;
size_t len;
2020-12-22 18:15:25 +00:00
};
2024-04-24 18:40:56 +00:00
struct s_obj {
t_buf_d vertices;
t_buf_d uvs;
t_buf_d normals;
t_buf_ui vertices_indices;
t_buf_ui uvs_indices;
t_buf_ui normals_indices;
2020-12-22 18:15:25 +00:00
};
2024-04-24 18:40:56 +00:00
struct s_env {
char *file_name;
t_cam camera;
t_window window;
t_obj object;
2024-04-25 07:01:05 +00:00
double *vbo_data;
2024-04-24 18:40:56 +00:00
GLuint shader_program;
GLuint vertex_shader;
GLuint fragment_shader;
t_vec3 translate;
t_vec3 rotate;
t_vec3 scale;
2020-12-22 18:15:25 +00:00
};
2024-04-24 18:40:56 +00:00
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);
2020-12-23 16:58:47 +00:00
2024-04-24 18:40:56 +00:00
int parse_line(t_env *e, char *line);
t_gl_buf_type parse_gl_buf_type(char *token);
void parse_triangulate(t_buf_ui *indices, int token_count);
void parse_append_data_tmp(t_buf_ui *indices, int vertex_count, unsigned int *data_tmp);
2020-12-22 18:15:25 +00:00
2024-04-24 18:40:56 +00:00
int parse_token(t_env *e, char *token, t_gl_buf_type gl_buf_type);
int parse_append_data_d(t_buf_d *buffer, char *token);
int parse_append_data_ui(t_buf_ui *buffer, char *token);
2020-12-26 05:41:27 +00:00
2024-04-24 18:40:56 +00:00
void center_vertices(t_buf_d *vertices);
2020-12-26 05:41:27 +00:00
2024-04-24 18:40:56 +00:00
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);
2020-12-22 18:15:25 +00:00
2024-04-24 18:40:56 +00:00
int run(t_env *e);
2020-12-22 18:15:25 +00:00
#endif