From 8dce8be241ea378094b4b20e0d37a25c1b2e4c6b Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Thu, 25 Jan 2024 11:08:23 -0500 Subject: [PATCH] i love you --- .../Testing/Temporary/LastTest.log | 4 +- include/functions.h | 8 +-- include/image.h | 1 + libraries/BLT-With-Graphics-Template | 2 +- src/functions.cpp | 20 ++++---- src/main.cpp | 49 +++++++------------ 6 files changed, 35 insertions(+), 49 deletions(-) diff --git a/cmake-build-release/Testing/Temporary/LastTest.log b/cmake-build-release/Testing/Temporary/LastTest.log index 5377508..22cafb0 100644 --- a/cmake-build-release/Testing/Temporary/LastTest.log +++ b/cmake-build-release/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Jan 25 09:22 EST +Start testing: Jan 25 10:57 EST ---------------------------------------------------------- -End testing: Jan 25 09:22 EST +End testing: Jan 25 10:57 EST diff --git a/include/functions.h b/include/functions.h index 368c236..27a3ef8 100644 --- a/include/functions.h +++ b/include/functions.h @@ -196,22 +196,22 @@ DEF_FUNC_LIST(FUNC_ALLOW_TERMINALS, function_t::SCALAR, function_t::X, function_ * Create mappings */ #define FUNC_DEFINE(NAME, MIN_ARGS, MAX_ARGS, FUNC, ...) MIN_ARGS, -std::array function_arg_min_map = { +[[maybe_unused]] static inline std::array function_arg_min_map = { FUNC_FUNCTIONS }; #undef FUNC_DEFINE #define FUNC_DEFINE(NAME, MIN_ARGS, MAX_ARGS, FUNC, ...) MAX_ARGS, -std::array function_arg_max_map = { +[[maybe_unused]] static inline std::array function_arg_max_map = { FUNC_FUNCTIONS }; #undef FUNC_DEFINE #define FUNC_DEFINE(NAME, MIN_ARGS, MAX_ARGS, FUNC, ...) func_list{__VA_ARGS__}, -std::array, OPERATOR_COUNT> function_arg_allowed_map = { +[[maybe_unused]] static inline std::array, OPERATOR_COUNT> function_arg_allowed_map = { FUNC_FUNCTIONS }; #undef FUNC_DEFINE #define FUNC_DEFINE(NAME, MIN_ARGS, MAX_ARGS, FUNC, ...) convert(func_list{__VA_ARGS__}), -std::array, OPERATOR_COUNT> function_arg_allowed_set_map = { +[[maybe_unused]] static inline std::array, OPERATOR_COUNT> function_arg_allowed_set_map = { FUNC_FUNCTIONS }; #undef FUNC_DEFINE diff --git a/include/image.h b/include/image.h index eb1dbe0..bbeb334 100644 --- a/include/image.h +++ b/include/image.h @@ -114,6 +114,7 @@ class image blt::vec3 color = std::visit(blt::lambda_visitor{ [](const image_data_t*) -> blt::vec3 { BLT_ASSERT("There has been an error in the matrix. You should not have gotten here!"); + return {}; }, [](const blt::vec3& v) -> blt::vec3 { return v; diff --git a/libraries/BLT-With-Graphics-Template b/libraries/BLT-With-Graphics-Template index 709db71..129f6e3 160000 --- a/libraries/BLT-With-Graphics-Template +++ b/libraries/BLT-With-Graphics-Template @@ -1 +1 @@ -Subproject commit 709db718275718e09b3c68bde3faa6d7c9701af8 +Subproject commit 129f6e3fb9d6524e9fd6ece47f9bf4ea6f0a1a83 diff --git a/src/functions.cpp b/src/functions.cpp index 31261d6..8ad2032 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -51,14 +51,14 @@ void f_noise(image& img, float x, float y, blt::size_t argc, const image** argv, float scaleX = width; float scaleY = height; if (argc >= 1) - scaleX *= argv[0].get().x(); + scaleX *= argv[0]->get().x(); if (argc > 1) - scaleY *= argv[1].get().x(); + scaleY *= argv[1]->get().x(); auto val = stb_perlin_noise3(protect_div(x, scaleX, z), protect_div(y, scaleY, z), z, 0, 0, 0); - img.set({val, val, val}, x, y); + img.set({val, val, val}, static_cast(x), static_cast(y)); } void f_cnoise(image& img, float x, float y, blt::size_t argc, const image** argv, const data_t& extra_data) @@ -72,17 +72,17 @@ void f_cnoise(image& img, float x, float y, blt::size_t argc, const image** argv float scaleGY = height; float scaleBY = height; if (argc >= 1) - scaleRX *= argv[0].get().x(); + scaleRX *= argv[0]->get().x(); if (argc > 1) - scaleRY *= argv[1].get().x(); + scaleRY *= argv[1]->get().x(); if (argc >= 3) - scaleRX *= argv[2].get().x(); + scaleRX *= argv[2]->get().x(); if (argc > 3) - scaleRY *= argv[3].get().x(); + scaleRY *= argv[3]->get().x(); if (argc >= 5) - scaleRX *= argv[4].get().x(); + scaleRX *= argv[4]->get().x(); if (argc > 5) - scaleRY *= argv[5].get().x(); + scaleRY *= argv[5]->get().x(); auto valR = stb_perlin_noise3(protect_div(x, scaleRX, z), protect_div(y, scaleRY, z), @@ -93,7 +93,7 @@ void f_cnoise(image& img, float x, float y, blt::size_t argc, const image** argv auto valB = stb_perlin_noise3(protect_div(x, scaleBX, z), protect_div(y, scaleBY, z), z, 0, 0, 0); - img.set({valR, valG, valB}, x, y); + img.set({valR, valG, valB}, static_cast(x), static_cast(y)); } void f_scalar(image& img, float x, float y, blt::size_t argc, const image** argv, const data_t& extra_data) diff --git a/src/main.cpp b/src/main.cpp index 948ac0a..1a2fafb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -139,17 +139,17 @@ struct node BLT_ASSERT(sub_nodes[i] != nullptr && sub_nodes[i]->img.has_value() && "Node must have evaluated children!"); sub_node_images[i] = &sub_nodes[i]->img.value(); } -#define FUNC_DEFINE(NAME, MIN_ARGS, MAX_ARGS, FUNC, ...) case function_t::NAME: { \ - if (FUNC_ALLOW_TERMINALS_SET.contains(function_t::NAME)){ \ - FUNC(img.value(), 0, 0, argc, sub_node_images.data(), data); \ - } else { \ - for (blt::i32 y = 0; y < height; y++) { \ - for (blt::i32 x = 0; x < width; x++) { \ - FUNC(img.value(), static_cast(x), static_cast(y), argc, sub_node_images.data(), data); \ - } \ - } \ - } \ - } \ +#define FUNC_DEFINE(NAME, MIN_ARGS, MAX_ARGS, FUNC, ...) case function_t::NAME: { \ + if (FUNC_ALLOW_TERMINALS_SET.contains(function_t::NAME)){ \ + FUNC(img.value(), 0, 0, argc, const_cast(sub_node_images.data()), data); \ + } else { \ + for (blt::i32 y = 0; y < height; y++) { \ + for (blt::i32 x = 0; x < width; x++) { \ + FUNC(img.value(), static_cast(x), static_cast(y), argc, const_cast(sub_node_images.data()), data); \ + } \ + } \ + } \ + } \ break; switch (type) @@ -223,28 +223,13 @@ void update(std::int32_t w, std::int32_t h) root = node::construct_random_tree(); root->evaluate_tree(); BLT_INFO("Preprocess"); - auto& data = root->getImage()->getData(); - for (auto& v : data) - { - //BLT_INFO_STREAM << "B4: " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << "\n"; - if (fucky(v.x())) - v[0] = 0; - if (fucky(v.y())) - v[1] = 0; - if (fucky(v.z())) - v[2] = 0; - v = v.normalize(); - if (fucky(v.x())) - v[0] = 0; - if (fucky(v.y())) - v[1] = 0; - if (fucky(v.z())) - v[2] = 0; - //BLT_INFO_STREAM << "A4: " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << "\n"; - } BLT_INFO("Uploading"); - texture->upload((void*) root->getImage()->getData().data(), GL_RGB, 0, 0, 0, -1, -1, GL_FLOAT); + //delete texture; + texture->upload((void*) root->getImage().getData().data(), GL_RGB, 0, 0, 0, -1, -1, GL_FLOAT); + //texture->upload((void*) test.data(), GL_RGBA, 0, 0, 0, width, height, GL_UNSIGNED_BYTE); + //texture->upload(file); + //texture = new blt::gfx::texture_gl2D(file); resources.set("img", texture); } @@ -252,7 +237,7 @@ void update(std::int32_t w, std::int32_t h) auto lh = 512.0f; //renderer_2d.drawRectangle(blt::vec4{0.5, 0.0, 1.0, 1.0}, // {static_cast(w) / 2.0f, static_cast(h) / 2.0f, static_cast(w), static_cast(h)}); - renderer_2d.drawRectangle("cum", {static_cast(w) / 2.0f, static_cast(h) / 2.0f, lw, lh}); + renderer_2d.drawRectangle("img", {static_cast(w) / 2.0f, static_cast(h) / 2.0f, lw, lh}); global_matrices.update(); renderer_2d.render();