Support setting volume data size in cloud example

This commit is contained in:
Nikita Lisitsa 2021-01-15 17:56:56 +03:00
parent b0b2975efc
commit 863b251903

View file

@ -21,8 +21,11 @@
#include <psemek/random/uniform_sphere.hpp>
#include <psemek/util/range.hpp>
#include <psemek/util/clock.hpp>
#include <psemek/util/to_string.hpp>
#include <psemek/async/threadpool.hpp>
#include <iostream>
using namespace psemek;
template <typename Iterator>
@ -164,7 +167,7 @@ struct cloud_app
float step;
float max_density = 6.f;
float max_density = 2.f;
geom::interval<float> harmonic_range;
util::clock<std::chrono::duration<float>> clock;
@ -187,10 +190,9 @@ struct cloud_app
gfx::texture_3d cloud_texture;
gfx::texture_3d shadow_texture;
cloud_app()
cloud_app(std::size_t size)
: app::app("Cloud")
{
std::size_t size = 32;
geom::vector<int, 3> cloud_size{2 * size, size, size};
bbox = {{{-2.f, 2.f}, {-1.f, 1.f}, {-1.f, 1.f}}};
@ -243,7 +245,7 @@ struct cloud_app
// can't use template argument deduction for first argument due to gcc bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89062
geom::gradient<float> g(std::make_pair(0.2f, 0.f), geom::easing_type::cubic, std::pair{0.4f, max_density});
geom::gradient<float> g(std::make_pair(0.2f, 0.f), geom::easing_type::quadratic_out, std::pair{0.3f, max_density});
util::array<std::uint8_t, 3> cloud_data({cloud_size[0], cloud_size[1], cloud_size[2]});
@ -590,7 +592,18 @@ struct cloud_app
}
};
int main()
int main(int argc, char ** argv)
{
return app::main<cloud_app>();
if (argc != 1 && argc != 2)
{
std::cout << "Usage: " << argv[0] << " [ size ]\n";
return 0;
}
std::size_t size = 32;
if (argc == 2)
{
size = util::from_string<std::size_t>(argv[1]);
}
return app::main<cloud_app>(size);
}