Skip to content

Instantly share code, notes, and snippets.

View moebiussurfing's full-sized avatar
🛴

moebiusSurfing moebiussurfing

🛴
View GitHub Profile
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active April 22, 2020 04:39
openFrameworks - file path handling with boost
//split string path using boost
//https://stackoverflow.com/questions/10099206/howto-parse-a-path-to-a-vector-using-c
//boost::filesystem::path p1("/usr/local/bin");
boost::filesystem::path p1(videoFilePath.get());
//boost::filesystem::path p2("c:\\");
std::cout << p1.filename() << std::endl; // prints "bin"
std::cout << p1.parent_path() << std::endl; // prints "/usr/local"
videoName = ofToString(p1.filename());
filename: "NightmoVES4.mov"
@moebiussurfing
moebiussurfing / ofApp.cpp
Created April 28, 2020 00:47
openFrameworks - ofxImGui customize font
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontFromFileTTF(&ofToDataPath("ofxPresetsManager/fonts/overpass-mono-bold.otf")[0], 12.0f);
gui.setup();
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active May 5, 2020 22:27
openFrameworks / ImGui add ofParamaters as c++ types. plain ImGui without ofxImGui
//h
ofParameter<float> _edgeSlope;
//convert string to char pointer
string _str = parameter.getName();
const char * _name(_str.c_str());
/cpp
//setup
_edgeSlope.set("edgeSlope", 0.3f, 0.0f, 1.0f);
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active May 5, 2020 22:28
openFrameworks / template for parameter types / ofxImGui example
template<typename ParameterType>
bool AddParameter(ofParameter<ParameterType>& parameter);
//--------------------------------------------------------------
template<typename ParameterType>
bool ofxImGui::AddParameter(ofParameter<ParameterType>& parameter)
{
auto tmpRef = parameter.get();
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active August 4, 2020 10:55
openFrameworks / ofParameterGroup save/load parameters settings to xml
//h
void loadGroup(ofParameterGroup &g, string path);
void saveGroup(ofParameterGroup &g, string path);
//cpp
//--------------------------------------------------------------
@moebiussurfing
moebiussurfing / ofApp.cpp
Created May 6, 2020 05:48
openFrameworks / ImGui toggle button. styled and with animation
//2 snippets from here:
//https://github.com/ocornut/imgui/issues/1537
//1. styled rounded toggle button with animation
//add into ofApp.cpp
namespace ImGui {
void ToggleButton(const char* str_id, bool* v)
{
ImVec2 p = ImGui::GetCursorScreenPos();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
@moebiussurfing
moebiussurfing / ofApp.cpp
Created May 6, 2020 06:02
openFramewokrs / ImGui circular knob
//https://github.com/ocornut/imgui/issues/942#issuecomment-268369298
//put code into ofApp.cpp and use between begin/end:
if (MyKnob("attack", &myKnob, 0.f, 10.f))
{
cout << "knob:" << myKnob << endl;
}
// Implementing a simple custom widget using the public API.
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active May 7, 2020 03:41
openFrameworks / check if a data folder is present, create the folder if not.
void ofApp::CheckFolder(string _path)
{
ofDirectory dataDirectory(ofToDataPath(_path, true));
//check if target data folder exist
if (!dataDirectory.isDirectory())
{
ofLogError("__FUNCTION__") << "FOLDER DOES NOT EXIST!";
//create folder
@moebiussurfing
moebiussurfing / ofApp.cpp
Created May 10, 2020 14:17
openFrameworks / soundStream: audioIn / audioOut from maximilian example
//.h
// For drawing
float waveform[4096]; //make this bigger, just in case
int waveIndex;
ofSoundStream soundStream;
/* ofxMaxi*/
void audioIn(ofSoundBuffer& input) override; // not used in this example
void audioOut(ofSoundBuffer& output) override;
@moebiussurfing
moebiussurfing / ofApp.cpp
Created May 28, 2020 03:27
openFrameworks / ImGui helper
// my own helper
template<typename ParameterType>
bool AddParameter(ofParameter<ParameterType>& parameter);
// my own helper
//--------------------------------------------------------------
template<typename ParameterType>
bool ofApp::AddParameter(ofParameter<ParameterType>& parameter)
{