void imageMeltingPoint::render( const ofTexture& _tex){ if( !_tex.isAllocated() ) return;// false; int radius = karmaSoundAnalyser::getInstance().getZeroCrossings()/400; _tex.draw(position); /*for(int x=position.x-radius; x<position.x+radius; x+=round(ofRandom(1,radius/10)) ){ if( x < 0 || x > _tex.getWidth() ) continue; for(int y=position.y-radius; y<position.y+radius; y+=round(ofRandom(1,radius/10))){ if( y < 0 || y > _tex.getHeight() ) continue; int offset = y*_tex.getWidth() + x; offset /= _tex.getNumChannels()*2; ofSetColor( (ofColor) _tex[offset] ); ofDrawCircle(x, y, 1); } }*/ }
//---------- bool Receiver::receive(ofTexture & texture) { try { //check if we're initialised if (!this->isInitialized()) { throw("Not initialized"); } //prepare the channel name, allow it to be changed if different channels are available char mutableName[256]; unsigned int mutableWidth, mutableHeight; strcpy_s(mutableName, this->channelName.size() + 1, this->channelName.c_str()); //check if the texture is allocated correctly, if not, allocate it if (texture.getWidth() != this->width || texture.getHeight() != this->height) { int format = texture.isAllocated() ? texture.getTextureData().glInternalFormat : this->defaultFormat; texture.allocate(width, height, format); } //pull data into the texture (keep any existing fbo attachments) GLint drawFboId = 0; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId); if (!this->spoutReceiver->ReceiveTexture(mutableName, mutableWidth, mutableHeight, texture.getTextureData().textureID, texture.getTextureData().textureTarget, false, drawFboId)) { throw("Can't receive texture"); } //update our local settings incase anything changed this->channelName = mutableName; this->width = mutableWidth; this->height = mutableHeight; return true; } catch (const char * e) { ofLogError("ofxSpout::Receiver::receive") << e; return false; } }
bool fboRecorder::endFrame(bool _showBuffer){ if(!isRecording()) return false; if(!useGrabScreen){ if(!bFrameStarted) return false; fbo.end(); //fbo.getTexture().getTextureData().bFlipTexture = false; bFrameStarted=false; } static ofTexture tmpTex; int w = ofGetWidth(); int h = ofGetHeight(); if(!tmpTex.isAllocated()){ tmpTex.allocate( w, h, GL_RGBA ); } switch(fboRecMode){ case VIDEOREC_MODE_FILE_H264 : case VIDEOREC_MODE_FILE_PNG : { ofPixels pix; pix.allocate(fbo.getWidth(),fbo.getHeight(), ofGetImageTypeFromGLType(GL_RGB)); if(useGrabScreen){ tmpTex.loadScreenData(0, 0, w, h); tmpTex.readToPixels(pix); } else { fbo.readToPixels(pix); } ofxVideoRecorder::addFrame(pix); break; } #ifdef KM_ENABLE_SYPHON case VIDEOREC_MODE_SYPHON: { //fbo.updateTexture( fbo.getTexture().texData.textureID ); if( useGrabScreen ){ //syphonServer.publishScreen(); tmpTex.loadScreenData(0, 0, ofGetWidth(), ofGetHeight()); //tmpTex = fbo.getTexture(); syphonServer.publishTexture( &tmpTex ); } else { //tmpTex = fbo.getTexture(); syphonServer.publishTexture( &fbo.getTexture() ); } break; } #endif default: return false; break; } // flush tmpTex.clear(); if(_showBuffer){ if(!useGrabScreen){ #ifdef KM_ENABLE_SYPHON if( fboRecMode==VIDEOREC_MODE_SYPHON ){ #else if(false){ #endif fbo.draw(0, 0, fbo.getWidth(), fbo.getHeight()); // show recorded image } else { fbo.draw(0, fbo.getHeight(),fbo.getWidth(), -fbo.getHeight()); // show recorded image } } } return true; } // LISTENERS void fboRecorder::beforeDraw( karmaControllerDrawEventArgs& _args ){ beginFrame(); } void fboRecorder::afterDraw( karmaControllerDrawEventArgs& _args ){ endFrame(videoRecShowOutput); }