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 RoyalSociety_jiangy9LucyApp::draw()
{
	gl::draw(*mySurface);

	// display message to explain the controls of my application by "?"-> implement main goal 2 
	if(press%2==1){
		mFont = Font( "Times New Roman", 24 );
		mTextureFont = gl::TextureFont::create( mFont );
		std::string str("Welcome! Press '/' key can open and close this introduction. Use mouse clicking to create flowers with 3 different colors in gray rectangle between grass and river!");
		gl::color( Color8u( 0,0,0 ) );
		gl::enableAlphaBlending();
		Rectf boundsRect( 40, mTextureFont->getAscent() + 40, getWindowWidth() - 40, getWindowHeight() - 40 );
		mTextureFont->drawStringWrapped( str, boundsRect );
		gl::color(Color8u(255,255,255));
	}

}
Exemple #3
0
void HW02App::draw()
{
	if(show_info)
	{
		gl::setMatricesWindow( getWindowSize() );
		gl::enableAlphaBlending();
		gl::clear( Color( 0, 0, 0 ) );
	
		std::string str("Press '?' to show/hide these instructions. Press 'p' to push the bottom shape to the front of the list.  Press 'r' to reverse the list.");
		Rectf boundsRect( 40, mTextureFont->getAscent() + 40, getWindowWidth() - 40, getWindowHeight() - 40 );

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

		mTextureFont->drawStringWrapped( str, boundsRect );
	}
	else
	{
		gl::clear(Color(0,0,0));
		gl::draw(*mySurface_);
	}
}
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 MPEBouncingBallApp::mpeFrameRender(bool isNewFrame)
{
    // Just for the hell of it to see if we can crash by accessing the same data on different threads.
    if (mBalls.size() > 0)
    {
        mBalls[0].manipulateInternalData();
    }

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

    // Paint the Master drawable region gray if we're in step with the server, or red if our
    // draw loop is ahead of the server.
    // The App's loop will continue at the normal speed even if we're waiting for data from the
    // server, we just don't update the state.
    // A flickering background means the FPS is faster than the server data-rate.
    if (mClient->isConnected())
    {
        if (isNewFrame)
        {
            gl::color(Color(0.8, 0.75, 0.75));
        }
        else
        {
            gl::color(Color(1, 0.25, 0.25));
        }
    }
    else
    {
        // Gray if we're not connected
        gl::color(Color(0.5, 0.5, 0.5));
    }

    ivec2 masterSize = mClient->getMasterSize();
    Rectf masterFrame = Rectf(0,0,masterSize.x,masterSize.y);
    gl::drawSolidRect(masterFrame);

    gl::color(0.2,0.2,0.2);
    gl::enableAlphaBlending();
    std::ostringstream stringStream;
    stringStream << "Client ID: " << std::to_string(CLIENT_ID) << std::endl;
    stringStream << "FPS: " << std::to_string((int)getAverageFps()) << std::endl;
    stringStream << "Frame Num: " << std::to_string(mClient->getCurrentRenderFrame()) << std::endl;
    stringStream << "Updates Per Second: " << std::to_string((int)mClient->getUpdatesPerSecond());
    string str = stringStream.str();
    vec2 stringSize = mTextureFont->measureStringWrapped(str, Rectf(0,0,400,400));
    vec2 stringOffset(40,40);
    vec2 rectOffset = mClient->getVisibleRect().getUpperLeft() + stringOffset;
    gl::drawSolidRect(Rectf(rectOffset.x - 10,
                            rectOffset.y - 10,
                            rectOffset.x + 20 + stringSize.x,
                            rectOffset.y + 20 + stringSize.y - mTextureFont->getAscent()));
    gl::color(0.9,0.9,0.9);
    mTextureFont->drawStringWrapped(str,
                                    mClient->getVisibleRect(),
                                    vec2(0, mTextureFont->getAscent()) + stringOffset);

    gl::disableAlphaBlending();

    glEnable (GL_DEPTH_TEST);

    for( Ball & ball : mBalls )
    {
        ball.draw( mClient->getIsRendering3D() );
    }

    glDisable (GL_DEPTH_TEST);

}
void Homework02App::draw()
{
	/*
	I think a better way to impliment all this code in your draw() method
	would be to have it in seperate methods that could be called more easily.
	This would also cut down the clutter in this method and make your code more readable
	*/

	gl::enableAlphaBlending();
	gl::clear(Color(120,120,120));

	//Draws the 12 squares for the background
	//Row 1
	gl::color(ColorA(255,0,0,.5f));
	gl::drawSolidRect(Rectf(0,0,200,200), false);	
	gl::color(ColorA(255,255,0,.5f));
	gl::drawSolidRect(Rectf(200,0,400,200), false);
	gl::color(ColorA(0,0,255,.5f));
	gl::drawSolidRect(Rectf(400,0,600,200), false);
	gl::color(ColorA(0,255,0,.5f));
	gl::drawSolidRect(Rectf(600,0,800,200), false);

	//Row 2
	gl::color(ColorA(0,255,0,.5f));
	gl::drawSolidRect(Rectf(0,200,200,400), false);	
	gl::color(ColorA(255,0,0,.5f));
	gl::drawSolidRect(Rectf(200,200,400,400), false);
	gl::color(ColorA(255,255,0,.5f));
	gl::drawSolidRect(Rectf(400,200,600,400), false);
	gl::color(ColorA(0,0,255,.5f));
	gl::drawSolidRect(Rectf(600,200,800,400), false);

	//Row 3
	gl::color(ColorA(0,0,255,.5f));
	gl::drawSolidRect(Rectf(0,400,200,600), false);	
	gl::color(ColorA(0,255,0,.5f));
	gl::drawSolidRect(Rectf(200,400,400,600), false);
	gl::color(ColorA(255,0,0,.5f));
	gl::drawSolidRect(Rectf(400,400,600,600), false);
	gl::color(ColorA(255,255,0,.5f));
	gl::drawSolidRect(Rectf(600,400,800,600), false);

	//Inner Row 1
	gl::color(ColorA(255,0,0,.5f));
	gl::drawSolidRect(Rectf(100,100,300,300), false);	
	gl::color(ColorA(0,255,0,.5f));
	gl::drawSolidRect(Rectf(300,100,500,300), false);
	gl::color(ColorA(0,0,255,.5f));
	gl::drawSolidRect(Rectf(500,100,700,300), false);

	//Inner Row 2
	gl::color(ColorA(0,0,255,.5f));
	gl::drawSolidRect(Rectf(100,300,300,500), false);	
	gl::color(ColorA(255,0,0,.5f));
	gl::drawSolidRect(Rectf(300,300,500,500), false);
	gl::color(ColorA(0,255,255,.5f));
	gl::drawSolidRect(Rectf(500,300,700,500), false);

	//Creates the string for instructions
	std::string str( "Click any of the rings to bring them to the front of the screen. Press 'R' to reverse the order of the rings. Press '?' to toggle these instructions on/off the screen. Mini-game: Count the number of squares displayed on the screen! (squares underneath squares count, but the border of the program is not a square) Tweet @mmarsden5 with your answer and be the first to win!");
	Rectf boundsRect( 40, mTextureFont->getAscent() + 40, getWindowWidth() - 40, getWindowHeight() - 40 );

	//Text color
	ColorA semiTransparent = ColorA(0,0,0,.9f);
	gl::color(semiTransparent);
	mTextureFont->drawStringWrapped( str, boundsRect );

	Node* current_ = sentinel -> next_;
	do{
		current_ -> draw();
		current_  = current_ -> next_;
	} while(current_ != sentinel);

}