Last active
January 5, 2021 20:19
-
-
Save moebiussurfing/5e3f7403a3e2b762525ccd697107a742 to your computer and use it in GitHub Desktop.
openFrameworks / ofParameters cast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// casting ofParameters | |
float v = static_cast<ofParameter<float>&>(parameter); | |
ofParameter<float> prop = static_cast<ofParameter<float>&>(parameter); | |
ofParameter<float> prop = parameter.cast<float>(); | |
//which internally does the static cast you are using now. | |
//https://forum.openframeworks.cc/t/ofparametergroup-best-practices/18752/8 | |
//-- | |
// static and multi class gui | |
//https://forum.openframeworks.cc/t/using-ofxgui-slider-values-outside-of-ofapp/21293/11 | |
//NOTICE: | |
//If you use vector for MyClass like #1 example above, please make sure MyClass’s destructor won’t be called. | |
//This happen often for example when you push_back() new element to vector. When you add new element to your vector, it could be automatically change its memory size to prepare future addition. During this auto expansion process, destructor ofGui is called and lose callback pointer information. Resulting mouse event stop working. To avoid this, and makes really sure its pointer and memory is under your control always, one could use shared pointer like below | |
vector<shared_ptr<MyClass>> myClasses; | |
// emplace_back |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment