Beispiel #1
0
void Day44App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.0, 0.0, 0.0 ) );
    
    // gl::rotate(angleAxis(theta, vec3(0.1,1.,0.)));
    // gl::rotate(angleAxis(theta, vec3(0.3,0.,0.)));
    
    int counter = 100;
    for (vec3 v : mPositions)
    {
        gl::ScopedMatrices push;
        gl::translate(v);
        //  gl::rotate(counter + theta, vec3(1.,0.,0.));
        // gl::rotate(counter + theta, vec3(0.5,0.8,0.));
        mBatch->draw();
        counter++;
    }
    
    //    {
    //        gl::ScopedMatrices push;
    //        gl::translate(1.5f, 0.f,0.f);
    //        mBatchB->draw();
    //    }
    
    {
        gl::ScopedMatrices push;
        gl::translate(lightPos.x, lightPos.y, lightPos.z);
        mLight->draw();
    }
    
    if (getElapsedFrames() > 240.f) saveGif();
    
}
Beispiel #2
0
void Day59App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.1, 0.1, 0.1 ) );
    gl::color(Color(0.,0.,0.));
    gl::clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
    mCam.setEyePoint(vec3(0.,0.,fabs(cos(omega) * 50.f)));
  mPerlin.setSeed(getElapsedFrames());
    
    // enable stencil test to be able to give the stencil buffers values.
    gl::ScopedState scopeStencil( GL_STENCIL_TEST, true );
  //  gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
    for (int i =0; i <NUM_OBJS; i++)
    {
        
        vec3 noise = mPerlin.dfBm(mRandomPositions[i]);
    
        gl::ScopedMatrices scpMtx;
        gl::translate(mRandomPositions[i]);
        
    
        {
            gl::ScopedMatrices push;
            gl::rotate(angleAxis(theta + mOffsets[i], vec3(1.0, 0., 0.)));
            gl::translate(mRandomPositions[i]);
            gl::scale(mScales[i]);
            
            //DRAW THE MAIN OBJECT (1ST RENDER PASS) AS NORMAL, FILL THE STENCIL BUFFER
            gl::stencilFunc(GL_ALWAYS, 1, 0xFF); //ALL FRAGMENTS MUST UPDATE THE STENCIL BUFFER
            gl::stencilMask(0xFF); //ENABLE WRITING TO THE STENCIL BUFFER
            mObject->draw();
        }
        
        //IF THE STENCIL TEST FAILS, KEEP THE FRAGMENT
        //IF STENCIL PASSES AND DEPTH FAILS, KEEP THE FRAGMENT
        //IF THE DEPTH TEST AND STENCIL TEST PASS, REPLACE THE FRAGMENT
        glStencilOp(GL_KEEP  , GL_KEEP, GL_REPLACE);
        
        //2ND RENDER PASS - DRAW OBJECT SLIGHTLY BIGGER, BUT DISABLE STENCIL WRITING.  BECAUSE THE STENCIL BUFFER IS FILLED WITH 1s (PARTICULARLY IN THE AREA OF THE ORIGINAL OBJECT), THE ONLY THING THAT WILL BE DRAWN IS THE AREA OF THE 2ND OBJECT, IE. THE SIZE DIFFERENCE
        
        gl::stencilFunc(GL_NOTEQUAL, 1, 0xFF); //don't update the stencil buffer
        gl::stencilMask(0x00);
        gl::disable(GL_DEPTH_TEST);
        {
            gl::ScopedMatrices push;
            gl::rotate(angleAxis(theta + mOffsets[i], vec3(1.0, 0., 0.)));
            gl::translate(mRandomPositions[i]);
            
            gl::scale(vec3(mScales[i] + vec3(0.1) ));
            
            mBorderObject->draw();
        }
    
    }
    
    gl::stencilMask(0xFF);
    gl::enable(GL_DEPTH_TEST);
  //  saveGif();
    
}
Beispiel #3
0
void Day61App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.0, 0.0, 0.0 ) );

    {
        gl::ScopedMatrices scpMtr;
        gl::rotate(angleAxis(theta, vec3(0,1,0)));
        gl::color(ColorAf(1.,1.,1.,1.));
        mSolidSphere->draw();
    }
    
  //  mBatch->draw();
    for (int i = 0 ; i < 20 ; i++)
    {
        mPos.x = cos(theta + 12*i);
        mPos.y = 0.5 - cos(sin(theta + i));
        mPos.z = sin(theta + 12*i);
        gl::ScopedMatrices push;
        gl::translate(mPos);
        mBatch->draw();
    }
    
    //if(getElapsedFrames() > 240) saveGif();
    saveGif();
    
}
void EnvironmentTestApp::draw() {
  gl::enableDepthRead();
  gl::enableDepthWrite();

#ifdef ENABLE_DOF
  mDOFFilter->beginRender();
#endif
  {
    gl::ScopedMatrices mtx;
    gl::setMatrices(mCam);
    gl::clear(Color::black());

    {
      gl::ScopedModelMatrix modelMtx;
      gl::scale(0.5, 0.5, 0.5);
#ifdef ENABLE_SEM
      gl::ScopedTextureBind tex0(mEnvironmentTexture, 0);
      gl::ScopedTextureBind tex1(mIlluminationTexture, 1);
#endif
      mObjectBatch->draw();
    }
    
    gl::ScopedFaceCulling culling(true, GL_FRONT);
    gl::ScopedTextureBind environmentTex(mEnvironmentTexture);
    mEnvironmentBatch->draw();
  }
#ifdef ENABLE_DOF
  mDOFFilter->endRender();
  mDOFFilter->drawFullscreen();
#endif

#ifdef EXPORT_FRAMES
  saveFrame();
#endif
}
void ImageBasedLighting_05App::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    
    gl::setMatrices( mCam );
    
    // enable depth testing
    gl::ScopedDepth scopedDepth( true );
    
    // bind the cubemap textures
    gl::ScopedTextureBind scopedTexBind0( mTextureRadianceMap, 0 );
    gl::ScopedTextureBind scopedTexBind1( mTextureIrradianceMap, 1 );
    gl::ScopedTextureBind scopedTexBind2( mNormalMap, 2 );
    gl::ScopedTextureBind scopedTexBind3( mRoughnessMap, 3 );
    gl::ScopedTextureBind scopedTexBind4( mMetallicMap, 4 );
    gl::ScopedTextureBind scopedTexBind5( mColorMap, 5 );
    gl::ScopedTextureBind scopedTexBind6( mAOMap, 6 );
    gl::ScopedTextureBind scopedTexBind7( mSpecularMap, 7 );
    
    auto shader = mBatchModel->getGlslProg();
    shader->uniform( "uRadianceMap", 0 );
    shader->uniform( "uIrradianceMap", 1 );
    shader->uniform( "uNormalMap", 2 );
    shader->uniform( "uRoughnessMap", 3 );
    shader->uniform( "uMetallicMap", 4 );
    shader->uniform( "uColorMap", 5 );
    shader->uniform( "uAOMap", 6 );
    shader->uniform( "uSpecularMap", 7);
    
    // sends the base color, the specular opacity,
    // the light position, color and radius to the shader
