Commit 11c56e00 authored by Lky's avatar Lky

update for no arduino usage, basics on glitch lines [wip]

parent 2b3c8eb5
......@@ -265,9 +265,9 @@ void main()
vec3 color_layer_1, color_layer_2;
vec3 background_color = vec3(0,0,0);
color_layer_1 = mix(channel_1.rgb, background_color, opBC_ch1);
color_layer_1 = mix(background_color, channel_1.rgb, opBC_ch1);
color_layer_1 = ContrastSaturationBrightness(color_layer_1,1,1,1);
color_layer_2 = mix(channel_2.rgb, background_color, opBC_ch2);
color_layer_2 = mix(background_color, channel_2.rgb, opBC_ch2);
color_layer_2 = ContrastSaturationBrightness(color_layer_2,1,1,1);
......@@ -314,12 +314,8 @@ void main()
if(blendmode == 0) {
color = mix(color_layer_1,color_layer_2,main_opacity);
} else {
//color_layer_1 = mix(color_layer_1,vec3(0,0,0),main_opacity*2);
//color_layer_1 = mix(vec3(0,0,0),color_layer_2,main_opacity*2);
color = BlendColor(color_layer_1,color_layer_2,blendmode);
//vec3 color_mix = mix(color_layer_1,color_layer_2,main_opacity);
}
//color = mix(vec3(1,0,0),vec3(0,0,1),sin_val);
// note:: CSB goes from effect to negative (if mouseX from 1 to -1).
outputColor = vec4(color,1); //channel_2.r);
......
#include "ofApp.h"
#define INTERFACE_
#define ARDUINO
#define ARDUINO_
#define WRITE_INFO
#define REBOUNCE_DELAY_MS 10
......@@ -28,6 +28,9 @@ void ofApp::setup()
framerate = 60;
x_gl = 0; x_main = 0; x_ch1 = 0; x_pos_ch1 = 0; x_pos_ch2 = 0;
x_sub = 0; w_sub = ofGetWidth(); sx_sub = -1000;
main_fbo.allocate(MAIN_W, MAIN_H, GL_RGB);
fbo_ch1.allocate(MAIN_W, MAIN_H, GL_RGB);
......@@ -37,6 +40,8 @@ void ofApp::setup()
gray = new unsigned char[w*h];
grayTex.allocate(w,h,GL_LUMINANCE);
w_fbo = MAIN_H;
recording = false;
record_actual_frame = 0;
playing_record = false;
......@@ -50,6 +55,7 @@ void ofApp::setup()
settings.folderPath = "recording";
recorder.setup(settings);*/
#ifdef TARGET_OPENGLES
shader.load("shadersES2/shader");
cout << "ES2 loaded";
......@@ -68,9 +74,10 @@ void ofApp::setup()
ard.connect("COM5", 57600);
ard.sendFirmwareVersionRequest();
ofAddListener(ard.EInitialized, this, &ofApp::setupArduino);
bSetupArduino = false; // flag so we setup arduino when its ready, you don't need to touch this :)
#endif
bSetupArduino = false; // flag so we setup arduino when its ready, you don't need to touch this :)
blendmode = 0;
count_1 = 0; count_2 = 0; count_3 = 0; count_4 = 0; count_5 = 0;
......@@ -88,7 +95,7 @@ void ofApp::setup()
extension_3channel = 100;
opBC_ch1 = 1; opBC_ch2 = 1; opBC_ch3 = 1;
main_opacity = .5;
main_opacity = 0.5;
//// GETTING FILES NAMES
//ofDirectory dir;
......@@ -127,7 +134,6 @@ void ofApp::setup()
hap_noise.load("rushes/noise_1500_1080.mov");
hap_noise.play();
hap_noise.setSpeed(4);
hap_noise.setLoopState(OF_LOOP_NORMAL);
background_image.load(background_path);
......@@ -202,8 +208,6 @@ void ofApp::update()
#ifdef ARDUINO
updateArduino();
#else
//opBC_ch1 = sin(actual_frame * PI / 180) + 1;
#endif
if (!playing_record) {
......@@ -217,27 +221,11 @@ void ofApp::update()
}*/
}
/*float noiseScale = ofMap(mouseX, 0, ofGetWidth(), 0, 0.1);
float noiseVel = ofGetElapsedTimef();
ofPixels & pixels = noise_img.getPixels();
int w = noise_img.getWidth();
int h = noise_img.getHeight();
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
int i = y * w + x;
float noiseVelue = ofNoise(x * noiseScale, y * noiseScale, noiseVel);
pixels[i] = 255 * noiseVelue;
}
}
noise_img.update();*/
ofSetColor(255, 255, 255, 255);
fbo_ch1.begin();
ofClear(0,0,0);
hap_ch1.draw(x_pos_ch1,0);
//hap_ch1.draw(0, 0);// ofGetWidth(), ofGetHeight());
fbo_ch1.end();
fbo_ch2.begin();
......@@ -299,7 +287,6 @@ void ofApp::update()
case 12:
blendName = "burn";
break;
}
}
......@@ -307,8 +294,9 @@ void ofApp::update()
void ofApp::draw()
{
float sin_val = opBC_ch1;// sin(actual_frame * PI / 180);
//float sin_val = opBC_ch1;// sin(actual_frame * PI / 180);
string windowName = ofToString(ofGetFrameRate()) + " - speeds: "+ ofToString(speed_ch1) + "-"+ofToString(speed_ch2) + "-"+ ofToString(speed_ch3) + " : opBC: " + "-" + ofToString(opBC_ch1) + "-" + ofToString(opBC_ch2) + "-" + ofToString(opBC_ch3) + " - blendmode::" + ofToString(blendmode);
windowName += "x_sub:"+ ofToString(x_sub)+", w_sub:" + ofToString(w_sub) + ", sx_sub:" + ofToString(sx_sub) + ".";
ofSetWindowTitle(windowName);
ofScale(1); // 3 is better
......@@ -322,20 +310,16 @@ void ofApp::draw()
shader.begin();
#ifdef TARGET_OPENGLES
// when texture coordinates are normalised, they are always between 0 and 1.
// in GL2 and GL3 the texture coordinates are not normalised,
// so we have to multiply the normalised mouse position by the plane width.
// mousePosition *= plane.getWidth();
#endif
/*shader.setUniform1f("mouseX", mousePositionX);
shader.setUniform1f("mouseY", mousePositionY);*/
ofPushMatrix();
shader.setUniform1f("mouseX", 5*mouseX/ofGetHeight());
shader.setUniform1f("mouseY", 5*mouseY/ofGetWidth());
shader.setUniform1f("mouseX",200);
shader.setUniform1f("mouseY",200);
/*shader.setUniform1f("mouseX", 5*mouseX/ofGetHeight());
shader.setUniform1f("mouseY", 5*mouseY/ofGetWidth());*/
shader.setUniform1i("blendmode", blendmode);
......@@ -355,15 +339,15 @@ void ofApp::draw()
shader.setUniformTexture("noise_texture", fbo_noise.getTexture(), 5);
fbo_ch3.draw(0,0);
fbo_ch3.draw(x_gl,0);
ofPopMatrix();
shader.end();
main_fbo.end();
extension_3channel = sin_val;
main_fbo.getTexture().drawSubsection(0, 0, ofGetWidth(), 1500, -1000, 0);
//extension_3channel = sin_val;
main_fbo.getTexture().drawSubsection(x_sub, 0, w_sub, 1500, sx_sub, 0);
//main_fbo.draw(800, 0, 1080*1, 1500*1.3);
//fbo_noise.draw(0, 0);
......@@ -387,9 +371,11 @@ void ofApp::draw()
string to_write = "";
for (int i = 0; i < buttonNumber; ++i) {
to_write += ofToString(i) + ":"+ofToString(list_of_buttons[i].clickCount) + ", ";
if (i == 4) {
to_write += "\n test ";
}
}
font.drawString(to_write, 200, 100);
// font.drawString(ofToString(list_of_buttons[0].clickCount) + "," + ofToString(list_of_buttons[1].clickCount) + "," + ofToString(list_of_buttons[2].clickCount) + "," + ofToString(list_of_buttons[3].clickCount), 200, 100);
font.drawString(to_write, 300, 100);
}
#endif
......@@ -404,6 +390,23 @@ void ofApp::exit()
void ofApp::keyPressed(int key){
switch (key) {
// SPEEDS
case '4':
w_fbo += 20;
x_pos_ch1 += 10;
x_pos_ch2 += 10;
x_sub -= 20;
main_fbo.allocate(w_fbo, MAIN_H, GL_RGB);
break;
case '3':
if (w_fbo > 20) {
w_fbo -= 20;
x_pos_ch1 -= 10;
x_pos_ch2 -= 10;
x_sub += 20;
}
main_fbo.allocate(w_fbo, MAIN_H, GL_RGB);
break;
case 'q':
speed_ch1 += 0.2;
hap_ch1.setSpeed(speed_ch1);
......@@ -461,6 +464,31 @@ void ofApp::keyPressed(int key){
opBC_ch3 -= 0.1;
break;
case '[':
x_sub -= 10;
break;
case ']':
x_sub += 10;
break;
case '(':
w_sub -= 10;
break;
case ')':
w_sub += 10;
break;
case '\\':
sx_sub -= 10;
break;
case '|':
sx_sub += 10;
break;
case '{':
x_ch1 -= 10;
break;
case '}':
x_ch1 += 10;
break;
// BLENDMODES AND MAIN OPACITY
case OF_KEY_RIGHT:
......@@ -484,7 +512,10 @@ void ofApp::keyPressed(int key){
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
#ifdef INTERFACE
#elseif
ofHideCursor();
#endif
}
//--------------------------------------------------------------
......@@ -531,7 +562,7 @@ void ofApp::setupArduino(const int & version) {
// If using Arduino 0022 or older, then use 16 - 21.
// Firmata pin numbering changed in version 2.3 (which is included in Arduino 1.0)
buttonNumber = 8;
buttonNumber = 10;
list_of_buttons = new buttonStruct[buttonNumber];
for (int i = 0; i < buttonNumber; i++)
{
......@@ -547,8 +578,10 @@ void ofApp::setupArduino(const int & version) {
list_of_buttons[3].pinNumber = 5;
list_of_buttons[4].pinNumber = 6;
list_of_buttons[5].pinNumber = 7;
list_of_buttons[6].pinNumber = 8;
list_of_buttons[7].pinNumber = 9;
list_of_buttons[6].pinNumber = 10;
list_of_buttons[7].pinNumber = 11;
list_of_buttons[8].pinNumber = 12;
list_of_buttons[9].pinNumber = 13;
//// Initialiser les PIN de tous les boutons grer
for (int i = 0; i < buttonNumber; i++)
......@@ -576,16 +609,16 @@ void ofApp::setupArduino(const int & version) {
ard.sendAnalogPinReporting(7, ARD_ANALOG);
// set pin D13 as digital output
ard.sendDigitalPinMode(13, ARD_OUTPUT);
// ard.sendDigitalPinMode(13, ARD_OUTPUT);
// set pin A4 as digital output
ard.sendDigitalPinMode(18, ARD_OUTPUT); // pin 20 if using StandardFirmata from Arduino 0022 or older
// set pin D11 as PWM (analog output)
ard.sendDigitalPinMode(11, ARD_PWM);
// ard.sendDigitalPinMode(11, ARD_PWM);
// attach a servo to pin D9
// servo motors can only be attached to pin D3, D5, D6, D9, D10, or D11
ard.sendServoAttach(9);
// ard.sendServoAttach(9);
// Listen for changes on the digital and analog pins
//ofAddListener(ard.EDigitalPinChanged, this, &ofApp::digitalPinChanged);
......@@ -758,6 +791,7 @@ void ofApp::analogPinChanged(const int & pinNum) {
}
//}
}
if (pinNum == 2) {
potar_2 = ofMap(ard.getAnalog(pinNum), 0, 1024, 0, 1);
//potar_10 = roundf(potar_10 * 10) / 10;
......
......@@ -110,6 +110,10 @@ public:
float opBC_ch1, opBC_ch2, opBC_ch3, extension_3channel;
string blendName;
// Setup for tests
int x_gl, x_main, x_ch1;
int x_sub, w_sub, sx_sub;
int w_fbo;
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment