diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 16 | ||||
| -rw-r--r-- | src/testApp.cpp | 141 | ||||
| -rw-r--r-- | src/testApp.h | 29 |
3 files changed, 186 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..ad74a97 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,16 @@ +#include "ofMain.h" +#include "testApp.h" +#include "ofAppGlutWindow.h" + +//======================================================================== +int main( ){ + + ofAppGlutWindow window; + ofSetupOpenGL(&window, 450,800, OF_WINDOW ); // <-------- setup the GL context + printf("%ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight()); + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + ofRunApp( new testApp()); + +} diff --git a/src/testApp.cpp b/src/testApp.cpp new file mode 100644 index 0000000..8aa0e05 --- /dev/null +++ b/src/testApp.cpp @@ -0,0 +1,141 @@ +#include "testApp.h" + +/* +openBTS visualisation + +ALL units relative to screen size in H or W + + +*/ + +void testApp::setup(){ + + printf("setup: %ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight()); + + int windowMode = ofGetWindowMode(); + if(windowMode == OF_FULLSCREEN){ + this->windowWidth = ofGetScreenWidth(); + this->windowHeight = ofGetScreenHeight(); + } + else if(windowMode == OF_WINDOW){ + this->windowWidth = ofGetWidth(); + this->windowHeight = ofGetHeight(); + } + + //Q Why is it that if you put a camera at (0,0,-100) looking at (0,0,0) and an object at (0,0,0) the camera isn't pointing at the object? + //A Because ortho is different + /* + camera.enableOrtho(); + camera.setPosition(-windowWidth/2,-windowHeight*4.1f,windowWidth); + //camera.lookAt(ofVec3f(-windowWidth/2,-windowHeight,0),ofVec3f(0, 1, 0)); + camera.rotate(70,1,0,0); + camera.cacheMatrices(); //stop error messages + */ + + ofSetFrameRate(30); + + ofSetCircleResolution(windowWidth); + ofEnableSmoothing(); + + camera.setPosition(0,windowHeight*10,windowHeight); + camera.lookAt(ofVec3f(0,0,-windowHeight*.5),ofVec3f(0, 0, 1)); + camera.setFov(6.5); + + lines = new ofPoint[25]; + for (int i=0;i<25;i++) { + float a=ofRandom(TWO_PI); + float r=ofRandom(windowWidth/2); + float l=ofRandom(windowHeight); + lines[i]=ofPoint(cos(a)*r,sin(a)*r,-l); + } + +} + + +//-------------------------------------------------------------- +void testApp::update(){ + + +} + +//-------------------------------------------------------------- +void testApp::draw(){ + + glDisable(GL_LIGHTING); + ofBackground(0,0,0); + + camera.begin(); + + //ofSphere(0,0,0,10); + + glDisable(GL_DEPTH_TEST); + ofSetHexColor(0xff7fff); + glDisable(GL_BLEND); + + ofPushMatrix(); + ofNoFill(); + for (float f=0;f<windowWidth*0.6;f+=windowWidth/10) { + ofCircle(0,0,0,f); + } + ofPopMatrix(); + + ofSetHexColor(0x8f8f8f); + for (int i=0;i<25;i++) { + ofLine(lines[i].x,lines[i].y,0,lines[i].x,lines[i].y,lines[i].z); + } + + camera.end(); + + ofSetHexColor(0xffffff); + char reportStr[1024]; + sprintf(reportStr, "fps: %f", ofGetFrameRate()); + ofDrawBitmapString(reportStr, 10, windowHeight-10); +} + +//-------------------------------------------------------------- +void testApp::keyPressed(int key){ + switch (key){ + case ' ': + break; + } +} + +//-------------------------------------------------------------- +void testApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void testApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void testApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mousePressed(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void testApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void testApp::dragEvent(ofDragInfo dragInfo){ + +} diff --git a/src/testApp.h b/src/testApp.h new file mode 100644 index 0000000..36e6f54 --- /dev/null +++ b/src/testApp.h @@ -0,0 +1,29 @@ +#include "ofMain.h" + + + +class testApp : public ofBaseApp{ + + public: + void setup(); + void update(); + void draw(); + + void keyPressed(int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + + int windowWidth, windowHeight; + + ofCamera camera; + + ofPoint *lines; + +}; + |
