openframeworks / openframeworks/openFrameworks
add an example of a single-file project
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
my current starting point for prototyping new ideas with OF looks like this:
#include "ofAppGlutWindow.h"
#include "ofMain.h"
class ofApp : public ofBaseApp {
public:
void setup() {
}
void update() {
}
void draw() {
}
};
int main() {
ofAppGlutWindow window;
ofSetupOpenGL(&window, 1280, 720, OF_WINDOW);
ofRunApp(new ofApp());
}
that's a single-file project contained entirely in a main.cpp. i like it because it means i don't have to answer questions like "should this go in the header or not" when i'm only prototyping a small idea.
@bilderbuchi just suggested that it might be helpful to have a minimal example like this in the examples folder to show people how they might construct a single-file example for reporting bugs or suggesting features (for example like https://github.com/openframeworks/openFrameworks/issues/1674#issuecomment-11756116). i think that could be really cool, and i'd be glad to add this if other people are also interested. so this issue is more to gauge interest.
p.s.: as an aside, it would be cool if we had a macro like this:
#define ofStart(appName, width, height, windowMode) \
int main() {\
ofAppGlutWindow window;\
ofSetupOpenGL(&window, width, height, windowMode);\
ofRunApp(new appName());\
}
and ofMain.h included ofAppGlutWindow.h, then a minimal single-file example would look like:
#include "ofMain.h"
class ofApp : public ofBaseApp {
public:
void setup() {}
void update() {}
void draw() {}
};
ofStart(ofApp, 1280, 720, OF_WINDOW);
this idea is from cinder, which uses:
#if defined( CINDER_MAC )
#define CINDER_APP_BASIC( APP, RENDERER ) \
int main( int argc, char * const argv[] ) { \
cinder::app::AppBasic::prepareLaunch(); \
cinder::app::AppBasic *app = new APP; \
cinder::app::Renderer *ren = new RENDERER; \
cinder::app::AppBasic::executeLaunch( app, ren, #APP, argc, argv ); \
cinder::app::AppBasic::cleanupLaunch(); \
return 0; \
}
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing examples folder and the proposed single-file main.cpp shown in the issue. Add a minimal example that demonstrates this structure, and consider only the requested example scope; completion means the example is present and usable for prototyping or reproducing issues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100