#Struct
43 messages · Page 1 of 1 (latest)
#define RGB2GL 1.0f / 255.0f
...
float r = 224.0f * RGB2GL;
that struct is kind of useless
@leaden grotto has reached level 3. GG!
why
@storm basin has reached level 14. GG!
because you can't pass to any functions unless their type is Color_sky
it should be an instance of an rgb struct
you aren't passing the whole struct in, just its individual fields
yeah
either way, that's a bad design imo
can you send better code
im not a pro
so idk wym by "an instance of an rgb struct"
struct rgb_t {
float r, g, b, a;
};
// assuming this is at global scope
static rgb_t constexpr COLOR_SKY { .r = ..., .b = ..., .g = ..., .a = ...};
replace the ellipsis with the values you used above
like this, you can freely define other colors as well:
void whatever(){
rgb_t const red { .r = 1.f, .b = 0.f, .g = 0.f, .a = 1.f };
// blah blah blah
}
btw im not sure this syntax will work
it is only supported by c++ since c++17 i think
it works but without the rgba names
just nums
and no dots
so like cpp .......... COLOR_SKY {1, 2, 3, 4};
it's actually since c++20
which is funny because this is available in c99
lol I didnt even notice
struct Vec4f{
float x,y,z,w;
Vec4f(){}
Vec4f(float x,float y,float z,float w) : x(x),y(y),z(z),w(w){}
};
struct Vec4f skyColor = Vec4f(...);
to retrieve values simply do skyColor.x,y,z, or w
You already have a Vec4f object in the glm namespace
use it or make your own vec4f
you need not to define those constructors
it's a preference
can you do this with classes too?
curious
using std::initializer_list as single constructor argument