//    shader->uniform( "uBaseColor", mBaseColor );
//    shader->uniform( "uSpecular", mSpecular );
//    shader->uniform( "uNormalMapScale",mNormalMapScale);
    
    // sends the tone-mapping uniforms
    shader->uniform( "uExposure", mExposure );
    shader->uniform( "uGamma", mGamma );
    
    // render a grid of sphere with different roughness/metallic values and colors
    {
        
//        shader->uniform( "uRoughness", mRoughness );
//        shader->uniform( "uRoughness4", pow( mRoughness, 4.0f ) );
//        shader->uniform( "uMetallic", mMetallic );
        
        mBatchModel->draw();
        
    }
    
    // render skybox
    shader = mBatchSkyBox->getGlslProg();
    shader->uniform( "uExposure", mExposure );
    shader->uniform( "uGamma", mGamma );
    mBatchSkyBox->draw();
    
    //  DRAW SETTINGS
    _params->draw();
}
Beispiel #6
0
void GeometryApp::draw()
{
	// Prepare for drawing.
	gl::clear();
	gl::setMatrices( mCamera );
	
	// Draw the grid.
	if( mShowGrid && mGrid ) {
		gl::ScopedGlslProg scopedGlslProg( gl::context()->getStockShader( gl::ShaderDef().color() ) );
		// draw the coordinate frame with length 2.
		gl::drawCoordinateFrame( 2 );
		mGrid->draw();
	}

	if( mPrimitive ) {
		gl::ScopedTextureBind scopedTextureBind( mTexture );
		mPhongShader->uniform( "uTexturingMode", mTexturingMode );

		// Rotate it slowly around the y-axis.
		gl::ScopedModelMatrix matScope;
		gl::rotate( float( getElapsedSeconds() / 5 ), 0, 1, 0 );

		// Draw the normals.
		if( mShowNormals && mPrimitiveNormalLines ) {
			gl::ScopedColor colorScope( Color( 1, 1, 0 ) );
			mPrimitiveNormalLines->draw();
		}

		// Draw the primitive.
		gl::ScopedColor colorScope( Color( 0.7f, 0.5f, 0.3f ) );

		if( mViewMode == WIREFRAME ) {
			// We're using alpha blending, so render the back side first.
			gl::ScopedAlphaBlend blendScope( false );
			gl::ScopedFaceCulling cullScope( true, GL_FRONT );

			mWireframeShader->uniform( "uBrightness", 0.5f );
			mPrimitiveWireframe->draw();

			// Now render the front side.
			gl::cullFace( GL_BACK );

			mWireframeShader->uniform( "uBrightness", 1.0f );
			mPrimitiveWireframe->draw();
		}
		else
			mPrimitive->draw();
	}

	// Render the parameter window.
#if ! defined( CINDER_GL_ES )
	if( mParams )
		mParams->draw();
#endif
}
void basic3_batchApp::draw()
{
	gl::clear();
    gl::enableDepthRead();
    gl::enableDepthWrite();
    
    gl::setMatrices(mCam);
    
    int numSpheres = 64;
    float maxAngle = M_PI * 7;
    float spiralRadius = 1;
    float height = 2;
    float boxSize = 0.05f;
    float anim = getElapsedFrames() / 60.0f;
    
    for (int s = 0; s<numSpheres; ++s) {
        float rel = s/(float)numSpheres;
        float angle = rel * maxAngle;
        float y = fabs(cos(rel*M_PI*anim))*height;
        float r = rel * spiralRadius;
        vec3 offset(r*cos(angle), y/2, r*sin(angle));
        
        gl::pushModelMatrix();
        gl::translate(offset);
        gl::scale(vec3(boxSize, y, boxSize));
        gl::color(Color(CM_HSV, rel, 1, 1));
        mBox->draw();
        gl::popModelMatrix();
    }
}
Beispiel #8
0
void EarthquakeApp::draw()
{
	gl::clear( Color( 1, 0, 0 ) );

	gl::ScopedDepth       depth( true );
	gl::ScopedColor       color( 1, 1, 1 );

	// Draw stars.
	if( mShowStars ) {
		gl::ScopedTextureBind tex0( mStars, 0 );
		gl::ScopedFaceCulling cull( true, GL_FRONT );
		mStarSphere->draw();
	}

	// Draw Earth.
	if( mShowEarth ) {
		mEarth.draw();
	}

	// Draw quakes.
	if( mShowQuakes ) {
		mEarth.drawQuakes();
	}

	// Draw labels.
	if( mShowText ) {
		mEarth.drawQuakeLabelsOnSphere( mPov.mEyeNormal, mPov.mDist );
	}

	if( mSaveFrames ) {
		static int currentFrame = 0;
		writeImage( getHomeDirectory() / "CinderScreengrabs" / ( "Highoutput_" + toString( currentFrame++ ) + ".png" ), copyWindowSurface() );
	}
}
void SphericalStereoApp::update()
{
	if( mRift ) {
		hmd::ScopedRiftBuffer bind{ mRift };
		gl::clear();
		for( auto eye : mRift->getEyes() ) {
			mRift->enableEye( eye );
			const auto& pano = mPanos.at( mPanoIndex );
			mStereoGlsl->uniform( "uDisplayMode", pano.mDisplayMode );
			mStereoGlsl->uniform( "uRightEye", static_cast<int>(eye) );
			gl::ScopedTextureBind tex0( pano.mLatLong );
			mSphere->draw();

			{
				auto size = mRift->getFboSize();
				gl::ScopedMatrices push;
				gl::setMatricesWindow( size.x / 2, size.y );
				vec3 latencies = mRift->getLatencies();

				stringstream ss;
				ss << mPanos.at( mPanoIndex ).mName << std::endl;
				ss << " " << std::endl;
				ss << "App fps: " << toString( getAverageFps() ) << std::endl;
				ss << "Ren: " << latencies.x << std::endl;
				ss << "TWrp: " << latencies.y << std::endl;
				ss << "PostPresent: " << latencies.z << std::endl;

				auto tbox = TextBox().text( ss.str() ).font( Font( "Arial", 20.0f ) ).color( Color::white() ).backgroundColor( Color::black() );
				gl::draw( gl::Texture2d::create( tbox.render() ), vec2( size.x / 3, size.y / 2 ) );
			}
		}
	}
}
Beispiel #10
0
void Day48App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0, 0, 0 ) );
    gl::color(ColorAf(1.0f,1.f,1.f,1.f));
    
    //gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
    
    for (int i = 0; i < NUM_OBJS; i++)
    {
        gl::ScopedMatrices push;
        gl::translate(mPositions[i]);
        mBatch->draw();
        
    }
    
    
    
    //COLOUR AND DRAW THE POINT LIGHTS
    for (int i = 0; i < mPointLights.size(); i++)
    {
        switch (i){
            case 0:
                gl::color(Color(1.,1.,1.));
                break;
                
            case 1: //RED
                gl::color(Color(1.,0.,0.));
                break;
                
            case 2:  //BLUE
                gl::color(Color(0.,1.,0.));
                break;
                
            case 3:  //GREEN
                gl::color(Color(0.,0.,1.));
                break;
        }
        
        gl::ScopedMatrices push;
        gl::translate(mPointLights[i]);
        mLight->draw();
        
    }
     
}
Beispiel #11
0
void ArcballTestApp::draw()
{
	CameraPersp &cam = ( mUsingCameraUi ) ? mDebugCam : mCam;
	gl::clear( Color( 0, 0.0f, 0.15f ) );
	gl::setMatrices( cam );

	// draw the earth
	gl::enableDepthRead();
	gl::enableDepthWrite();
	gl::translate( mEarthSphere.getCenter() );
	gl::rotate( mArcball.getQuat() );
	mEarthTex->bind();
	mEarth->draw();

	// draw constraint axis
	if( mArcball.isUsingConstraint() ) {
		gl::setMatrices( cam );
		gl::color( 1, 1, 0 );
		gl::translate( mEarthSphere.getCenter() );
		gl::rotate( glm::rotation( vec3( 0, 1, 0 ), mArcball.getConstraintAxis() ) );
		mConstraintAxis->draw();
	}

	gl::disableDepthRead();

	// draw from vector marker
	gl::setMatrices( cam );
	gl::color( 0, 1, 0.25f );
	gl::translate( mEarthSphere.getCenter() + mArcball.getFromVector() * mEarthSphere.getRadius() );
	mMarker->draw();

	// draw to vector marker
	gl::setMatrices( cam );
	gl::color( 1, 0.5f, 0.25f );
	gl::translate( mEarthSphere.getCenter() + mArcball.getToVector() * mEarthSphere.getRadius() );
	mMarker->draw();

	// draw the elliptical axes
	gl::setMatricesWindow( getWindowSize() );
	gl::color( 1, 0, 0 );
	vec2 center, axisA, axisB;
	mCam.calcScreenProjection( mEarthSphere, getWindowSize(), &center, &axisA, &axisB );
	gl::drawLine( center - axisA, center + axisA );
	gl::drawLine( center - axisB, center + axisB );
}
void CubeMappingApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::setMatrices( mCam );

	mCubeMap->bind();
	gl::pushMatrices();
		gl::multModelMatrix( mObjectRotation );
		gl::scale( vec3( 4 ) );
		mTeapotBatch->draw();
	gl::popMatrices();
	
	// draw sky box
	gl::pushMatrices();
		gl::scale( SKY_BOX_SIZE, SKY_BOX_SIZE, SKY_BOX_SIZE );
		mSkyBoxBatch->draw();
	gl::popMatrices();		
}
Beispiel #13
0
void Day72App::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    gl::setMatrices(mCam);
    gl::color(Color(0.2,0.2,0.2));
    
    gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
    gl::rotate(angleAxis(cos(theta/2), normalize(vec3(1., 0., 0.4))));
    
    int i = getElapsedFrames();
    
    if ( i <= 80 ) mIcos->draw();
    else if ( i > 80 && i <= 160) mTorus->draw();
    else mCube->draw();
    
    
    saveGif();
}
void NormalMappingBasicApp::draw()
{
	gl::clear();

	gl::setMatrices( mCam );
	gl::ScopedModelMatrix modelScope;
	gl::multModelMatrix( mCubeRotation );
	mGlsl->uniform( "uLightLocViewSpace", vec3( mCam.getViewMatrix() * vec4( mLightPosWorldSpace, 1 )) );
	mBatch->draw();
}
Beispiel #15
0
void Day37bApp::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0., 0., 0 ) );
    
    {
        gl::ScopedMatrices push;
        gl::rotate(theta, vec3(1.,0.,0.));
        mBatch->draw();
    }
    
    {
        gl::ScopedMatrices push;
        gl::translate(lightPos.x, lightPos.y, lightPos.z);
        mLight->draw();
    }
    
    if (getElapsedFrames() > 240.f) saveGif();
    
}
Beispiel #16
0
void Day41App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( .0, 0., 0. ) );

    for (int i = 0; i < 4; i++)
    {
        gl::ScopedMatrices push;
        gl::translate(0.,1.*i, 0.);;
        gl::rotate(0.5*sin(i*3), vec3(0.,1.,0.));
        mBatch->draw();
    }

    {
        gl::ScopedMatrices push;
        gl::translate(lightPos);
        mLight->draw();
    }
    if (getElapsedFrames() > 240.f) saveGif();

}
void ShadowMappingBasic::drawScene( bool shadowMap )
{
	gl::pushModelMatrix();
	gl::color( Color( 0.4f, 0.6f, 0.9f ) );
	gl::rotate( mTime * 2.0f, 1.0f, 1.0f, 1.0f );

	if( shadowMap )
		mTeapotBatch->draw();
	else
		mTeapotShadowedBatch->draw();

	gl::popModelMatrix();
	
	gl::color( Color( 0.7f, 0.7f, 0.7f ) );
	gl::translate( 0.0f, -2.0f, 0.0f );
	
	if( shadowMap )
		mFloorBatch->draw();
	else
		mFloorShadowedBatch->draw();
}
Beispiel #18
0
void RotatingCubeApp::draw()
{
	gl::clear();

	gl::setMatrices( mCam );

	gl::ScopedModelMatrix modelScope;
	gl::multModelMatrix( mCubeRotation );

	mTexture->bind();
	mBatch->draw();
}
void PointCloudApp::draw()
{
	gl::clear(Color(0.25f, 0.1f, 0.15f));
	
	//gl::enableAdditiveBlending();
	gl::enableDepthRead();
	gl::enableDepthWrite();
	gl::setMatrices(mMayaCam.getCamera());

	gl::ScopedTextureBind cTexture(mTexRgb);
	gl::pointSize(getWindowWidth()/mDepthDims.x);
	mDrawObj->draw();
}
Beispiel #20
0
void ObjLoaderApp::draw()
{
    gl::enableDepthWrite();
    gl::enableDepthRead();

    gl::clear( Color( 0.0f, 0.1f, 0.2f ) );

    gl::setMatrices( mCam );

    gl::pushMatrices();
    gl::rotate( mArcball.getQuat() );
    mBatch->draw();
    gl::popMatrices();
}
void MyoBlockTestApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
    
    gl::ScopedMatrices push;
    
    gl::setMatrices(mCam);
    
    {
        gl::ScopedModelMatrix model;
        gl::multModelMatrix(toMat4(mArmband.mRotation));
        mHelloWorld->draw();
    }
    
}
Beispiel #22
0
void BasicApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) ); 
	gl::setMatrices(mCamera);

	drawWorld(vec3(0), vec3(10), 2.0f);
	gl::pointSize(4.0f);
	mBatch->draw();

	gl::color(Color(0, 1, 1));
	gl::enableWireframe();
	gl::draw(*mTris.get());


}
Beispiel #23
0
void FiretrailApp::draw()
{
    const gl::ScopedViewport scopedVPort(vec2(0,0), getWindowSize());
    const gl::ScopedMatrices scopedMatrices;
    gl::setMatrices( mCamera );
    
	gl::clear();
    gl::color(Color::white());

    gl::ScopedBlendAdditive scopedBlend;
    gl::ScopedTextureBind texFire( mFireTex, 0);
    gl::ScopedTextureBind noiseFire( mNoiseTex, 1);
    
    mGlsl->uniform("time", (float)getElapsedSeconds() * mTimeFactor);
    
    mBatch->draw();
    
    mParams->draw();
}
void ViewportArrayApp::update()
{
	// bind the fbo and enable depth testing
	gl::ScopedFramebuffer scopedFbo( mFbo );
	gl::ScopedDepth scopedDepthTest( true );
	
	// clear our fbo
	gl::clear( Color( 0, 0, 0 ) );
	
	// create an array with the different cameras matrices
	vector<mat4> matrices;
	for( auto cam : mCameras ) {
		matrices.push_back( cam.getProjectionMatrix() * cam.getViewMatrix() );
	}
	// and send it to the shader
	mTeapot->getGlslProg()->uniform( "uMatrices", &matrices[0], mCameras.size() );
	
	// render the teapot once (the geometry shader takes care of the rest)
	mTeapot->draw();
}
void MotionBlurFboApp::draw()
{
	gl::viewport( vec2(), mAccumFbo->getSize() );

	if( ! mPaused ) {
		// make 'mAccumFbo' the active framebuffer
		gl::ScopedFramebuffer fbScp( mAccumFbo );
		// clear out both of our FBOs
		gl::clear( Color::black() );
		gl::color( 1, 1, 1, 1 );

		// iterate all the sub-frames
		double startTime = getElapsedSeconds();
		for( int i = 0; i < SUBFRAMES; ++i ) {
			// draw the Cube's sub-frame into mFbo
			gl::enableDepth();
			gl::enableAlphaBlending();
			mFbo->bindFramebuffer();
			gl::clear();
			gl::enableDepth();
			gl::setMatrices( mCam );
			updateCubeRotation( startTime + i / (float)SUBFRAMES );
			gl::multModelMatrix( mCubeRotation );
			mBatch->draw();
			
			// now add this frame to the accumulation FBO
			mAccumFbo->bindFramebuffer();
			gl::setMatricesWindow( mAccumFbo->getSize() );
			gl::enableAdditiveBlending();
			gl::enableDepth( false );
			gl::draw( mFbo->getColorTexture() );
		}
	}
	
	gl::disableDepthRead();
	gl::disableAlphaBlending();
	// set the color to be 1/SUBFRAMES, which divides the HDR image by the number of sub-frames we rendered
	gl::color( 1.0f / SUBFRAMES, 1.0f / SUBFRAMES, 1.0f / SUBFRAMES, 1 );
	gl::setMatricesWindow( getWindowSize() );
	gl::draw( mAccumFbo->getColorTexture() );
}
void GridUtilitiesApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	
	// draw the grid bounds
	gl::ScopedColor color0( ColorA::gray( 1.0f, 0.15f ) );
	auto gridBounds = mGrid.getBounds();
	gl::drawStrokedRect( gridBounds );
	
	// draw the samples found in a 10 pixels radius around the mouse
	auto neighbors = mGrid.rangeSearch( getMousePos() - getWindowPos(), 10.0f );
	gl::drawStrokedCircle( getMousePos() - getWindowPos(), 10.0f );
	gl::ScopedColor red( ColorA( 1.0f, 0.0f, 0.0f, 1.0f ) );
	for( auto n : neighbors ) {
		gl::drawStrokedCircle( n.first->getPosition(), 4.0f );
	}
	
	// draw the samples
	gl::ScopedColor color1( ColorA::gray( 1.0f, 1.0f ) );
	mSamples->draw();
	
	// get all the grid cells and draw the ones that have samples
	size_t bins = mGrid.getNumBins();
	for( size_t i = 0; i < bins; ++i ) {
		auto bin = mGrid.getBin( i );
		if( bin.size() ) {
			gl::drawStrokedRect( mGrid.getBinBounds( i ) );
		}
	}
	
	// try to get a bin at the mouse position
	try {
		auto binIndex = mGrid.getBinIndexAt( getMousePos() - getWindowPos() );
		gl::ScopedColor red( ColorA( 1.0f, 0.0f, 0.0f, 1.0f ) );
		gl::drawStrokedRect( mGrid.getBinBounds( binIndex ) );
		gl::drawStringCentered( to_string( mGrid.getBin( binIndex ).size() ), mGrid.getBinCenter( binIndex ), Color(1,0,0) );
		gl::drawString( "Bin #" + to_string( binIndex ), gridBounds.getUpperLeft() - vec2( 0, 10 ) );
	}
	// the mouse position might be outside of the grid bounds
	catch( const sp::GridOutOfBoundsException &exc ) {}
}
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();
}
Beispiel #28
0
void CompassApp::draw()
{
	gl::clear();
	gl::color( Color::white() );

    gl::pushMatrices();
    gl::setMatrices( mCam );

	mSphereBatch->draw();

	static const float kD = kTargetDistance;
	drawCardinalTex( 'N', vec3(  0,  0, -kD ),	vec3(  0,	  M_PI,	  0 ) );
	drawCardinalTex( 'S', vec3(  0,  0,  kD ),	vec3(  0,	   0,	  0 ) );
	drawCardinalTex( 'E', vec3(  kD, 0,  0 ),	vec3(  0,	  M_PI/2, 0 ) );
	drawCardinalTex( 'W', vec3( -kD, 0,  0 ),	vec3(  0,	 -M_PI/2, 0 ) );
	drawCardinalTex( 'U', vec3(  0,  kD, 0 ),	vec3( -M_PI/2, 0,     0 ) );
	drawCardinalTex( 'D', vec3(  0, -kD, 0 ),	vec3(  M_PI/2, 0,     0 ) );

	gl::popMatrices();

	drawFps();
}
Beispiel #29
0
void Day62App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.0, 0.0, 0.0 ) );
    
    //ROTATE THE CAMERA AROUND THE CENTRE OF THE SCENE
    mCam.setEyePoint(vec3(15 * cos(theta), 0., 15*sin(theta)));
    mCam.lookAt(vec3(0));
    
    int i = 0;
    for(std::map<float,glm::vec3>::reverse_iterator it = sorted.rbegin(); it != sorted.rend(); ++it)
    {
        gl::ScopedMatrices push;
        gl::translate(it->second);
        //gl::rotate(angleAxis(toRadians(mRotations[i]), vec3(0.,1.,0)));
        mBatch->draw();
        i++;
    }
    
    saveGif();
  
}
Beispiel #30
0
void Day28aApp::draw()
{
    gl::setMatrices(mCam);
	gl::clear( Color( 0, 0, 0 ) );
    
    gl::color(Color(1.f,1.f,1.f));
    
    for (int i = 0; i < NUM_INSTANCES; i++)
    {
        gl::ScopedModelMatrix scpMtx;
        
        
        gl::translate(mPositions[i]);
        gl::scale(mScales[i]);
        
        mBatch->draw();
        
        mPositions[i].z = 50*sin(mSpeeds[i] * zPos);
    }
    
  //  if (getElapsedFrames() > 900) saveGif();
}