summaryrefslogtreecommitdiff
path: root/polyTest/src
diff options
context:
space:
mode:
Diffstat (limited to 'polyTest/src')
-rw-r--r--polyTest/src/main.cpp24
-rw-r--r--polyTest/src/ofApp.cpp132
-rw-r--r--polyTest/src/ofApp.h35
3 files changed, 191 insertions, 0 deletions
diff --git a/polyTest/src/main.cpp b/polyTest/src/main.cpp
new file mode 100644
index 0000000..02b6b14
--- /dev/null
+++ b/polyTest/src/main.cpp
@@ -0,0 +1,24 @@
+#include "ofMain.h"
+#include "ofApp.h"
+
+
+//========================================================================
+int main(int argc, char *argv[]){
+
+
+ ofGLFWWindowSettings settings;
+
+
+ settings.width = 1200;
+ settings.height = 900;
+
+ //1200 = 13.2° = 42898 pts theoretical
+
+ shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
+
+ shared_ptr<ofApp> mainApp(new ofApp);
+
+ ofRunApp(mainWindow, mainApp);
+ ofRunMainLoop();
+}
+ \ No newline at end of file
diff --git a/polyTest/src/ofApp.cpp b/polyTest/src/ofApp.cpp
new file mode 100644
index 0000000..1553666
--- /dev/null
+++ b/polyTest/src/ofApp.cpp
@@ -0,0 +1,132 @@
+#include "ofApp.h"
+#include "glew.h"
+
+
+//--------------------------------------------------------------
+void ofApp::setup(){
+
+}
+
+
+
+//--------------------------------------------------------------
+void ofApp::update(){
+
+
+}
+
+ofPolyline ofApp::polyLineTransform(const ofPolyline& poly, ofMatrix4x4 xform){
+ ofPolyline tempPoly;
+ for (auto& p:poly){
+ tempPoly.addVertex(ofVec3f(p)*xform);
+ }
+ return tempPoly;
+}
+
+ofPolyline makePolygon(int num,float diam){
+ ofPolyline poly;
+ float step=PI*2/num;
+ for (int i=0;i<=num;i++){
+ poly.addVertex(cos(step*i)*diam,sin(step*i)*diam);
+ }
+ return poly;
+}
+
+void drawPoly(ofPolyline poly,float x,float y){
+ glPushMatrix();
+ ofTranslate(x,y);
+ poly.draw();
+ for (int i=0;i<poly.size();i++){
+ ofDrawBitmapString(poly.getDegreesAtIndex(i),poly[i].x+10,poly[i].y+10,0);
+ }
+ glPopMatrix();
+}
+
+
+//--------------------------------------------------------------
+void ofApp::draw(){
+ ofBackground(0,0,0);
+ ofSetColor(255,255,255);
+
+ ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+ ofRotate(0,0,1,ofGetElapsedTimef()*50);
+ drawPoly(makePolygon(4,200),200,200);
+ drawPoly(makePolygon(5,200),-200,200);
+ drawPoly(makePolygon(6,200),-200,-200);
+
+
+
+
+}
+
+
+//--------------------------------------------------------------
+void ofApp::exit() {
+
+}
+
+
+
+//--------------------------------------------------------------
+void ofApp::keyPressed(ofKeyEventArgs &args){
+
+
+
+}
+
+
+//--------------------------------------------------------------
+void ofApp::keyReleased(int key){
+
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseEntered(int x, int y){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseExited(int x, int y){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::windowResized(int w, int h){
+
+}
+
+void ofApp::outputWindowResized(ofResizeEventArgs &resizeargs){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::dragEvent(ofDragInfo dragInfo){
+
+
+}
diff --git a/polyTest/src/ofApp.h b/polyTest/src/ofApp.h
new file mode 100644
index 0000000..316649c
--- /dev/null
+++ b/polyTest/src/ofApp.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include "ofMain.h"
+
+
+
+class ofApp : public ofBaseApp{
+
+ public:
+ void setup();
+ void update();
+ void updateOutput(ofEventArgs & args);
+ void draw();
+ void drawOutput(ofEventArgs & args);
+ void exit();
+
+ void outputKeyPressed(ofKeyEventArgs & args);
+
+ void keyPressed(ofKeyEventArgs &keyargs);
+ 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 mouseEntered(int x, int y);
+ void mouseExited(int x, int y);
+ void windowResized(int w, int h);
+ void outputWindowResized(ofResizeEventArgs &resizeargs);
+ void dragEvent(ofDragInfo dragInfo);
+ void gotMessage(ofMessage msg);
+
+ ofPolyline polyLineTransform(const ofPolyline& poly, ofMatrix4x4 xform);
+
+
+};