Exemplo n.º 1
0
// oF < 0.8.1 does not have ofShader::getShaderSource, so we just cut
// out some of the necessary code from ofShader to get the source in the
// same way as ofShader::load did in version a90a782 (2014, April 10th.)
//
// Note that in this legacy mode, we don't support shader includes (as
// ofShader does in 0.8.1).
bool ofxFXObject::load(string path){
    string vertName = path + ".vert";
    string fragName = path + ".frag";
    string frag = "";
    string vert = "";

    if (fragName.empty() == false){
        ofBuffer buffer = ofBufferFromFile(fragName);
        frag = buffer.getText();
    }
    if (vertName.empty() == false){
        ofBuffer buffer = ofBufferFromFile(vertName);
        vert = buffer.getText();
    }

    if (frag.empty() && vert.empty()){
        ofLog(OF_LOG_ERROR, "Could not load shader from file " + path);
        return false;
    }

    bool loaded = setCode(frag, vert);
    if (loaded)
        shaderFilePath = path;
    return loaded;
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
//
bool ofxAutoReloadedShader::load(string vertName, string fragName, string geomName)
{
	unload();
	
    ofShader::setGeometryOutputCount(geometryOutputCount);
    ofShader::setGeometryInputType(geometryInputType);
    ofShader::setGeometryOutputType(geometryOutputType);

    
	// hackety hack, clear errors or shader will fail to compile
	GLuint err = glGetError();
	
	lastTimeCheckMillis = ofGetElapsedTimeMillis();
	setMillisBetweenFileCheck( 2 * 1000 );
	enableWatchFiles();
	
	loadShaderNextFrame = false;
	
	vertexShaderFilename = vertName;
	fragmentShaderFilename = fragName;
	geometryShaderFilename = geomName;
	
	vertexShaderFile.clear();
	fragmentShaderFile.clear();
	geometryShaderFile.clear();
	
	vertexShaderFile   = ofFile( ofToDataPath( vertexShaderFilename ) );
	fragmentShaderFile = ofFile( ofToDataPath( fragmentShaderFilename ) );
	geometryShaderFile = ofFile( ofToDataPath( geometryShaderFilename ) );
	
	ofBuffer vertexShaderBuffer = ofBufferFromFile( ofToDataPath( vertexShaderFilename ) );
	ofBuffer fragmentShaderBuffer = ofBufferFromFile( ofToDataPath( fragmentShaderFilename ) );
	ofBuffer geometryShaderBuffer = ofBufferFromFile( ofToDataPath( geometryShaderFilename ) );
	
	fileChangedTimes.clear();
	fileChangedTimes.push_back( getLastModified( vertexShaderFile ) );
	fileChangedTimes.push_back( getLastModified( fragmentShaderFile ) );
	fileChangedTimes.push_back( getLastModified( geometryShaderFile ) );
	
	if( vertexShaderBuffer.size() > 0 )
	{
		setupShaderFromSource(GL_VERTEX_SHADER, vertexShaderBuffer.getText() );
	}

	if( fragmentShaderBuffer.size() > 0 )
	{
		setupShaderFromSource(GL_FRAGMENT_SHADER, fragmentShaderBuffer.getText());
	}

	#ifndef TARGET_OPENGLES
	if( geometryShaderBuffer.size() > 0 )
	{
		setupShaderFromSource(GL_GEOMETRY_SHADER_EXT, geometryShaderBuffer.getText());
	}
	#endif

	bindDefaults();
	
	return linkProgram();
}
Exemplo n.º 3
0
bool UIShader::reloadShader(string _fragPath, string _vertPath, string _geomPath){
    ofShader::unload();
	
	// hackety hack, clear errors or shader will fail to compile
	GLuint err = glGetError();
	
    fragFile.clear();
    fragFilename = ofToDataPath( _fragPath );
    fragFile = ofFile( fragFilename );
    fragChangedTimes = getLastModified( fragFile );
    ofBuffer fragBuffer = ofBufferFromFile( fragFilename );
    if( fragBuffer.size() > 0 ){
        setupShaderFromSource(GL_FRAGMENT_SHADER, fragBuffer.getText());
    }
    
    
    if (_vertPath != ""){
        vertFile.clear();
        vertFilename = ofToDataPath(_vertPath);
        vertFile = ofFile( vertFilename );
        vertChangedTimes = getLastModified( vertFile );
        ofBuffer vertBuffer = ofBufferFromFile( vertFilename );
        
        if( vertBuffer.size() > 0 ){
            setupShaderFromSource(GL_VERTEX_SHADER, vertBuffer.getText());
        }
        
        bVertex = true;
    }
    
    if (_geomPath != ""){
        geomFile.clear();
        geomFilename = ofToDataPath(_geomPath);
        geomFile = ofFile( geomFilename );
        geomChangedTimes = getLastModified( geomFile );
        ofBuffer geomBuffer = ofBufferFromFile( geomFilename );
        
        if( geomBuffer.size() > 0 ){
            setupShaderFromSource(GL_GEOMETRY_SHADER, geomBuffer.getText());
        }
        
        setGeometryInputType(geomInType);
        setGeometryOutputType(geomOutType);
        setGeometryOutputCount(geomOutCount);
        
        bGeometry = true;
    }
    
	lastTimeCheckMillis = ofGetElapsedTimeMillis();
    
    if (linkProgram()){
        extractUniforms(fragBuffer.getText());
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 4
0
Compiler::Compiler(ProcessTaskQueue& taskQueue,
                   const std::string& pathToTemplates,
                   const std::string& openFrameworksDir):
    _taskQueue(taskQueue),
    _pathToTemplates(pathToTemplates),
    _projectFileTemplate(ofBufferFromFile(ofToDataPath(_pathToTemplates + "/main.tmpl")).getText()),
    _classTemplate(ofBufferFromFile(ofToDataPath(_pathToTemplates + "/class.tmpl")).getText()),
    _openFrameworksDir(openFrameworksDir)
{
}
//--------------------------------------------------------------
void ofxEasyFboGlitch::draw(ofFbo _fbo,float _drawX,float _drawY,float _drawW,float _drawH){
    fbo.begin();
    ofSetColor(255);
    ofBackground(0);
    _fbo.draw(0,0,fboW,fboH);
    fbo.end();
        if(glitchReset){
            reader.readToPixels(fbo, pix);
            glitchImg.setFromPixels(pix);
            glitchReset=false;
        }
        string breakImgName="glitch.jpg";
        glitchImg.saveImage(breakImgName,imgQuality);
        ofBuffer file= ofBufferFromFile(breakImgName);
        int fileSize=file.size();
        char *buffer = file.getBinaryBuffer();
        int whichByte=(int)ofRandom(fileSize);
        int whichBit =ofRandom(8);
        char bitMask = 1<< whichBit;
        buffer[whichByte] |= bitMask;
        ofBufferToFile(breakImgName,file);
        glitchImg.loadImage(breakImgName);
        if (ofRandom(1)<glitchResetProbability) {
            glitchReset=true;
        }
    glitchImg.draw(_drawX, _drawY, _drawW,_drawH);
}
Exemplo n.º 6
0
//--------------------------------------------------------------
void testApp::setup() {
    
    ofBackgroundHex(0xff72a1);
    ofSetFrameRate(30);
    
    nextLetterTime = ofGetElapsedTimeMillis();
    lineCount      = 0;
    letterCount    = 0;
    
    // this is our buffer to stroe the text data
    ofBuffer buffer = ofBufferFromFile("ohplaces.txt");
    
    if(buffer.size()) { 
                
        // we now keep grabbing the next line
        // until we reach the end of the file
        while(buffer.isLastLine() == false) {
            
            // move on to the next line
            string line = buffer.getNextLine();
            
            // copy the line to draw later
            // make sure its not a empty line
            if(line.empty() == false) {
                seussLines.push_back(line);
            }
            
            // print out the line
            cout << line << endl;
            
        }
        
    }
    
}
Exemplo n.º 7
0
void ofApp::setupFinderItems(){

    // file -> buffer
    ofBuffer buffer = ofBufferFromFile("finderItems.txt");
    
    // buffer -> vec2f
    if(buffer.size()) {
        while(buffer.isLastLine() == false) {
            
            string line = buffer.getNextLine();
            
            if(line.empty() == false) {
                vector<string> words = ofSplitString(line, " ");
                FinderItem tmpItem = FinderItem(ofVec2f(ofToFloat(words[3]), ofToFloat(words[4])));
                items.push_back(tmpItem);
            }
        }
    } // load end

    // debug info
    cout << "FinderItems size:" << items.size() << endl;
    for (int i=0; i<items.size(); i++) {
        cout << "item[" << i << "] " << items[i]._p.x << ":" << items[i]._p.y << endl;
    }
}
Exemplo n.º 8
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofBackground(100);
    ofSetColor(255);
    
    //Load TMX file
    ofBuffer buffer = ofBufferFromFile("example.tmx");
    map->ParseText(buffer.getText());

    //Check error
    if (map->HasError()) {
		printf("error code: %d\n", map->GetErrorCode());
		printf("error text: %s\n", map->GetErrorText().c_str());
		system("PAUSE");
        
		return map->GetErrorCode();
	}
    
    //Debug info
    printDebugInfo();
    
    //Load images
    for (int i = 0; i < map->GetNumTilesets(); ++i) {
        //tileSheet.loadImage("tmw_desert_spacing.png");
        tileSheets.push_back(ofImage());
        (tileSheets.back()).loadImage( map->GetTileset(i)->GetImage()->GetSource().c_str() );
    }
    
    
}
Exemplo n.º 9
0
//--------------------------------------------------------------
void testApp::setup(){
	ofSetWindowTitle("Ailove-Instagram-Stat");
	ofBackground(0);

	min_lat = 1e8;
	min_lng = 1e8;
	max_lat =-1e8;
	max_lng =-1e8;

	ofBuffer b = ofBufferFromFile("stat.csv");
	b.getNextLine();
	while (!b.isLastLine()) {
		string s = b.getNextLine();
		int p = s.find(", ");
		if (p !=-1) {
			float lat = ofToFloat(s.substr(0, p));
			float lng = ofToFloat(s.substr(p+2));
			if(min_lat > lat) min_lat = lat;
			if(min_lng > lng) min_lng = lng;
			if(max_lat < lat) max_lat = lat;
			if(max_lng < lng) max_lng = lng;

			points.push_back(ofPoint(lat, lng));
		}
	}
	
	img.allocate(4096, 4096,OF_IMAGE_COLOR_ALPHA);
	unsigned int* p1 = (unsigned int*) img.getPixels();
	memset(p1, 0 , 4096*4096*4);
	
	lat_s = 4095.0/(max_lat - min_lat);
	lng_s = 4095.0/(max_lng - min_lng);
	for (int i=0; i<points.size(); i++) {
		ofPoint& p = points[i];
		unsigned int px = (p.x-min_lat)*lat_s;
		unsigned int py = (p.y-min_lng)*lng_s;
		p1[px+4096*py] += 1;
	}
	img.saveImage("map.png");

	// calc integral
	for(unsigned int i=1; i<4096; i++) {
		p1[i     ] = p1[ i-1      ] + p1[i     ];
		p1[i*4096] = p1[(i-1)*4096] + p1[i*4096];
	}
	for(unsigned int i=1; i<4096; i++) {
		for(unsigned int j=1; j<4096; j++) {
			p1[i+j*4096] = 
				p1[(i-1) + j   *4096] + 
				p1[ i    +(j-1)*4096] - 
				p1[(i-1) +(j-1)*4096] + 
				p1[ i    + j   *4096] ;
		}
	}

	img.update();
	//splitRect(ofRectangle(0,0,4096,4096));
	exportRectsAsJson();
	
}
Exemplo n.º 10
0
void ofxBvh::load(string path)
{
	path = ofToDataPath(path);
	
	string data = ofBufferFromFile(path).getText();
	
	const size_t HIERARCHY_BEGIN = data.find("HIERARCHY", 0);
	const size_t MOTION_BEGIN = data.find("MOTION", 0);
	
	if (HIERARCHY_BEGIN == string::npos
		|| MOTION_BEGIN == string::npos)
	{
		ofLogError("ofxBvh", "invalid bvh format");
		return;
	}
	
	parseHierarchy(data.substr(HIERARCHY_BEGIN, MOTION_BEGIN));
	parseMotion(data.substr(MOTION_BEGIN));
	
	currentFrame = frames[0];
	
	int index = 0;
	updateJoint(index, currentFrame, root);
	
	frame_new = false;
}
Exemplo n.º 11
0
void GlitchRect::update()
{
    if (tempo < 100) {
        tempo = 100;
    }
    if (amp < 0) {
        amp = 0;
    }
    int icoin = int(coin);
    //if (int(ofRandom(icoin)) % icoin == 0) {
    if (int(ofGetElapsedTimef()*1000) % tempo < ofGetFrameRate()){
        scale = ofRandom(2.0, 6.0);
        clipImage.grabScreen(pos.x + width/2 - width/scale/2, pos.y + height/2 - height/scale/2, width/scale, height/scale);
        clipImage.saveImage(compressedFilename, quality);
        ofBuffer file = ofBufferFromFile(compressedFilename, true);
        int fileSize = file.size();
        char * buffer = file.getBinaryBuffer();
        
        synth->set("lpf", amp*2000 + 80);

        for (int i = 0; i < ofRandom(1, 4); i++) {
            int whichByte = (int) ofRandom(fileSize * glitchStart, fileSize);
            int whichBit = ofRandom(8);
            char bitMask = 1 << whichBit;
            buffer[whichByte] |= bitMask;
        }
        
        ofBufferToFile(compressedFilename, file, true);
        clipImage.loadImage(compressedFilename);        
    }
}
Exemplo n.º 12
0
//-----//
void testApp::loadCalibration(){
	ofBuffer buf = ofBufferFromFile("calibration", false);
	
	string s = buf.getNextLine();
	skHratio = ofToFloat(s);
	
	s = buf.getNextLine();
	skVratio = ofToFloat(s);
	
	s = buf.getNextLine();
	skelHoffset = ofToFloat(s);
	
	s = buf.getNextLine();
	skelVoffset = ofToFloat(s);
	
	s = buf.getNextLine();
	spdWings = ofToFloat(s);
	
	s = buf.getNextLine();
	hgtWings = ofToFloat(s);
	
	s = buf.getNextLine();
	sclWings = ofToFloat(s);
	
	int _x = ofToInt(buf.getNextLine());
	int _y = ofToInt(buf.getNextLine());
	vout.move(_x,_y);
}
Exemplo n.º 13
0
void baseScene::loadCode( string fileName ){
    
    ofBuffer buffer = ofBufferFromFile(fileName);
    code = "";
    
    code += "// artwork by " + originalArtist + "\n";
    code += "// re-coded by " + author + "\n";
    code += "\n";

    for (auto line : buffer.getLines()){
        code += line;
        code += "\n";
    }

    // Remove trailing newlines and spaces
    code.erase(std::find_if(code.rbegin(),
                            code.rend(),
                            std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
               code.end());
    dataPath = ofFilePath::removeTrailingSlash(ofFilePath::getEnclosingDirectory(fileName));
    
    bAnimateScene = true;
    bHasEndSet = false;
    if (ofFile(dataPath+"/paramsRecording.xml").exists()) {
        float duration;
        loadMidi(recData, &duration, dataPath+"/paramsRecording.xml");
        cout << "got " << recData.size() << " events " << duration << endl;
        if (duration > 0) {
            setSceneEnd(duration);
        }
    }
}
void ofApp::setupParameters()
{
 //set up OSC controllable parameters from params.txt (which is in Max's goofy coll format for now)
    params.setName("params");
    string params_text = ofBufferFromFile(ofToDataPath("../../src/params.txt")).getText();
    vector<string> params_lines = ofSplitString(params_text, "\n");
    if(params_lines.size()==1) params_lines = ofSplitString(params_text, "\r");
    for(auto line:params_lines){
        vector<string> param_tokens = ofSplitString(line, " ");
        if(param_tokens.size()<3) break;
        string param_name = param_tokens[1];
        float param_val = atof(param_tokens[2].c_str());
        params.add(ofParameter<float>().set(param_name, param_val));

        cout<<"added OSC parameter "<<param_name<<" with initial value "<<param_val<<endl;
    }

    //set up parameters which are not floats and/or have callbacks separately for now
	//params.add(seed.set("seed",0));
	//seed.addListener(this, &ofApp::initParams);

    params.add(forward_graph->params);

    //I don't really understand the role of ofxGui in managing ofParameters/ofParameterGroups, something to return to
    gui.setup(params);
	sync.setup((ofParameterGroup&)gui.getParameter(),local_port,remote_host,remote_port);
}
Exemplo n.º 15
0
Project::Project(const std::string& path): _path(path), _isLoaded(false)
{
    // this is not efficient at all! I am just keeping these FileTemplate loads in the project
    // constructor because it makes the most sense architecure wise.
    _classFileTemplate = ofBufferFromFile(ofToDataPath("Resources/Templates/SketchTemplates/class.tmpl")).getText();
    load(_path, getName());
}
Exemplo n.º 16
0
void ofApp::setup()
{
    pugi::xml_document doc;

    std::string buffer = ofBufferFromFile("message.xml").getText();

    pugi::xml_parse_result result = doc.load(buffer.c_str());

    if (result)
    {
        pugi::xml_node messageNode = doc.child("message");

        ofLogNotice("ofApp::setup") << "     To: " << messageNode.child("to").text().as_string();
        ofLogNotice("ofApp::setup") << "   From: " << messageNode.child("from").text().as_string();
        ofLogNotice("ofApp::setup") << "Subject: " << messageNode.child("subject").text().as_string();
        ofLogNotice("ofApp::setup") << "   Body: " << messageNode.child("body").text().as_string();
    }
    else
    {
        ofLogError("ofApp::setup") << "XML [" << buffer << "] parsed with errors.";
        ofLogError("ofApp::setup") << "Error description: " << result.description();
        ofLogError("ofApp::setup") << "Error offset: " << result.offset << " (error at [..." << (result.offset) << "]";
        ofLogNotice("ofApp::setup") << "   Body: " << result.description();
    }
}
Exemplo n.º 17
0
void ofApp::setup(){

    // Comment this out... -------------------------
    ofBuffer file = ofBufferFromFile("api_key.txt");
    string apiKey = file;
    // ---------------------------------------------
    
    // ...and replace the apiKey variable with your own api key: --------------------------------
    string apiUrl = "http://api.wunderground.com/api/" + apiKey + "/conditions/forecast10day/q/NY/New_York.json";
    // ------------------------------------------------------------------------------------------
    
    // /conditions/ returns the current weather only
    // /forecast1oday/ returns forecast for: current day's periods + next 10 days
    // Paste the url into firefox to better visualize the JSON response!
    
    if (!response.open(apiUrl)){
        cout << "Failed to parse JSON" << endl;
        
    }else{
        cout << "JSON loaded successfully" << endl;
        cout << "************************" << endl;
        
        // ofxJSON is doing all the heavy lifting of parsing the JSON
        // and allowing us to navigate through it.
        
        // City name is under response > current_observation > display_location > city
        cout << response["current_observation"]["display_location"]["city"].asString() << endl;
        
        // Current observation is under response > current_observation > temp_c or temp_f
        cout << "temperature in celsius now is: " << response["current_observation"]["temp_c"].asFloat() << endl;
        cout << "temperature in farenheit now is: " << response["current_observation"]["temp_f"].asFloat() << endl;
    }
}
Exemplo n.º 18
0
Arquivo: ofApp.cpp Projeto: tado/ORF15
void ofApp::loadData(){
    string data = ofBufferFromFile("bytebeat.txt").getText();
    lastBeat = data;
    if (data.substr(0, 1) == "d" && bytebeats.size()>0) {
        int n = atoi(data.substr(1, data.length()).c_str());
        if (n < bytebeats.size()) {
            bytebeats.erase(bytebeats.begin() + n);
        }
    } else {
        BytebeatGenerator *bg = new BytebeatGenerator(bufferSize, nChannels);
        bg->height = ofGetHeight();
        bg->setup();
        bg->time = time;
        bg->beat = data;
        bytebeats.push_back(bg);
    }

    /*
     data = data.substr(0, data.length()-1);
    vector<string> beatStr = split(data, ';');
    bytebeats.clear();
    for (int i = 0; i < beatStr.size(); i++) {
        BytebeatGenerator *bg = new BytebeatGenerator(bufferSize, nChannels);
        bg->height = ofGetHeight() / beatStr.size();
        bg->setup();
        bg->time = time;
        bg->beat = beatStr[i] + ";";
        bytebeats.push_back(bg);
    }
     */
}
Exemplo n.º 19
0
//--------------------------------------------------------------
void testApp::update(){
    
    source.grabFrame();
    pixels = source.getPixels();
	
	// FFT stuff
	
	string compressedFilename = "compressed2.jpg";
	
	
	img.saveImage(compressedFilename, quality);
	
	ofBuffer file = ofBufferFromFile(compressedFilename);
	int fileSize = file.size();
	
	char * buffer = file.getBinaryBuffer();
	
	int whichByte = (int) ofRandom(fileSize);
	
	int whichBit = ofRandom(20);
	
	char bitMask = 1 << whichBit;
	buffer[whichByte] |= bitMask;
	
	ofBufferToFile(compressedFilename, file);
	
	img.loadImage(compressedFilename);
	
//end FFT stuff	
}
Exemplo n.º 20
0
void Cinema::load(){
        ofDirectory dir("cinema/");
        dir.listDir();
        vector<string> dirs;
        for(int i=0;i<dir.size();i++){
            string d = dir.getPath(i);
            if(d.find("DB")!=string::npos){
                vector<string> vids;
                vector<ofVideoPlayer*> ps;
                ofDirectory dir2(d);
                dir2.listDir();
                for(int j=0;j<dir2.size();j++){
                    vector<double> scene;
                    vector<string> movs;
                    string vidpath = dir2.getPath(j);
                    string origVidPath = vidpath;
                    if(dir2.getName(j)[0] != '.' &&
                            (vidpath.find(".mov")!=string::npos || vidpath.find(".mp4")!=string::npos ||
                       vidpath.find(".avi")!=string::npos ||
                       vidpath.find(".3gp")!=string::npos
                       || vidpath.find(".gif")!=string::npos
                       || vidpath.find(".webm")!=string::npos
                       || vidpath.find(".mkv")!=string::npos)){
                        vids.push_back(vidpath);
                        playerPaths.push_back(vidpath);
                        ofVideoPlayer* p = new ofVideoPlayer;
                        playerIntensities.push_back(0);
                        ps.push_back(p);
                        
                        string txtPath = vidpath;
                        ofStringReplace(txtPath, ".mov", ".txt");
                        ofStringReplace(txtPath, ".mp4", ".txt");
                        ofStringReplace(txtPath, ".mkv", ".txt");
                        ofStringReplace(txtPath, ".webm", ".txt");
                        ofStringReplace(txtPath, ".avi", ".txt");
                        ofStringReplace(txtPath, ".gif", ".txt");
                        string t = ofBufferFromFile(txtPath).getText();
                        if(t.compare("")){
                            vector<string > splitted = ofSplitString(t, "\n");
                            for(int x=0;x<splitted.size();x++){
                                vector<string> line = ofSplitString(splitted[x]," ");
                                scene.push_back(ofToDouble(line[0]));
                                if(line.size()>1)
                                    movs.push_back((line[1]));
                                else
                                    movs.push_back(" ");
                            }
                            ofFile vf(vidpath) ;
                            string absoluteVidPath = vf.getAbsolutePath();
                            playerScenes[absoluteVidPath] = scene;
                            playerScenesMovements[origVidPath] = movs;
                        }
                    }
                   
                }
                strdb.push_back(vids);
            }
        }
    }
Exemplo n.º 21
0
void ofxCcv::setup(string network) {
    string imagenetFilename = ofToDataPath(network);
    convnet = ccv_convnet_read(0, imagenetFilename.c_str());
    ofBuffer buffer = ofBufferFromFile("image-net-2012.words");
    for(auto line : buffer.getLines()) {
        words.push_back(line);
    }
}
Exemplo n.º 22
0
//--------------------------------------------------------------
void ofApp::recExportPressed(){
    ofBuffer buf = ofBufferFromFile(tempAudio, true);
    string tempPath = "audio_" + ofToString(int(frames)) + "_" + ofToString(int(frameRate)) + ".wav";
    ofFileDialogResult saveFileResult = ofSystemSaveDialog(tempPath, "Save your file");
    if (saveFileResult.bSuccess){
        bool fileWritten = ofBufferToFile(saveFileResult.filePath, buf);
    }
}
Exemplo n.º 23
0
Arquivo: ofApp.cpp Projeto: tado/ORF15
//--------------------------------------------------------------
void ofApp::update(){
    for (int i = 0; i < bytebeats.size(); i++) {
        bytebeats[i]->update();
    }
    if (lastBeat != ofBufferFromFile("bytebeat.txt").getText()) {
        loadData();
    }
}
//--------------------------------------------------------------
bool ofShader::setupShaderFromFile(GLenum type, string filename) {
	ofBuffer buffer = ofBufferFromFile(filename);
	if(buffer.size()) {
		return setupShaderFromSource(type, buffer.getText());
	} else {
		ofLog(OF_LOG_ERROR, "Could not load shader of type " + nameForType(type) + " from file " + filename);
		return false;
	}
}
Exemplo n.º 25
0
//--------------------------------------------------------------
void ofApp::setup(){

	ofBackground(40, 100, 40);

	// open an outgoing connection to HOST:PORT
	sender.setup(HOST, PORT);
    
    imgAsBuffer = ofBufferFromFile("sendImageTest.jpg", true);

}
Exemplo n.º 26
0
//--------------------------------------------------------------
vector <ofDefaultVertexType> ofApp::loadPoints(const std::string& file) {
	vector <ofDefaultVertexType> pts;
	vector <string>  ptsStr = ofSplitString(ofBufferFromFile(file).getText(), ",");
	for(int i=0; i<ptsStr.size(); i+=2) {
		float x = ofToFloat(ptsStr[i]);
		float y = ofToFloat(ptsStr[i+1]);
		pts.push_back(ofDefaultVertexType(x, y, 0));
	}
	return pts;
}
Exemplo n.º 27
0
void ofApp::loadUUIDList(){
    ofBuffer buffer = ofBufferFromFile("uuidList.txt");
    string line;
    while (true){
        line = buffer.getNextLine();
        vector < string > str = ofSplitString(line, " ");
        uuidMapping[str[1]] = ofToInt(str[0]);
        if (buffer.isLastLine()) break;
    }
}
Exemplo n.º 28
0
void LedsManager::readLedsPosition()
{
    
    int lineNumber = 0;
    int id = 0;
    bool upwards = false;
    
    for(int i = 1; i <= NUM_CHANNELS; i++)
    {
        string led_section_path = LEDS_LIST_PATH + "leds_" + ofToString(i) + ".txt";
        ofBuffer buffer = ofBufferFromFile(led_section_path);
        
        if(buffer.size())
        {
            while(buffer.isLastLine() == false)
            {
                 string line = buffer.getNextLine();
                 ofPoint ledPosition;
                
                
                 if(parseLedLine(line,ledPosition))
                 {
                     if(ledPosition.z == 0)
                     {
                         upwards = !upwards;
                         if (!upwards) {
                             id = lineNumber + STRIP_SIZE - 1;
                         }
                         else{
                             id = lineNumber;
                         }
                         
                     }
                     else
                     {
                         createLed(ledPosition, id);
                         
                         if(upwards){
                             id++;
                         }
                         else{
                             id--;
                         }
                         
                         lineNumber++;
                     }
                     
                   
                 }
            }
        }

    }
    
}
Exemplo n.º 29
0
void VisionRequestItem::setImage(const std::string& uri)
{
    if (uri.substr(0, 5).compare("gs://") == 0)
    {
        _json["image"].clear();
        _json["image"]["source"]["gcs_image_uri"] = uri;
    }
    else
    {
        setImage(ofBufferFromFile(uri));
    }
}
Exemplo n.º 30
0
//--------------------------------------------------------------
void Interface::load( int index )
{
	string fileName = "presets/preset" + ofToString( index ) + ".txt";
	string text = string( ofBufferFromFile( fileName ) );
	vector<string> list = ofSplitString( text, " " );

	if ( list.size() == slider.size() ) {
		for (int i=0; i<slider.size(); i++) {
			*slider[i].value = ofToFloat( list[i] );
		}
	}
}