Skip to content

Instantly share code, notes, and snippets.

@moebiussurfing
moebiussurfing / ofApp.cpp
Last active February 17, 2020 05:41
openFrameworks - ofxGui theme. check font file exist
//ofxGui theme
string path = GLOBAL_Path + "fonts/overpass-mono-bold.otf";
ofFile file(path);
if (file.exists())
{
ofLogNotice("ofxSceneTEST") << "ofxGui theme: LOADED FONT FILE '" << path << "'";
ofxGuiSetFont(path, 9);
}
else
{
@moebiussurfing
moebiussurfing / cpp
Created February 11, 2020 05:10
openFrameworks - check if file exists
ofFile file(path);
if (file.exists())
{
}
else
{
ofLogError("ofApp") << "loadSettings '" << path << "' NOT FOUND!";
}
@moebiussurfing
moebiussurfing / gist:73953e47d02c7e2bbdb484c42b80d390
Last active February 11, 2020 08:51
openFrameworks - ImGui vec sliders
static float position[] = {0.0f, 0.0f};
ImGui::SliderFloat2("position", position, -1.0f, 1.0f);
static glm::vec3 myVector{0.0f, 0.0f, 0.0f};
ImGui::SliderFloat3("myVector", (float*)&myVector, 0.0f, 1.0f);
static ImVec4 myImVector{1.0f, 1.0f, 1.0f, 1.0f};
ImGui::SliderFloat4("myImVector", (float*)&myImVector, 0.0f, 1.0f);
@moebiussurfing
moebiussurfing / open file system dialog
Last active February 11, 2020 08:51
openFrameworks - open file system dialog // get texture from video
https://forum.openframeworks.cc/t/how-do-i-mix-the-alpha-channel-of-one-video-with-another/18771
ofApp.h file
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
@moebiussurfing
moebiussurfing / ofParameterGroup_Changed_params
Last active August 20, 2021 01:09
openFrameworks - callback parameterGroup . ofParameterGroup / Changed_params / name = e.getName()
// .h
ofParameterGroup params{"Params"};
void Changed_Params(ofAbstractParameter &e);
bool DISABLE_Callbacks = false; // to avoid callback crashes or to enable only after setup()
// .cpp
// setup()
//params
SHOW_gui.set("SHOW_gui", true);
# rm all files
git rm -r --cached .
# add all files as per new .gitignore
git add .
# now, commit for new .gitignore to apply
git commit -m ".gitignore is now working"
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active February 11, 2020 08:52
openFrameworks - ofxSerializer OF types easy serialization
// Make vector.
std::vector<ofColor> palette = { ofColor::red };
// Serialize it.
ofJson json = palette;
// Save it.
ofSaveJson("palette.json", json);
// Load it.
ofJson paletteJson = ofLoadJson("palette.json");
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active May 18, 2020 06:07
openFrameworks - ofParameterGroup cast parameters from group callback
ofApp::Changed_params(ofAbstractParameter &e)
{
//bool
if (e.type() == typeid(ofParameter<bool>).name())
{
ofParameter<bool> b = e.cast<bool>();
if (name == "BANG_1")
{
@moebiussurfing
moebiussurfing / cute & cool dark colors grid
Last active May 1, 2020 03:10
openFrameworks - example: cool colors grid
fontSmall.loadFont("Fonts/DIN.otf", 8 );
ofxGuiSetFont( "Fonts/DIN.otf", 8 );
ofxGuiSetDefaultWidth( 260 );
// --------------------------------
void draw()
{
// + background
ofBackgroundGradient( ofColor(40,40,40), ofColor(0,0,0), OF_GRADIENT_CIRCULAR);
@moebiussurfing
moebiussurfing / ofApp.h
Created November 28, 2019 00:14
create gui from class params post glitch
std::map<std::string, RenderPass::Ptr> passes;
ofxPanel gui;
void toggleListener(const void * sender, bool & value);