Rename RenderParams -> Options

This commit is contained in:
josh committed 2026-11-03 19:34:20 -05:00
1 parent de2c51376a
commit 6f8e3714da
9 files changed
+25 -25

No files matched your search

+4 -4
View File
@@ -172,7 +172,7 @@ int Cli::handle_option(size_t flag_idx, const char * arg_value)
{ {
case flag_height: case flag_height:
case flag_height_l: case flag_height_l:
if (!parse_size(flag_defs[flag_idx].flag, arg_value, &this->params.height)) if (!parse_size(flag_defs[flag_idx].flag, arg_value, &this->options.height))
{ {
return 2; return 2;
} }
@@ -198,11 +198,11 @@ int Cli::handle_option(size_t flag_idx, const char * arg_value)
case flag_threads: case flag_threads:
case flag_threads_l: case flag_threads_l:
if (!parse_size(flag_defs[flag_idx].flag, arg_value, &this->params.threads)) if (!parse_size(flag_defs[flag_idx].flag, arg_value, &this->options.threads))
{ {
return 2; return 2;
} }
if (*this->params.threads == 0u) if (*this->options.threads == 0u)
{ {
fprintf(stderr, "Error: option %s must be at least 1\n", flag_defs[flag_idx].flag); fprintf(stderr, "Error: option %s must be at least 1\n", flag_defs[flag_idx].flag);
return 2; return 2;
@@ -211,7 +211,7 @@ int Cli::handle_option(size_t flag_idx, const char * arg_value)
case flag_width: case flag_width:
case flag_width_l: case flag_width_l:
if (!parse_size(flag_defs[flag_idx].flag, arg_value, &this->params.width)) if (!parse_size(flag_defs[flag_idx].flag, arg_value, &this->options.width))
{ {
return 2; return 2;
} }
+2 -2
View File
@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <fart/RenderParams.h> #include <fart/Options.h>
class Cli class Cli
{ {
public: public:
RenderParams params; Options options;
string_view input_file; string_view input_file;
opt<string_view> output_file; opt<string_view> output_file;
+5 -5
View File
@@ -4,8 +4,8 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
Engine::Engine(const RenderParams & params) Engine::Engine(const Options & options)
: params(params) : options(options)
{ {
} }
@@ -62,9 +62,9 @@ int Engine::run(string_view input_file, opt<string_view> output_file)
return 1; return 1;
} }
/* CLI params take precedence over scene params; defaults fill the rest. */ /* CLI options take precedence over scene options; defaults fill the rest. */
params.merge(scene->params); options.merge(scene->options);
params.apply_defaults(); options.apply_defaults();
return 0; return 0;
} }
+3 -3
View File
@@ -1,19 +1,19 @@
#pragma once #pragma once
#include <fart/ImageWriter.h> #include <fart/ImageWriter.h>
#include <fart/RenderParams.h> #include <fart/Options.h>
#include <fart/Scene.h> #include <fart/Scene.h>
#include <memory> #include <memory>
class Engine class Engine
{ {
public: public:
Engine(const RenderParams & params); Engine(const Options & options);
~Engine(); ~Engine();
int run(string_view input_file, opt<string_view> output_file); int run(string_view input_file, opt<string_view> output_file);
protected: protected:
RenderParams params; Options options;
std::unique_ptr<ImageWriter> image_writer; std::unique_ptr<ImageWriter> image_writer;
Scene * scene = nullptr; Scene * scene = nullptr;
}; };
@@ -1,7 +1,7 @@
#include <fart/RenderParams.h> #include <fart/Options.h>
#include <thread> #include <thread>
void RenderParams::merge(const RenderParams & other) void Options::merge(const Options & other)
{ {
if (!width) if (!width)
{ {
@@ -21,7 +21,7 @@ void RenderParams::merge(const RenderParams & other)
} }
} }
void RenderParams::apply_defaults() void Options::apply_defaults()
{ {
if (!width) if (!width)
{ {
@@ -3,7 +3,7 @@
#include <fart/Color.h> #include <fart/Color.h>
#include <stddef.h> #include <stddef.h>
struct RenderParams struct Options
{ {
opt<size_t> width; opt<size_t> width;
opt<size_t> height; opt<size_t> height;
@@ -11,7 +11,7 @@ struct RenderParams
opt<Color> background; opt<Color> background;
/* Set each field that is not already set to the value from other. */ /* Set each field that is not already set to the value from other. */
void merge(const RenderParams & other); void merge(const Options & other);
/* Fill in any unset fields with default values. */ /* Fill in any unset fields with default values. */
void apply_defaults(); void apply_defaults();
+3 -3
View File
@@ -124,15 +124,15 @@ Scene * Parser::build_scene(const string_view & input_file, PStart start)
bool ok = true; bool ok = true;
if (PBackground background = item.pBackground(); p_node_valid(background)) if (PBackground background = item.pBackground(); p_node_valid(background))
{ {
scene->params.background = vector_to_color(background.pVector()); scene->options.background = vector_to_color(background.pVector());
} }
else if (PHeight height = item.pHeight(); p_node_valid(height)) else if (PHeight height = item.pHeight(); p_node_valid(height))
{ {
ok = token_to_size(input_file, height.pToken2(), &scene->params.height); ok = token_to_size(input_file, height.pToken2(), &scene->options.height);
} }
else if (PWidth width = item.pWidth(); p_node_valid(width)) else if (PWidth width = item.pWidth(); p_node_valid(width))
{ {
ok = token_to_size(input_file, width.pToken2(), &scene->params.width); ok = token_to_size(input_file, width.pToken2(), &scene->options.width);
} }
if (!ok) if (!ok)
{ {
+2 -2
View File
@@ -1,9 +1,9 @@
#pragma once #pragma once
#include <fart/RenderParams.h> #include <fart/Options.h>
class Scene class Scene
{ {
public: public:
RenderParams params; Options options;
}; };
+1 -1
View File
@@ -15,6 +15,6 @@ int main(int argc, char * argv[])
fprintf(stderr, "Error: no input file specified\n"); fprintf(stderr, "Error: no input file specified\n");
return 1; return 1;
} }
Engine engine(cli.params); Engine engine(cli.options);
return engine.run(cli.input_file, cli.output_file); return engine.run(cli.input_file, cli.output_file);
} }