Initialising structs

  • doodlum
  • Topic Author
More
2 years 5 months ago #1 by doodlum Initialising structs was created by doodlum
How could I initialise a struct with ReShade's syntax. As an example here is a struct I can't compile.

struct RRTOptions
{
    float glow_gain;
    float glow_mid;
    float red_scale;
    float red_pivot;
    float red_hue;
    float red_width;
    float sat_factor;
};
static const RRTOptions default_rrt =
{
    0.05,
    0.08,
    0.82,
    0.03,
    0.0,
    135.0,
    0.96
};

Please Log in or Create an account to join the conversation.

  • crosire
More
2 years 5 months ago #2 by crosire Replied by crosire on topic Initialising structs
ReShade FX interprets "{ ... }" syntax as an array (it doesn't do context-sensitive parsing). It also doesn't support struct constructor syntax at the moment. So to initialize the struct have to assign each field individually:
struct RRTOptions
{
    float glow_gain;
    float glow_mid;
    float red_scale;
    float red_pivot;
    float red_hue;
    float red_width;
    float sat_factor;
};

...

RRTOptions default_rrt;
default_rrt.glow_gain = 0.05;
default_rrt.glow_mid = 0.08;
default_rrt.red_scale = 0.82;
default_rrt.red_pivot = 0.03;
default_rrt.red_hue = 0.0;
default_rrt.red_width = 135.0;
default_rrt.sat_factor = 0.96;

Please Log in or Create an account to join the conversation.