やりたいこと
簡単なコードを書くのにmain.cpp, ofApp.cpp, ofApp.hファイル分けて行ったり来たりするのがめんどくさいので、アプリケーションの記述をmain.cppに集中させたい。
main.cpp
main.cppに全部書く。
// main.cpp
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
void setup(){
ofBackground(0);
}
void update(){
x += direction;
if( x > ofGetWidth() || x < 0.0 ){
direction *= -1; // bounce
}
}
void draw(){
ofDrawCircle(x, ofGetHeight()/2, 100);
}
// Define members here.
float x = 0.0, direction = 8.0;
};
//========================================================================
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());
}
ofApp.hとofApp.cpp
必要ないのでファイルごと削除する。