patriciogonzalezvivo / glslViewer

Console-based GLSL Sandbox for 2D/3D shaders
BSD 3-Clause "New" or "Revised" License
4.62k stars 350 forks source link

Fix: Promote project's standards to `C++17` #284

Open tcoyvwac opened 2 years ago

tcoyvwac commented 2 years ago
tcoyvwac commented 1 year ago

Due to a discovery in building PR:#319; because of an interesting characteristic highlighted during the Build (windows-latest) CI chain, this PR may have a follow-up PR to be promoted to C++20! :rocket:


Explanation: It seems that Build (windows-latest) is quite "strict" with some C++ nice features which other compilers accept pre-C++20! :disappointed:

This feature is called "Designated Initializer Lists"


So condensely explained, instead of being able to write the terse shortform: :smiling_face_with_tear:

union render_pass_args_t { // <-- [2]: Note: can use the union datatype for a bonus combo!
    const vera::Fbo* const fbo;
    const BuffersList* const fbolist;  // using BuffersList = std::vector<vera::Fbo*>;
};
struct vtable_render_pass_t{
    using func_sig_t = auto (*)(const std::string&, Uniforms&, const render_pass_args_t&, render_ui_t&)-> void;
    const std::string prompt_id;
    const render_pass_args_t process_info;
    const func_sig_t process_render_pass;
};
const auto render_pass_table = { vtable_render_pass_t
    {"u_buffer", {}, do_pass_singlebuffer}
    , {"u_scene", {&m_sceneRender.renderFbo}, do_pass_scene}
    , {"u_sceneBuffer", {.fbolist = &m_sceneRender.buffersFbo}, do_pass_scenebuffer} // <-- [1] for "Build (windows-latest)", this is "technically" a c++20 feature.
    , {"u_sceneDepth", {&m_sceneRender.renderFbo}, do_pass_scenedepth}
};

...we must be "strict" and write the very bluntish and verbose longform! (For Build (windows-latest) to be happy!) :scream:

struct render_pass_args_t {  // <-- [2]: Warning: strict-mode C++11, and so we have to use struct datatype declaration!
    const vera::Fbo* const fbo;
    const BuffersList* const fbolist;  // using BuffersList = std::vector<vera::Fbo*>;
};
struct vtable_render_pass_t{
    using func_sig_t = auto (*)(const std::string&, Uniforms&, const render_pass_args_t&, render_ui_t&)-> void;
    const std::string prompt_id;
    const render_pass_args_t process_info;
    const func_sig_t process_render_pass;
};
const auto render_pass_table = { vtable_render_pass_t
    {"u_buffer", {nullptr, nullptr}, do_pass_singlebuffer}
    , {"u_scene", {&m_sceneRender.renderFbo, nullptr}, do_pass_scene}
    , {"u_sceneBuffer", {nullptr, &m_sceneRender.buffersFbo}, do_pass_scenebuffer} // <-- [1]: Boo. :( All fields must be declared for everything, to make "Build (windows-latest)" happy!
    , {"u_sceneDepth", {&m_sceneRender.renderFbo, nullptr}, do_pass_scenedepth}
};

If programming (OO) is all about "message passing"[1], it's disappointing and unfortunate that this nice feature is hidden behind C++20 on Build (windows-latest)! :disappointed:

  1. https://en.m.wikipedia.org/wiki/Smalltalk#History