コード例 #1
0
void TextParticlesApp::update()
{
	if( !mActive )
		return;

	// Update particles on the GPU
	gl::ScopedGlslProg prog( mUpdateProg );
	gl::ScopedState rasterizer( GL_RASTERIZER_DISCARD, true );	// turn off fragment stage
	mPerlin3dTex->bind(0);
	mUpdateProg->uniform( "uPerlinTex", 0 );
	mUpdateProg->uniform( "uStep", mStep.value() );
	mUpdateProg->uniform( "uDampingSpeed", mDampingSpeed );
	mUpdateProg->uniform( "uNoiseOffset", mNoiseOffset );
	mUpdateProg->uniform( "uEndColor", mEndColor );
	
	// Bind the source data (Attributes refer to specific buffers).
	gl::ScopedVao source( mAttributes[mSourceIndex] );
	// Bind destination as buffer base.
	gl::bindBufferBase( GL_TRANSFORM_FEEDBACK_BUFFER, 0, mParticleBuffer[mDestinationIndex] );
	gl::beginTransformFeedback( GL_POINTS );

	// Draw source into destination, performing our vertex transformations.
	gl::drawArrays( GL_POINTS, 0, mTextParticleCount );
	gl::endTransformFeedback();
	
	mPerlin3dTex->unbind();
	
	// Swap source and destination for next loop
	std::swap( mSourceIndex, mDestinationIndex );
}
コード例 #2
0
void camerasApp::draw()
{
	gl::clear( Color( 0, 0.1f, 0.2f ) );
    
    // draw the cube
	gl::pushMatrices();
    gl::translate( getWindowCenter() );
    gl::rotate( mArcball.getQuat() );
    if(mTexture) {
        mTexture->enableAndBind();
        gl::drawCube(Vec3f::zero(), Vec3f(320,320,320));
        mTexture->unbind();
    }
	gl::popMatrices();
    


}
コード例 #3
0
void ProceduralAnimApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0.4f, 0.5f, 0.6f ) );
	gl::setMatrices( mMayaCam.getCamera() );
	gl::enableDepthRead();
	
	gl::Light light( gl::Light::DIRECTIONAL, 0 );
	light.setAmbient( Color::white() );
	light.setDiffuse( Color::white() );
	light.setSpecular( Color::white() );
	light.lookAt( mLightPos, Vec3f::zero() );
	light.update( mMayaCam.getCamera() );
	light.enable();
	
	gl::pushMatrices();
	float e = (float)getElapsedSeconds();
	gl::translate( math<float>::sin( 1.3f * e ), math<float>::cos( 2.7f * e ) );
	gl::enable( GL_LIGHTING );
	gl::enable( GL_NORMALIZE );
		
	if ( mEnableWireframe )
		gl::enableWireframe();
	if( mDrawMesh ) {
		SkinningRenderer::draw( mSkinnedVboBird );
	}
	if ( mEnableWireframe )
		gl::disableWireframe();
	
	gl::disable( GL_LIGHTING );
	gl::disable( GL_NORMALIZE );
	
	if( mDrawSkeleton) {
		SkinningRenderer::draw( mSkinnedVboBird->getSkeleton() );
	}
	
	if( mDrawLabels ) {
		SkinningRenderer::drawLabels( mSkinnedVboBird->getSkeleton(), mMayaCam.getCamera() );
	}

	gl::popMatrices();
	
	Vec3f mRight, mUp;
	mMayaCam.getCamera().getBillboardVectors(&mRight, &mUp);
//	gl::disableDepthRead();
	gl::disableDepthWrite();
	gl::enableAlphaBlending();
	dustParticleTex->enableAndBind();
	
	mDustShader->bind();
	mDustShader->uniform( "tex", 0 );
	for( const auto& d : mDust ) {
		mDustShader->uniform( "transparency", 1.0f - math<float>::abs(d.z)/(SCENE_SIZE/2.0f) );
		gl::drawBillboard(d, Vec2f(60.f, 60.f), 0.0f, mRight, mUp);
	}
	mDustShader->unbind();
	
	dustParticleTex->unbind();

	mParams.draw();
}
コード例 #4
0
void PointCloudApp::draw()
{
	gl::viewport( getWindowSize() );
	gl::clear();
	gl::setMatrices( mCamUi.getCamera() );
	gl::enableAlphaBlending();
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	if ( mSurfaceColor ) {
		if ( mTextureColor ) {
			mTextureColor->update( *mSurfaceColor );
		} else {
			mTextureColor = gl::Texture::create( *mSurfaceColor );
		}
		mTextureColor->bind( 0 );
	}
	if ( mChannelDepth ) {
		if ( mTextureDepth ) {
			gl::ScopedTextureBind scopeTextureBind( mTextureDepth->getTarget(), mTextureDepth->getId() );
			glTexSubImage2D( mTextureDepth->getTarget(), 0, 0, 0,
				mTextureDepth->getWidth(), mTextureDepth->getHeight(),
				GL_RED_INTEGER,	GL_UNSIGNED_SHORT, mChannelDepth->getData() );
		} else {
			mTextureDepth = gl::Texture::create( 
				mChannelDepth->getWidth(), mChannelDepth->getHeight(), 
				gl::Texture::Format().dataType( GL_UNSIGNED_SHORT ).internalFormat( GL_R16UI ) );
		}
		mTextureDepth->bind( 1 );
	}
	if ( mSurfaceDepthToCameraTable && !mTextureDepthToCameraTable ) {
		mTextureDepthToCameraTable = gl::Texture::create( *mSurfaceDepthToCameraTable );
		mTextureDepthToCameraTable->bind( 2 );
	}
	if ( mSurfaceDepthToColorTable ) {
		if ( mTextureDepthToColorTable ) {
			mTextureDepthToColorTable->update( *mSurfaceDepthToColorTable );
		} else {
			mTextureDepthToColorTable = gl::Texture::create( 
				*mSurfaceDepthToColorTable,
				gl::Texture::Format().dataType( GL_FLOAT ) );
		}
		mTextureDepthToColorTable->bind( 3 );
	}

	gl::ScopedGlslProg scopeGlsl( mGlslProg );
	gl::setDefaultShaderVars();
	mGlslProg->uniform( "uTextureColor",				0 );
	mGlslProg->uniform( "uTextureDepth",				1 );
	mGlslProg->uniform( "uTextureDepthToCameraTable",	2 );
	mGlslProg->uniform( "uTextureDepthToColorTable",	3 );

	gl::draw( mVboMesh );
	
	if ( mTextureColor ) {
		mTextureColor->unbind();
	}
	if ( mTextureDepth ) {
		mTextureDepth->unbind();
	}
	if ( mTextureDepthToCameraTable ) {
		mTextureDepthToCameraTable->unbind();
	}
	if ( mTextureDepthToColorTable ) {
		mTextureDepthToColorTable->unbind();
	}

	mParams->draw();
}