void FlickrImageViewerApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) );

	// calculate elapsed time in seconds (since last swap)
	double elapsed = ( getElapsedSeconds() - mTimeSwapped );
	// calculate crossfade alpha value
	double fade = ci::math<double>::clamp(elapsed / mTimeFade, 0.0, 1.0);
	// calculate zoom factor 
	float zoom = getWindowWidth() / 600.0f * 0.025f;

	// draw back image
	if(mBack) {
		Rectf image = mBack.getBounds();
		Rectf window = getWindowBounds();
		float sx = window.getWidth() / image.getWidth();	// scale width to fit window
		float sy = window.getHeight() / image.getHeight();	// scale height to fit window
		float s = ci::math<float>::max(sx, sy) 
			+ zoom * (float) (elapsed + mTimeDuration);	// fit window and zoom over time
		float w = image.getWidth() * s;						// resulting width
		float h = image.getHeight() * s;					// resulting height
		float ox = -0.5f * (w - window.getWidth());			// horizontal position to keep image centered
		float oy = -0.5f * (h - window.getHeight());		// vertical position to keep image centered
		image.set(ox, oy, ox+w, oy+h);

		gl::color( Color(1, 1, 1) );
		gl::draw( mBack, image );
	}

	// draw front image
	if(mFront) {
		Rectf image = mFront.getBounds();
		Rectf window = getWindowBounds();
		float sx = window.getWidth() / image.getWidth();
		float sy = window.getHeight() / image.getHeight();
		float s = ci::math<float>::max(sx, sy) + zoom * (float) elapsed;
		float w = image.getWidth() * s;
		float h = image.getHeight() * s;
		float ox = -0.5f * (w - window.getWidth());
		float oy = -0.5f * (h - window.getHeight());
		image.set(ox, oy, ox+w, oy+h);
		
		gl::color( ColorA(1, 1, 1, (float) fade) );
		gl::enableAlphaBlending();
		gl::draw( mFront, image );
		gl::disableAlphaBlending();
	}

}
Exemplo n.º 2
0
void FxApp::draw()
{
	static gl::Texture source;

	gl::clear( Color::black() );

	bool isNewFrame = mCapture && mCapture.checkNewFrame();

	if ( isNewFrame )
	{
		source = gl::Texture( mCapture.getSurface() );
	}

	gl::setMatricesWindow( getWindowSize() );
	gl::setViewport( getWindowBounds() );

	if ( isNewFrame )
		source = mEffects[ mCurrentEffect ]->process( source );

	if ( source )
	{
		gl::draw( source,
				Area::proportionalFit( source.getBounds(), getWindowBounds(),
									   true, true ) );
	}

	params::InterfaceGl::draw();
}
Exemplo n.º 3
0
void QuickTimeSampleApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::enableAlphaBlending();

	if( mFrameTexture ) {
		Rectf centeredRect = Rectf( mFrameTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mFrameTexture, centeredRect  );
	}

	if( mInfoTexture ) {
		glDisable( GL_TEXTURE_RECTANGLE_ARB );
		gl::draw( mInfoTexture, Vec2f( 20, getWindowHeight() - 20 - mInfoTexture.getHeight() ) );
	}
}
Exemplo n.º 4
0
void _TBOX_PREFIX_App::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	//gl::enableAlphaBlending();
	gl::color( Color::white() );

	if( mFrameTexture ) {
		Rectf centeredRect = Rectf( mFrameTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mFrameTexture, centeredRect  );
	}

	/*if( mInfoTexture ) {
		glDisable( GL_TEXTURE_RECTANGLE_ARB );
		gl::draw( mInfoTexture, Vec2f( 20, getWindowHeight() - 20 - mInfoTexture.getHeight() ) );
	}*/
}
void MovieBasicApp::draw()
{
	// clear out the window with black
	gl::clear( ColorA::black() );
	gl::enableAlphaBlending();
	
	if( mFrameTexture ) {
		Rectf centeredRect = Rectf( mFrameTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mFrameTexture, centeredRect  );
	}
	
	if( mInfoTexture ) {
        // error
        //		glDisable( GL_TEXTURE_RECTANGLE_ARB );
		gl::draw( mInfoTexture, Vec2f( 20, getWindowHeight() - 20 - mInfoTexture.getHeight() ) );
	}
}
Exemplo n.º 6
0
Rectf getCoveringRect(gl::Texture texture, Area containerArea) {
  float scale;
  Rectf bounds = texture.getBounds();
  bounds = bounds.getCenteredFit(containerArea, true);
  
  int container_h = containerArea.getHeight(),
  container_w = containerArea.getWidth(),
  texture_h = bounds.getHeight(),
  texture_w = bounds.getWidth();
  
  if (abs(container_h - texture_h) > abs(container_w - texture_w))
    scale = (float) container_h/texture_h;
  else
    scale = (float) container_w/texture_w;
  
  bounds.scaleCentered(scale + .05);
  
  return bounds;
}
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() ) );
	}
}
Exemplo n.º 8
0
void ardroneApp::draw()
{
    renderFbo.bindFramebuffer();

	gl::clear( Color( 0, 0, 0 ) );
    gl::color( Color::white() );
	if ( mFrameTexture ) {
		Rectf centeredRect = Rectf( mFrameTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mFrameTexture, centeredRect  );
	}
    
    renderFbo.blitToScreen(renderFbo.getBounds(), getWindowBounds());
    mSyphonServer.publishTexture(renderFbo.getTexture(), false);

    renderFbo.unbindFramebuffer(); // return rendering to the window's own frame buffer

	if( mInfoTexture ) {
		glDisable( GL_TEXTURE_RECTANGLE_ARB );
		gl::draw( mInfoTexture, Vec2f( 5, getWindowHeight() - 5 - mInfoTexture.getHeight() ) );
	}
}
Exemplo n.º 9
0
void RogalarmApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::enableAlphaBlending();
	
	if (mKinectConected) {
        
		//Rectf centeredRect = Rectf( mDepthTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		//gl::draw( mDepthTexture, centeredRect  );
		
		
		//gl::drawLine(Vec2f(mUserPos, 0), Vec2f(mUserPos, 640));
		gl::color (Color8u(255 ,255, 0));
		gl::drawSolidRect (Rectf(mUserPos-2, 0, mUserPos+2, 640) ,false);
        
		mGui->draw();
        
	}else {
		Rectf centeredRect2 = Rectf( mKonnect.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mKonnect, centeredRect2  );
	}

}
Exemplo n.º 10
0
// Just create the latest thing
void svvimApp::draw() {
  
  // SvvimLogo
  if (mSvvimLogoPng)
    mSvvimLogoPng.bind(0);
  
  // Mask
  if (mMaskTexture)
    mMaskTexture.bind(1);
  
  //
  if (mImageTexture)
    mImageTexture.bind(2);
  
  // Clear to black
  gl::clear();

  /*
  if (mMaskTexture) {
    Area bounds = mMaskTexture.getBounds();
    
    Area displayArea = getWindowBounds();
    // displayArea.y1 = displayArea.y1 + displayArea.getHeight() * .05;
    // displayArea.y2 = displayArea.y2 - displayArea.getHeight() * .05;
    
    Rectf centeredRect = Rectf(mMaskTexture.getBounds()).getCenteredFit(displayArea, false);
    
    float coverAspectRatio = mMaskTexture.getAspectRatio();
    float windowAspectRatio = getWindowAspectRatio();
    
    if (coverAspectRatio > windowAspectRatio) {
      float scale = displayArea.getHeight()/centeredRect.getHeight();
      centeredRect.scaleCentered(scale);
    }
    else {
      float scale = displayArea.getWidth()/centeredRect.getWidth();
      centeredRect.scaleCentered(scale);
    }
    
    gl::draw(mMaskTexture, centeredRect);
  } */

  
  // Draw pool-water background cover
  if (mImageTexture) {
    Area bounds = mImageTexture.getBounds();

    Area displayArea = getWindowBounds();
    displayArea.y1 = displayArea.y1 + displayArea.getHeight() * .05;
    displayArea.y2 = displayArea.y2 - displayArea.getHeight() * .05;
    
    Rectf centeredRect = Rectf(mImageTexture.getBounds()).getCenteredFit(displayArea, true);

    float coverAspectRatio = mImageTexture.getAspectRatio();
    float windowAspectRatio = getWindowAspectRatio();
    
    if (coverAspectRatio > windowAspectRatio) {
      float scale = displayArea.getHeight()/centeredRect.getHeight();
      centeredRect.scaleCentered(scale);
    }
    else {
      float scale = displayArea.getWidth()/centeredRect.getWidth();
      centeredRect.scaleCentered(scale);
    }
    
    gl::draw(mCurrentBgTexture, centeredRect);
  }

  if (mShader) {
    float displacement = 10. - min(mAlpha * 300.0, 10.0);
    mShader.bind();
    mShader.uniform("displacement", displacement);
    mShader.uniform("maskTexture", 0);
    mShader.uniform("innerTexture", 2);
    mShader.uniform("fillColor", Vec3f(0.3, 0.3, 0.3));
    mShader.uniform("bounds", Vec2f(getWindowWidth(), getWindowHeight()));
    mShader.uniform("alpha", 6 * mAlpha);
  }
  
  if (mSvvimLogoPng) {
    Rectf centeredRect = Rectf(mSvvimLogoPng.getBounds()).getCenteredFit(getWindowBounds(), true);
    Rectf topRect = centeredRect;
    gl::draw(mSvvimLogoPng, centeredRect);
    centeredRect.y1 -= 200;
    centeredRect.y2 -= 200;
    //gl::draw(mSvvimLogoPng, centeredRect);
    centeredRect.y1 += 400;
    centeredRect.y2 += 400;
    //gl::draw(mSvvimLogoPng, centeredRect);
  }
  
  if (mShader)
    mShader.unbind();
  
  if (mMaskTexture)
    mMaskTexture.unbind();
  
  if (mImageTexture)
    mImageTexture.unbind();
  
  if (mSvvimLogoPng)
    mSvvimLogoPng.unbind();

}