コード例 #1
0
ファイル: SvvimGramApp.cpp プロジェクト: mattvvhat/SvvimGram
void SvvimGramApp::drawLogo() {
  if (mSvvimLogo) {
    gl::pushMatrices();
    gl::setMatricesWindow(getWindowSize());
    
    float w = 850;
    float h = w/mSvvimLogo.getAspectRatio();
    float x = (getWindowWidth() - w)/2.f;
    float y = (getWindowHeight() - h)/2.f;
    gl::color(1, 1, 1, .4f);
    gl::draw(mSvvimLogo, Rectf(x, y, x + w, y + h));
    
    gl::popMatrices();
  }
}
コード例 #2
0
void PhotoBoothApp::draw()
{
    gl::enableAlphaBlending();
    
    gl::clear();
    gl::color(1, 1, 1, 1);
    glDepthMask( GL_FALSE );

    // Set up the view for landscape mode.
	gl::setMatricesWindow(width * DISPLAY_SCALE, height * DISPLAY_SCALE);
    gl::scale(DISPLAY_SCALE, DISPLAY_SCALE);
    
    // draw the live camera preview
	if( mCameraTexture ) {
        // flip the texture vertically
        mCameraTexture.setFlipped(false);
        
        // draw the texture mirrored.
        gl::draw( mCameraSurface, Rectf(width, 0, 0, height) );
	}

    // draw "idle" stuff (text and images overlayed on the live camera preview)
    if(mCurrentState == STATE_PREVIEW){
        gl::color(1, 1, 1, 0.75f);
        gl::draw(mLightBg, Rectf(0, 0, width, height));
        gl::color(1, 1, 1, 1);
        gl::draw(mIntroTexture, Rectf(0,0,width, height));
        
        gl::draw(mCameraButtonTexture, mCameraButtonPos.value() - Vec2f(0, abs( sin(getElapsedSeconds() * 3) * 30)));

        
        //gl::draw(mCameraButtonTexture, Rectf(mCameraButtonPos.value().x,mCameraButtonPos.value().y, mCameraButtonTexture.getWidth() * 0.5 + mCameraButtonPos.value().x, mCameraButtonTexture.getHeight() * 0.5 + mCameraButtonPos.value().y) );//  mCameraButtonPos.value() );
    }
        
    // Draw the preview image with dark background.
    if(mPreviewTexture){
        
        // draw background image and prompt text.
        if(mDarkBgAlpha > 0){
            gl::color(1, 1, 1, mDarkBgAlpha);
            gl::draw(mDarkBg, Vec2f::zero());
            gl::draw(mConfirmMessage, Vec2f(width/2 - mConfirmMessage.getWidth() / 2, 125 - mConfirmMessage.getHeight() / 2));
        }
        
        float aspect = mPreviewTexture.getAspectRatio();
        
        float imageHeight = height - 500; // margins are keyed off of hard-coded height, this is not very multi-resolution friendly.
        float imageWidth = imageHeight * aspect;
        
        float marginX = (width - imageWidth) / 2;
        float marginY = (height - imageHeight) / 2;
        
        gl::draw(mPreviewTexture, Rectf(marginX, marginY, width - marginX, height - marginY) + mPreviewTexturePos);
        

        // Draw semi-transparent pillar boxes to show how the sqare version of the image will look.
        if(mCurrentState == STATE_ACCEPT) {
            float pillarWidth = (imageWidth - imageHeight) / 2;
            gl::color(0, 0, 0, 0.35f);
            gl::drawSolidRect( Rectf( marginX, height - marginY, pillarWidth + marginX, marginY ) );
            gl::drawSolidRect( Rectf( width - marginX - pillarWidth, height - marginY, width - marginX, marginY ) );
        }
    }
    
    // draw the "flash"
    if(mCurrentState == STATE_ACCEPT){
        gl::color(1, 1, 1, mCameraFlash);
        gl::drawSolidRect( Rectf(0, 0, width, height));
    }
    
    // draw count-down timer
    if(mCurrentState == STATE_COUNT_DOWN){
        
        // draw dark circle background
        Vec2f centerPos = Vec2f(width / 2 - mNumberBg.getWidth() / 2, height / 2 - mNumberBg.getHeight() / 2);
        gl::draw( mNumberBg, centerPos);
        
        // background ring that "fills up" for each second.
        gl::draw(mNumberProgress, Area(0, mNumberProgress.getHeight() * mCountDownFractional, mNumberProgress.getWidth(), mNumberProgress.getHeight()), Rectf(centerPos.x,centerPos.y+mNumberProgress.getHeight() * mCountDownFractional, mNumberBg.getWidth()+centerPos.x, centerPos.y+mNumberBg.getHeight()));
        
        // Draw number.
        gl::enableAdditiveBlending();
        gl::draw( mNumberTextures[mCountDownNumber], centerPos);
    }

    gl::color(1, 1, 1, 1);
    gl::draw(mSaveTexture, mSavePos);
    gl::draw(mDiscardTexture, mDiscardPos);
}
コード例 #3
0
ファイル: svvimApp.cpp プロジェクト: mattvvhat/svvim
// 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();

}