Skip to content

Commit

Permalink
JLine buffer func
Browse files Browse the repository at this point in the history
  • Loading branch information
jildertviet committed Mar 21, 2023
1 parent d39ea9b commit 0175810
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
Binary file modified exampleSimple/bin/exampleSimple
Binary file not shown.
31 changes: 22 additions & 9 deletions src/Event/JLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,28 @@ void JLine::toRect(ofVec2f loc, ofVec2f size){
// Make env to move loc and size
}

void JLine::fromBuffer(){
cout << "Fill from buffer" << endl;
void JLine::fromBuffer(int bufferMode){
// cout << "Fill from buffer" << endl;
mode = 2;
line.clear();
line.addVertex(buffer[0], buffer[1]);
for(int i=1; i<buffer.size()/2; i++){
glm::vec2 v = glm::vec2(buffer[i*2], buffer[i*2+1]);
line.lineTo(ofPoint(v));
switch(bufferMode){
case 0:{
line.addVertex(buffer[0], buffer[1]);
for(int i=1; i<buffer.size()/2; i++){
glm::vec2 v = glm::vec2(buffer[i*2], buffer[i*2+1]);
line.lineTo(ofPoint(v));
}
}
break;
case 1:{
for(int i=0; i<buffer.size(); i++){
float x = size.x / buffer.size();
x *= i;
glm::vec2 v = glm::vec2(x, buffer[i]);
line.lineTo(ofPoint(v));
}
}
break;
}

// line.addVertex(buffer[buffer.size()-2], buffer[buffer.size()-1]);
Expand Down Expand Up @@ -114,6 +128,5 @@ void JLine::calcLine(){
}
}

void JLine::customOne(float* v){
fromBuffer();
}
void JLine::customOne(float* v){fromBuffer(0);}
void JLine::customTwo(float* v){fromBuffer(1);}
3 changes: 2 additions & 1 deletion src/Event/JLine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ class JLine: public JEvent{

void toRect(ofVec2f loc, ofVec2f size);

void fromBuffer();
void fromBuffer(int bufferMode = 0);
void setLoc(glm::vec3 loc) override;
void setSize(glm::vec3 size) override;
void calcLine();

void customOne(float* v = nullptr) override;
void customTwo(float* v = nullptr) override;
};
#endif /* JLine_hpp */
2 changes: 1 addition & 1 deletion src/MsgParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ bool MsgParser::setBuffer(ofxOscMessage& m){
int numFrames = m.getNumArgs()-4;
target->buffer.clear();
for(int i=0; i<numFrames; i++){
cout << "Add frame: " << m.getArgAsFloat(i+4) << endl;
// cout << "Add frame: " << m.getArgAsFloat(i+4) << endl;
target->buffer.push_back(m.getArgAsFloat(i+4));
}
} else{
Expand Down

0 comments on commit 0175810

Please sign in to comment.