Skip to content

Instantly share code, notes, and snippets.

@hiroMTB
Created December 28, 2018 21:55
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/07cb8207a7c24cdda10b2d876e83c69a to your computer and use it in GitHub Desktop.
Save hiroMTB/07cb8207a7c24cdda10b2d876e83c69a to your computer and use it in GitHub Desktop.
ofxGui, Single Panel 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
class MyClass{
public:
ofParameter<int> myInt{"MyInt", 0, 0, 100};
ofParameterGroup grp{"My Class", myInt};
};
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
gui.setup("settings", "settings.xml");
for(int i=0; i<3; i++){
myClasses.push_back(MyClass());
myClasses.back().grp.setName("My Class " + ofToString(i));
gui.add(myClasses.back().grp);
}
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
gui.draw();
}
#pragma once
#include "ofMain.h"
#include "ofxGui.h"
#include "MyClass.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
vector<MyClass> myClasses;
ofxPanel gui;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment