Skip to content

Instantly share code, notes, and snippets.

@hiroMTB
Last active December 30, 2018 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiroMTB/6306b682d36281523dc0c8e5bf8cdb35 to your computer and use it in GitHub Desktop.
Save hiroMTB/6306b682d36281523dc0c8e5bf8cdb35 to your computer and use it in GitHub Desktop.
ofxGui, NOT working example
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1024,768, OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp( new ofApp());
}
//
// MyClass.h
//
#pragma once
#include "ofxGui.h"
class MyClass{
public:
MyClass(int i){
string name = "settings" + ofToString(i);
gui.setup(name, name+".xml", i*220, 0);
gui.add(grp);
gui.loadFromFile(name+".xml");
}
void draw(){
gui.draw();
}
ofParameter<int> myInt{"MyInt", 0, 0, 100};
ofParameterGroup grp{"My Class", myInt};
ofxPanel gui;
};
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
for(int i=0; i<3; i++){
myClasses.push_back(i);
}
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
for(auto & c : myClasses){
c.draw();
}
}
#pragma once
#include "ofMain.h"
#include "MyClass.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
vector<MyClass> myClasses;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment