void TextureFontApp::draw()
{
	gl::setMatricesWindow( getWindowSize() );
	gl::enableAlphaBlending();
	gl::clear( Color( 0, 0, 0 ) );
	
	std::string str( "Granted, then, that certain transformations do happen, it is essential that we should regard them in the philosophic manner of fairy tales, not in the unphilosophic manner of science and the \"Laws of Nature.\" When we are asked why eggs turn into birds or fruits fall in autumn, we must answer exactly as the fairy godmother would answer if Cinderella asked her why mice turned into horses or her clothes fell from her at twelve o'clock. We must answer that it is MAGIC. It is not a \"law,\" for we do not understand its general formula." );
	Rectf boundsRect( 40, mTextureFont->getAscent() + 40, getWindowWidth() - 40, getWindowHeight() - 40 );

	gl::color( ColorA( 1, 0.5f, 0.25f, 1.0f ) );

#if defined( CINDER_COCOA )
	mTextureFont->drawStringWrapped( str, boundsRect );
#else
	mTextureFont->drawString( str, boundsRect );
#endif	

	// Draw FPS
	gl::color( Color::white() );
	mTextureFont->drawString( toString( floor(getAverageFps()) ) + " FPS", Vec2f( 10, getWindowHeight() - mTextureFont->getDescent() ) );
    
    // Draw Font Name
	float fontNameWidth = mTextureFont->measureString( mTextureFont->getName() ).x;
	mTextureFont->drawString( mTextureFont->getName(), Vec2f( getWindowWidth() - fontNameWidth - 10, getWindowHeight() - mTextureFont->getDescent() ) );
}
void DXTencoderApp::draw()
{
    gl::clear( Color( 0, 1.0, 1.0 ) );
    gl::color(1, 1, 1, 1);

    gl::enableAlphaBlending( true );
    
    if( ( ! mMovie ) || ( ! mSurface ) || !isStarted ){

        gl::color(0, 0, 0, 1);

        gl::color(1, 1, 1, 1);
        mTextureFont->drawString("DRAG VIDEO FILE IN THIS WINDOW", getWindowCenter() - vec2(210,0));

        return;
    }
    
    if(scaledSurface.getWidth() < getWindowWidth()){
        gl::draw( gl::Texture::create( scaledSurface ),vec2(0,100) );
        gl::draw( gl::Texture::create( correctedSurface ),vec2(scaledSize.x + 10,100) );
    }else{
        gl::color(1, 1, 1, 1);
        mTextureFont->drawString("NO PREVIEW VIDEO IS TO LARGE", getWindowCenter() - vec2(210,0));

    }

    gl::color(0, 0, 0, 0.6);
    gl::drawSolidRect(Rectf(0,0,getWindowWidth(),100));

    gl::color(1, 1, 1, 1);
    mTextureFont->drawString("ENCODING FRAME: " + toString(currentFrame) + " / " + toString(endFrame), ivec2(20,35));
    
    gl::drawString("original size: " + toString(mMovie->getSize()) , ivec2(20,70));
    gl::drawString("scaled size: " + toString(scaledSize) , ivec2(20,85));
    gl::drawString("corrected %4 size: " + toString(correctedSize) , ivec2(scaledSize.x + 20,85));

    gl::color(1, 1, 1, 1);
    float width = lmap(currentFrame, 0, endFrame, 0, getWindowWidth());
    gl::drawSolidRect(Rectf(0,45,width ,60));
    

    gl::color(1, 1.0, 1.0, 1.0);

    float lineHeight = 100 + correctedSize.y;
    gl::drawLine(vec2(0,lineHeight), vec2(getWindowWidth(),lineHeight));

    gl::color(1, .4, .7, 0.8);

    gl::drawLine(vec2(0,100 + 256), vec2(getWindowWidth(),100 + 256));
    gl::drawString("screen bottom " , ivec2(scaledSize.x +correctedSize.x + 20,90 + 256 ), Color(1,0.4,0.8));
    
}
void BasicShaderIIApp::draw()
{
	gl::clear( Color::black() ); 
	// Draw FPS
	gl::color( Color::white() );
	mTextureFont->drawString( toString( floor(getAverageFps()) ) + " FPS", Vec2f( 100, getWindowHeight() - mTextureFont->getDescent() ) );
    
    gl::pushMatrices();
	gl::setMatrices( mCam );
    gl::enableAlphaBlending();
    
	// draw interface
	params::InterfaceGl::draw();
	
	if( mDoSave )
	{	// save non-conflicting image
		// includes interface to record parameters
		saveFrame();
		mDoSave = false;
	}
    
    mShader.bind();
    mShader.uniform("lightDir", mLightDir );   
    
    gl::pushMatrices();
    gl::rotate( mArcball.getQuat() );
    gl::draw( mVBO );
    gl::popMatrices();
    mShader.unbind();     
    
    gl::popMatrices();
}
Exemple #4
0
void RetinaSampleApp::draw()
{
	gl::clear( Color( 0.1f, 0.1f, 0.15f ) );
	gl::enableAlphaBlending();
	
	gl::pushMatrices();
		gl::color( 1.0f, 0.5f, 0.25f );
		gl::lineWidth( toPixels( 1.0f ) );
		gl::draw( mPoints );
	gl::popMatrices();
	
	// rotate a 200x200pt square at the center of the window
	gl::pushMatrices();
		gl::color( 1.0f, 0.2f, 0.15f );
		gl::translate( getWindowCenter() );
		gl::rotate( getElapsedSeconds() * 5 );
		gl::drawSolidRect( Rectf( Area( -100, -100, 100, 100 ) ) );
	gl::popMatrices();

	// draw the logo in the lower-left corner at 64x64 points
	gl::color( Color::white() );
	gl::draw( mLogo, Rectf( 0, getWindowHeight() - 64, 64, getWindowHeight() ) );

	// The font has been made double the size we need for non-Retina, so we always scale by 0.5f
	// another strategy would be to use two different TextureFonts
	std::string s = ( getWindowContentScale() > 1 ) ? "Retina" : "Non-Retina";
	float stringWidth = mFont->measureString( s ).x * 0.5f;
	mFont->drawString( s, Vec2f( getWindowWidth() - stringWidth - 12, getWindowHeight() - 12 ),
		gl::TextureFont::DrawOptions().scale( 0.5f ).pixelSnap( false ) );
}
void TextParticlesApp::drawTextToFbo()
{
	{
		vec2 size = mTextFbo->getSize();
		gl::ScopedFramebuffer scpFbo( mTextFbo );
		gl::clear( ColorA( 0 , 0, 0, 0 ) );
		gl::ScopedViewport scpVp( ivec2(), size );
		gl::ScopedMatrices scpMtrx;
		gl::ScopedColor scpCol( 1, 1, 1);
		
		vec2 stringSize = mTextureFont->measureString( mString );
		float descent = mTextureFont->getDescent();
		float ascent = mTextureFont->getAscent();
		mTextSize = stringSize + vec2( 0, descent );
		
		// OPTIONALLY, draw the text metrics
		/*
		// string size - RED
		gl::color(1, 0, 0);
		gl::drawSolidRect( Rectf( -10, 0, stringSize.x + 10.0, stringSize.y ) );
		// ascent - CYAN
		gl::color(0, 1, 1);
		gl::drawSolidRect( Rectf( 0, stringSize.y - ascent, stringSize.x, ascent ) );
		// descent - YELLOW
		gl::color(1, 1, 0);
		gl::drawSolidRect( Rectf( 0, stringSize.y-descent, stringSize.x, stringSize.y ) );
		// above ascent
		gl::color( 0, 1, 0 );
		gl::drawSolidRect( Rectf( 0, 0, stringSize.x, stringSize.y-ascent ) );*/
		
		// DRAW string to FBO
		gl::color(1, 1, 1);
		mTextureFont->drawString( mString, vec2( 0, stringSize.y - descent ) );
	}
	
	// GET Texture from FBO
	mTextSurf = Surface( mTextFbo->readPixels8u( mTextFbo->getBounds() ) );
}
void ProjectionMappingApp::draw()
{
	if (mEditMode == EditMode_RECORD) {
		//		std::string imgName = (boost::format("%s\\out_images\\image_%05d.png") % SeqImageDir % mFrame).str();
		
		std::string imgName = (boost::format("%s\\%s_%05d.png") % mOutImageFolder % mOutImageName % mFrame).str();
			
		writeImage(imgName.c_str(), mFbo.getTexture());
		++mFrame;
	}

	gl::clear(Color(0, 0, 0));
	glColor3f(1, 1, 1);

	// 画像の表示を下向きに(もとに戻す)
	gl::setMatricesWindow(getWindowSize(), true); 
	
	glPushMatrix();
	if (mScale < 1.0) {
		Vec2f wc = getWindowCenter();
		glTranslatef(wc.x/2, wc.y/2, 0.0);
		glScalef(mScale, mScale, mScale);
	}

	if (mMeshMode) {
		glColor3f(1, 1, 0);
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		gl::draw(mMesh);
	} else {
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		gl::draw(mFbo.getTexture());
	}

	if (mIsShowCtrlMesh) {
		for (int k = 0; k < mCtrlPointsNum; ++k) {
			Vec2f p = mCtrlPoints[k].pos;
			glColor3f(0, 0, 0);
			gl::drawStrokedRect(Rectf(p.x-5+1, p.y-5+1, p.x+5+1, p.y+5+1));
			if (mCtrlPoints[k].isSelected) {
				glColor3f(1, 0, 0);
			} else {
				glColor3f(1, 1, 1);
			}
			gl::drawStrokedRect(Rectf(p.x-5, p.y-5, p.x+5, p.y+5));
		}

		for (int j = 0; j < 2; ++j) {	
			for (int i = 0; i < 2; ++i) {
				float px = distpoints[j][i][0];
				float py = distpoints[j][i][1];
				glColor3f(1, 1, 0);
				gl::drawStrokedRect(Rectf(px-10, py-10, px+10, py+10));
			}
		}
	}

	glPopMatrix();

	if (mSelectionMode) gl::drawStrokedRect(mSelectRegion);
	params::InterfaceGl::draw();
	
	if (mEditMode == EditMode_RECORD) {
		gl::enableAlphaBlending();
		const int ix = 700;
		const int iy = 900;
		mTexFont->drawString((boost::format("RENDERING : [%d / %d] Done.") % mFrame % mDuration).str(), Rectf(ix, iy, ix+500, iy+200));
	}
}
void iosAppTestApp::draw()
{
	gl::enableAlphaBlending();
	gl::enableDepthRead();
	tester.setState( TestCallbackOrder::DRAW );
	CameraPersp mCam;
	mCam.lookAt( Vec3f( 3, 2, -3 ), Vec3f::zero() );
	mCam.setPerspective( 60, getWindowAspectRatio(), 1, 1000 );

	if( isUnplugged() )
		gl::clear( Color( 0.2f, 0.2f, 0.3f ) );
	else
		gl::clear( Color( 0.4f, 0.2f, 0.2f ) );		

	gl::enable( GL_TEXTURE_2D );
	gl::color( Color::white() );
	gl::enableDepthRead();
	mTex.bind();
	gl::setMatrices( mCam );
	glPushMatrix();
		gl::multModelView( mCubeRotation );
		gl::drawCube( Vec3f::zero(), Vec3f( 2.0f, 2.0f, 2.0f ) );
	glPopMatrix();
	gl::disable( GL_TEXTURE_2D );
	
	gl::setMatricesWindow( getWindowSize() );
	for( map<uint32_t,TouchPoint>::const_iterator activeIt = mActivePoints.begin(); activeIt != mActivePoints.end(); ++activeIt ) {
		activeIt->second.draw();
	}

	for( list<TouchPoint>::iterator dyingIt = mDyingPoints.begin(); dyingIt != mDyingPoints.end(); ) {
		dyingIt->draw();
		if( dyingIt->isDead() )
			dyingIt = mDyingPoints.erase( dyingIt );
		else
			++dyingIt;
	}
	
	// draw yellow circles at the active touch points
	gl::color( Color( 1, 1, 0 ) );
	for( auto touch : getActiveTouches() )
		gl::drawStrokedCircle( touch.getPos(), 20.0f );
			
	if( getWindow() == mSecondWindow || Display::getDisplays().size() < 2 ) {
		static Font font = Font( "Arial", 48 );
		static std::string lastMessage;
		static gl::Texture messageTex;
		if( lastMessage != mSecondWindowMessage ) {
			TextBox box = TextBox().font( font ).text( mSecondWindowMessage );
			messageTex = box.render();
			lastMessage = mSecondWindowMessage;
		}
		if( messageTex ) {
			gl::color( Color::white() );
			gl::draw( messageTex, Vec2i( ( getWindowWidth() - messageTex.getCleanWidth() ) / 2, getWindowCenter().y ) );
		}
	}
//
	gl::disableDepthRead();
	gl::color( Color( 0.0f, 1.0f, 0.0f ) );
	mFont->drawString( orientationString( getWindowOrientation() ) + "@ " + toString( getWindowContentScale() ), Vec2f( 10.0f, 60.0f ) );
//	gl::drawStringCentered( "Orientation: " + orientationString( getInterfaceOrientation() ), Vec2f( getWindowCenter().x, 30.0f ), Color( 0.0f, 1.0f, 0.0f ), Font::getDefault() ); // ???: why not centered?

	mFont->drawString( toString( floor(getAverageFps()) ) + " fps", Vec2f( 10.0f, 90.0f ) );
}