void BulletSpheresApp::draw()
{
	drawToDepthFbo();
	gl::clear( Color( 0.1f, 0.1f, 0.1f ) );
	gl::setMatrices( mCam );
	gl::viewport( vec2( 0 ), getWindowSize() );
	
	// Draw small spheres
	{
		gl::ScopedTextureBind scopeTex0( mLight->getFbo()->getDepthTexture(), 0 );
		gl::ScopedTextureBind scopeTex1( mStripeTex, 1 );
		
		mRenderGlsl->uniform( "uShadowMap",	0 );
		mRenderGlsl->uniform( "uStripeTex",	1 );
		mRenderGlsl->uniform( "uLightPos",		mLight->getPos() );
		mRenderGlsl->uniform( "uDepthBias",	mLight->getDepthBias() );
		mRenderGlsl->uniform( "uLightPos1",	mRigidBodies[0].getPos() );
		mRenderGlsl->uniform( "uLightPos2",	mRigidBodies[1].getPos() );
		mRenderGlsl->uniform( "uRadius1",		mRigidBodies[0].getSize() );
		mRenderGlsl->uniform( "uRadius2",		mRigidBodies[1].getSize() );
		mRenderGlsl->uniform( "uShadowMvp",	mLight->getViewProjection() );
		
		mRenderSphere->drawInstanced( NUM_PARTICLES - 2 );
	}
	
	// Draw big spheres
	mGlowGlsl->bind();
	mGlowGlsl->uniform( "uLightPos", mLight->getPos() );
	for( auto &body : mRigidBodies ){
		auto index = body.getId();
		if( index < NUM_GLOWS ){
			mGlowGlsl->uniform( "uColor", mGlowColors[index] );
			body.draw();
		}
	}
	
	// Draw light source (if point light)
	if( mLight->getPos().w > 0.5f )
		mLight->draw();
	
	mContext->debugDraw();
}
void HeightfieldTerrainApp::draw()
{
	static float rotation = 0.0f;
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) );
	// set our camera
	gl::setMatrices( mCam );
	// rotate the camera position
	gl::multViewMatrix( rotate( toRadians( rotation += 0.1 ), vec3( 0.0f, 1.0f, 0.0f ) ) );
	{
		gl::ScopedModelMatrix scope;
		// Transform it with the physics heightfield
		gl::multModelMatrix( translate( bt::fromBullet( mHeightfieldTerrain->getRigidBody()->getWorldTransform().getOrigin() ) ) );
		mBatch->draw();
	}
	// If we want to draw the debug we can set this and just toggle on and off using...
	//
	// mContext->toggleDebugDraw()
	//
	mContext->debugDraw();
}