Hi folks
I am trying to get my openFrameworks window out of Syphon and in MadMapper. I can do it with the example code, no problem. I think the issue is that my code relies on the background not refreshing, creating a trailing circle. This does not display correctly. I do not know how to fix it or if it is even fixable/possible. I tried to load to a texture, but whatever I did, it failed.
what it should look like
type or paste code here
#include "ofApp.h"
//-----------------------------------------------------
void ofApp::setup(){
//General Code Setup
ofBackground(0);
ofSetFrameRate(60);
//SetBools
bC1 = false;
bC2 = false;
bC3 = false;
bAutoOn = false;
//SyphonStuff
mainOutputSyphonServer.setName("Screen Output");
mClient.setup();
mClient.set("","Simple Server");
}
//-----------------------------------------------------
void ofApp::update(){
}
//----------------------------------------------------
void ofApp::draw(){
//if I turn on the glClear, the pattern does not draw as
//it requires the background to not refresh.
// glClearColor(0.0, 0.0, 0.0, 0.0);
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ofSetBackgroundAuto(false);
//draw the cirle pattern
pattern();
if(bAutoOn == true){
int b = ofRandom(4);
if (b==2){
autoPattern();
}
int a = ofRandom(75);
if (a ==3){
ofClear(0, 255);
}
}
mainOutputSyphonServer.publishScreen();
}
//-----------------------------------------------------
void ofApp::pattern(){
float nPosX = posX + ofRandom(3,5);
float nPosY = posY + ofRandom(3,15);
float wander = ofRandom(5);
ofSetCircleResolution(200);
ofSetLineWidth(ofRandom(0.01,2));
//Set lerp amount
float cc = ofMap(posY,0,ofGetWidth(),0,1);
float ca = ofMap(posY,0,ofGetHeight(),0,100);
// set red, component by component
ofColor red;
red.r=255;
red.g=0;
red.b=0;
red.a =ca;
ofColor blue;
blue.r=0;
blue.g=0;
blue.b=255;
red.a =ca;
ofColor yellow;
yellow.r=255;
yellow.g=255;
yellow.b=0;
yellow.a =ca;
ofColor orange;
orange.r=255;
orange.g=165;
orange.b=0;
orange.a =ca;
ofColor green;
green.r=0;
green.g=255;
green.b=0;
green.a =ca;
if (bC1 ==true){
output = red;
ofColor newColor = output.lerp(blue, cc);
ofSetColor (newColor);
}
if (bC2 ==true){
output= yellow;
ofColor newColor = output.lerp(red, cc);
ofSetColor (newColor);
}
if (bC3 ==true){
output = blue;
ofColor newColor = output.lerp(green, cc);
ofSetColor (newColor);
}
ofNoFill();
ofDrawEllipse(posX, posY, nPosX/2+wander, nPosY/2+wander);
ofSetLineWidth(ofRandom(0.1,3));
ofDrawEllipse(posX, posY, nPosX/2, nPosY/2);
ofSetLineWidth(ofRandom(0.4,2.5));
ofDrawEllipse(posX, posY, nPosX/4, nPosY/4);
//update values for posX, posY
posX = nPosX;
posY = nPosY;
}
void ofApp::autoPattern(){
ofSetColor(ofRandom(255),ofRandom(255), ofRandom(255), ofRandom(100,255));
posX = ofRandom(100, ofGetWidth());
posY = ofRandom(100, ofGetHeight());
float nPosX = posX + ofRandom(3,5);
float nPosY = posY + ofRandom(3,15);
float wander = ofRandom(5);
ofSetCircleResolution(200);
ofSetLineWidth(ofRandom(1.5,7.5));
ofNoFill();
ofDrawEllipse(posX, posY, nPosX/2+wander, nPosY/2+wander);
ofSetLineWidth(ofRandom(0.1,3));
ofDrawEllipse(posX, posY, nPosX/2, nPosY/2);
ofSetLineWidth(ofRandom(0.4,2.5));
ofDrawEllipse(posX, posY, nPosX/4, nPosY/4);
//update values for posX, posY
posX = nPosX;
posY = nPosY;
}
//-----------------------------------------------------
void ofApp::keyPressed(int key){
if (key == 'c') {
ofClear(0, 255);
}
if (key == 'a') {
bC1=true;
bC2= false;
bC3 = false;
}
if (key == 's') {
bC1=false;
bC2= true;
bC3 = false;
}
if (key == 'd') {
bC1=false;
bC2= false;
bC3 = true;
}
if (key == 'z') {
ofClear(0, 255);
bAutoOn = !bAutoOn;
}
}
//-----------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
posX = mouseX;
posY = mouseY;
}
//-----------------------------------------------------
type or paste code here
#pragma once
#include "ofMain.h"
#include "ofxSyphon.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void mousePressed(int x, int y, int button);
void pattern();
void autoPattern();
float posX;
float posY;
float h,s,b;
ofColor output;
bool bC1,bC2,bC3;
bool bAutoOn;
//syphon stuff
ofxSyphonServer mainOutputSyphonServer;
ofxSyphonClient mClient;
};