Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Right way to save settings of vector of ofParameter in a ofxguiGroup / ofxGuiGroupExtended

$
0
0

when you resize a vector like that it'll create 1 element and then copy it to all positions. Since ofParameter has shallow copy semantics a copy of a parameter is realy a reference to it not a full copy so when you call set on the different positions of the vector you are changeing that 1 parameter you have created and for which there's several references in the vector. to avoid it you can use push_back instead of resize but i would advice you to use ofParameterGroup instead and then just setup the gui group with it like:

//.h
ofxGuiGroup MaskWindow;
ofParameterGroup MaskParameters;

//.cpp
...
for (int i = 0; i < _nFam; i++)
{
    string fam = "Family " + i;
    ofParameter<bool> param("Blend", false);
    MaskParameters.add(p_blend);

    ofParameter<bool> param("Alpha", 255, 0, 255);
    MaskParameters.add(p_alpha);
}
MaskWindow.setup(MaskParameters);

you can also have separate parameter groups if you prefer to have them separated by type and then add the parameter groups to the ofxGuiGroup or directly to an ofxPanel...


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>