diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-05-14 16:44:28 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-05-14 16:44:28 +0200 |
| commit | 23ba151d95e4284ddb2d5f1c9810741061c293fd (patch) | |
| tree | 98d9aa1322dc108e1adf2a695fc642266e05c2b3 /inc/scop.h | |
| parent | 29ea8338efb0b5450611b73463c9d7d469db2d75 (diff) | |
| download | scop-23ba151d95e4284ddb2d5f1c9810741061c293fd.tar.gz scop-23ba151d95e4284ddb2d5f1c9810741061c293fd.tar.bz2 scop-23ba151d95e4284ddb2d5f1c9810741061c293fd.zip | |
Refactoring to the point before started refactoring, without crash on texture binding
Diffstat (limited to 'inc/scop.h')
| -rw-r--r-- | inc/scop.h | 55 |
1 files changed, 35 insertions, 20 deletions
@@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/05/09 10:41:44 by charles #+# #+# */ -/* Updated: 2020/05/14 14:58:23 by charles ### ########.fr */ +/* Updated: 2020/05/14 16:29:38 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,21 +29,29 @@ #define WINDOW_WIDTH 640 #define WINDOW_HEIGHT 480 +#define VERTEX_COUNT 10 +#define VERTEX_STRIDE (sizeof(float) * VERTEX_COUNT) + +#define VERTEX_POS_OFFSET 0 +#define VERTEX_COLOR_OFFSET 4 +#define VERTEX_TEX_COORD_OFFSET 8 typedef struct { float *vertices; unsigned int *indices; - size_t vertices_size; - size_t indices_size; + size_t vertices_num; + size_t indices_num; + char *texture_filepath; } t_model_data; typedef struct { unsigned int vertex_buf; unsigned int index_buf; - size_t index_buf_size; + size_t index_buf_num; unsigned int vertex_array; + unsigned int texture; struct { t_ftmmat4 center; @@ -61,6 +69,7 @@ typedef struct int model; int view; int proj; + int texture; } location; } t_shader; @@ -90,20 +99,27 @@ union u_color }; /* -** state.c +** graphic/state.c +*/ + +bool state_init(t_state *state, t_model_data *data); +void state_run(t_state *state); +void state_quit(t_state *state); + +/* +** graphic/event.c */ -bool state_init(t_state *state, t_model_data *data); -void state_run(t_state *state); -void state_quit(t_state *state); +void event_handle(t_state *state); /* ** scene.c */ -void scene_init(t_scene *scene, t_model_data *data); -void scene_update_proj(t_scene *scene, float fov, int width, int height); -void scene_update_model(t_scene *scene, float rotation_radian); -void scene_quit(t_scene *scene); + +void scene_init(t_scene *scene, t_model_data *data); +void scene_update_proj(t_scene *scene, float fov, int width, int height); +void scene_update_model(t_scene *scene, float rotation_radian); +void scene_quit(t_scene *scene); /* ** parse.c @@ -128,28 +144,27 @@ void error_check(char *code, char *filename, int line_num); */ bool shader_init(t_shader *shader); -void shader_update_mvp(t_shader *shader, t_scene *scene); +void shader_set_uniforms(t_shader *shader, t_scene *scene); /* ** texture.c */ -unsigned int texture_new(char *filepath); +unsigned int texture_create(char *filepath); +void texture_coord_init(float *vertices, size_t vertices_num); /* ** helper.c */ -bool has_extension(char *filepath, char *extension); +bool helper_check_extension(char *filepath, char *extension); +void helper_find_boundary( + float *vertices, size_t vertices_num, t_ftmvec3 *max, t_ftmvec3 *min); /* ** color.c */ -bool color_merge_vertices(t_model_data *object, float *coords); - - -float *texture_coord_create(float *vertices, size_t vertices_len); - +void color_init(float *vertices, size_t vertices_num); #endif |
