void QuickTimePlayer::setup()
{
	/*fs::path moviePath = getOpenFilePath();
	if( ! moviePath.empty() )
		loadMovieFile( moviePath );*/
	// spout
	g_Width = 640;
	g_Height = 480;
	// Set up the texture we will use to send out
	// We grab the screen so it has to be the same size
	spoutTexture = gl::Texture(g_Width, g_Height);
	strcpy_s(SenderName, "QuickTimePlayer"); // we have to set a sender name first
	// Initialize a sender
	bInitialized = spoutsender.CreateSender(SenderName, g_Width, g_Height);

}
void QuickTimePlayer::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::enableAlphaBlending();

	if( mFrameTexture ) {
		Rectf centeredRect = Rectf( mFrameTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mFrameTexture, centeredRect  );
		
		if (bInitialized)
		{
			spoutsender.SendTexture(mFrameTexture.getId(), mFrameTexture.getTarget(), g_Width, g_Height, false);
		}
	}

	if( mInfoTexture ) {
		glDisable( GL_TEXTURE_RECTANGLE_ARB );
		gl::draw( mInfoTexture, Vec2f( 20, getWindowHeight() - 20 - mInfoTexture.getHeight() ) );
	}
}
Пример #3
0
//--------------------------------------------------------------
void Sender::sendTexture(ofTexture& t, string name)
{
	int width = t.getWidth();
	int height = t.getHeight();

	//lookup the sender
	int i = ofFind(senderNameList, name); 

	//if the sender is not there
	if (i == senderNameList.size()) {
		char senderNameChars[256];
		strcpy_s(senderNameChars, name.c_str());
		SpoutSender* sender = new SpoutSender();
		bool init = sender->CreateSender(senderNameChars, width, height);
	
		if (init) {
			ofLogNotice("ofxSpout2 Sender created");
			//init the fbo
			ofFbo senderFbo;
			ofFbo::Settings s;
			s.width = width;
			s.height = height;
			s.internalformat = GL_RGBA;
			s.textureTarget = GL_TEXTURE_2D;
			s.useDepth = false;
			s.useStencil = false;
			s.minFilter = GL_LINEAR;
			s.maxFilter = GL_LINEAR;
			s.wrapModeHorizontal = GL_CLAMP_TO_EDGE;
			s.wrapModeVertical = GL_CLAMP_TO_EDGE;
			s.numSamples = 0;
			senderFbo.allocate(s);
			senderFboList.push_back(senderFbo);
			senderWidthList.push_back(width);
			senderHeightList.push_back(height);
			senderNameList.push_back(name);
			spoutSenderList.push_back(sender);
		} else {
			ofLogError("ofxSpout2 Sender creation failed");
		}
		//we cannot create sender and immediatly send texture; so return
		return;
	}


	if (i >= 0 && i < senderNameList.size())
	{	
		if ((width != senderWidthList[i]) || (height != senderHeightList[i])) {
			// quick and dirty fix for spoutSender ignoring texture resolution changes
			senderFboList[i].destroy();
			ofFbo senderFbo;
			ofFbo::Settings s;
			s.width = width;
			s.height = height;
			s.internalformat = GL_RGBA;
			s.textureTarget = GL_TEXTURE_2D;
			s.useDepth = false;
			s.useStencil = false;
			s.minFilter = GL_LINEAR;
			s.maxFilter = GL_LINEAR;
			s.wrapModeHorizontal = GL_CLAMP_TO_EDGE;
			s.wrapModeVertical = GL_CLAMP_TO_EDGE;
			s.numSamples = 0;
			senderFbo.allocate(s);
			senderFboList[i] = senderFbo;
			senderWidthList[i] = width;
			senderHeightList[i] = height;
		}
		ofPushMatrix();
		ofPushStyle();
		senderFboList[i].begin();
		ofClear(0);
		ofSetColor(255);
		t.draw(0,0,width,height);
		senderFboList[i].end();
		ofPopStyle();
		ofPopMatrix();
		glBindTexture(GL_TEXTURE_2D, 0);  //
		spoutSenderList[i]->SendTexture(senderFboList[i].getTextureReference().getTextureData().textureID, GL_TEXTURE_2D, senderWidthList[i], senderHeightList[i], false); 
	}
}