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 /src/main.c | |
| 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 'src/main.c')
| -rw-r--r-- | src/main.c | 72 |
1 files changed, 19 insertions, 53 deletions
@@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/05/09 10:20:09 by charles #+# #+# */ -/* Updated: 2020/05/14 14:49:02 by charles ### ########.fr */ +/* Updated: 2020/05/14 16:16:24 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,37 +21,6 @@ ** - cleaner code */ -/* void handle_event(GLFWwindow *window) */ -/* { */ -/* if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) */ -/* glfwSetWindowShouldClose(window, true); */ -/* else if (glfwGetKey(window, GLFW_KEY_P) == GLFW_PRESS) */ -/* { */ -/* if (state->polygon_mode_last_time + 0.1 > glfwGetTime()) */ -/* return ; */ -/* if (state->polygon_mode == GL_FILL) */ -/* state->polygon_mode = GL_LINE; */ -/* else if (state->polygon_mode == GL_LINE) */ -/* state->polygon_mode = GL_POINT; */ -/* else if (state->polygon_mode == GL_POINT) */ -/* state->polygon_mode = GL_FILL; */ -/* GL_CALL(glPolygonMode(GL_FRONT_AND_BACK, state->polygon_mode)); */ -/* state->polygon_mode_last_time = glfwGetTime(); */ -/* } */ -/* else if (glfwGetKey(window, GLFW_KEY_EQUAL) == GLFW_PRESS) */ -/* { */ -/* state->fov -= M_PI / 100.0f; */ -/* if (state->fov <= M_PI_4 / 2) */ -/* state->fov = M_PI_4 / 2; */ -/* } */ -/* else if (glfwGetKey(window, GLFW_KEY_MINUS) == GLFW_PRESS) */ -/* { */ -/* state->fov += M_PI / 100.0f; */ -/* if (state->fov >= M_PI - M_PI_4 / 2) */ -/* state->fov = M_PI - M_PI_4 / 2; */ -/* } */ -/* } */ - void debugmat(t_ftmmat4 *mat) { for (int i = 0; i < 4; i++) @@ -70,11 +39,11 @@ int main(int argc, char **argv) t_state state; t_model_data data; - if (argc != 2) + if (argc != 2 && argc != 3) { ft_putstr("Usage: "); ft_putstr(argv[0]); - ft_putendl(" [obj file]"); + ft_putendl(" OBJ_FILE [BMP_FILE]"); return (1); } if (parse(argv[1], &data) == -1) @@ -83,37 +52,34 @@ int main(int argc, char **argv) ft_putendl(argv[1]); return (1); } + color_init(data.vertices, data.vertices_num); + texture_coord_init(data.vertices, data.vertices_num); + if (argc == 3) + data.texture_filepath = argv[2]; + else + data.texture_filepath = "res/brick.bmp"; - /* unsigned int texture = texture_new("res/brick.bmp"); */ - /* float *coords = texture_coord_create(object.vertices, object.vertices_len); */ - /* */ - /* if (!color_merge_vertices(&object, coords)) */ - /* { */ - /* ft_putstr("Error: couldn't create colors"); */ - /* return (1); */ - /* } */ - - printf("size %lu\n", data.indices_size); - for (size_t i = 0; i < data.indices_size; i++) + printf("size %lu\n", data.indices_num); + for (size_t i = 0; i < data.indices_num; i++) { printf("%u, ", data.indices[i++]); printf("%u, ", data.indices[i++]); printf("%u\n", data.indices[i]); } - printf("size %lu\n", data.vertices_size); - for (size_t i = 0; i < data.vertices_size; i++) + printf("size %lu\n", data.vertices_num); + for (size_t i = 0; i < data.vertices_num; i++) { printf("% f, ", data.vertices[i++]); printf("% f, ", data.vertices[i++]); printf("% f, ", data.vertices[i++]); + printf("% f | ", data.vertices[i++]); + printf("% f, ", data.vertices[i++]); + printf("% f, ", data.vertices[i++]); + printf("% f, ", data.vertices[i++]); + printf("% f | ", data.vertices[i++]); + printf("% f ", data.vertices[i++]); printf("% f\n", data.vertices[i]); - /* printf("% f, ", object.vertices[i++]); */ - /* printf("% f, ", object.vertices[i++]); */ - /* printf("% f, ", object.vertices[i++]); */ - /* printf("% f\ttex: ", object.vertices[i]); */ - /* printf("% f", object.vertices[i++]); */ - /* printf("% f\n", object.vertices[i]); */ } /* GL_CALL(glUniform1i(glGetUniformLocation(state.shader, "u_texture"), 0)); */ |
