Пример #1
0
void RDiffusionApp::setup()
{
	mReactionU = 0.25f;
	mReactionV = 0.04f;
	mReactionK = 0.047f;
	mReactionF = 0.1f;

	mMousePressed = false;
	
	// Setup the parameters
	mParams = params::InterfaceGl::create( "Parameters", ivec2( 175, 100 ) );
	mParams->addParam( "Reaction u", &mReactionU, "min=0.0 max=0.4 step=0.01 keyIncr=u keyDecr=U" );
	mParams->addParam( "Reaction v", &mReactionV, "min=0.0 max=0.4 step=0.01 keyIncr=v keyDecr=V" );
	mParams->addParam( "Reaction k", &mReactionK, "min=0.0 max=1.0 step=0.001 keyIncr=k keyDecr=K" );	
	mParams->addParam( "Reaction f", &mReactionF, "min=0.0 max=1.0 step=0.001 keyIncr=f keyDecr=F" );
	
	mCurrentFBO = 0;
	mOtherFBO = 1;
	mFBOs[0] = gl::Fbo::create( FBO_WIDTH, FBO_HEIGHT, gl::Fbo::Format().colorTexture().disableDepth() );
	mFBOs[1] = gl::Fbo::create( FBO_WIDTH, FBO_HEIGHT, gl::Fbo::Format().colorTexture().disableDepth()  );
	
	mRDShader = gl::GlslProg::create( loadResource( RES_PASS_THRU_VERT ), loadResource( RES_GSRD_FRAG ) );
	mTexture = gl::Texture::create( loadImage( loadResource( RES_STARTER_IMAGE ) ),
								    gl::Texture::Format().wrap(GL_REPEAT).magFilter(GL_LINEAR).minFilter(GL_LINEAR) );
	gl::getStockShader( gl::ShaderDef().texture() )->bind();
	
	resetFBOs();
}
Пример #2
0
void TweakBarApp::setup()
{
	mObjSize = 4;
	mLightDirection = vec3( 0, 0, -1 );
	mColor = ColorA( 0.25f, 0.5f, 1, 1 );
	mSomeValue = 2;

	// Setup our default camera, looking down the z-axis
	mCam.lookAt( vec3( -20, 0, 0 ), vec3( 0 ) );

	// Create the interface and give it a name.
	mParams = params::InterfaceGl::create( getWindow(), "App parameters", toPixels( ivec2( 200, 400 ) ) );

	// Setup the parameters
	mParams->addParam( "Cube Size", &mObjSize ).min( 0.1f ).max( 20.5f ).keyIncr( "z" ).keyDecr( "Z" ).precision( 2 ).step( 0.02f );
	mParams->addParam( "Cube Rotation", &mObjOrientation );
	mParams->addParam( "Cube Color", &mColor );
	mParams->addParam( "String ", &mString );

	mParams->addSeparator();

	// Attach a callback that is fired after a target is updated.
	mParams->addParam( "some value", &mSomeValue ).updateFn( [this] { console() << "new value: " << mSomeValue << std::endl; } );

	// Add a param with no target, but instead provide setter and getter functions.
	std::function<void( vec3 )> setter	= std::bind( &TweakBarApp::setLightDirection, this, std::placeholders::_1 );
	std::function<vec3 ()> getter		= std::bind( &TweakBarApp::getLightDirection, this );
	mParams->addParam( "Light Direction", setter, getter );

	// Other types of controls that can be added to the interface
	mParams->addButton( "Button!", std::bind( &TweakBarApp::button, this ) );
	mParams->addText( "text", "label=`This is a label without a parameter.`" );
}
Пример #3
0
void AudioObjApp::initGui()
{
    mParams = params::InterfaceGl::create( "Settings", Vec2f( 200, 250 ) );
    mParams->addParam( "Obj color",     &mObjColor );
    mParams->addParam( "Wireframe",     &mRenderWireframe );
    mParams->addParam( "Data Gain",     &mFeatureGain,         "min=0.0 max=25.0 step=0.1" );
    mParams->addParam( "Data Offset",   &mFeatureOffset,       "min=-1.0 max=1.0 step=0.01" );
    mParams->addParam( "Data Damping",  &mFeatureDamping,      "min=0.0 max=0.99 step=0.01" );
    mParams->addParam( "Spread",        &mFeatureSpread,       "min=0.0 max=1.0 step=0.01" );
    mParams->addParam( "Spread Offset", &mFeatureSpreadOffset, "min=0.0 max=1.0 step=0.01" );
}
void WaterSimulationApp::update(){
	////change status
	float dt = 1.f/60.0f;
	if(mAnimate){
		if(randomForce.lengthSquared()>0 && mAddNewForce) addForce(dt);
		fluidsys->step(dt);
		mParams->setOptions("status","label=`In animation:`");
	}else{
		mParams->setOptions("status","label=`Idle:`");
	}
}
Пример #5
0
void BasicReceiverApp::initGui()
{
    mParams = params::InterfaceGl::create( "Settings", Vec2f( 220, 200 ) );
    
    mParams->addParam( "Data Gain",     &mDataGain,         "min=0.0 max=100.0 step=0.1" );
    mParams->addParam( "Data Offset",   &mDataOffset,       "min=-1.0 max=1.0 step=0.01" );
    mParams->addParam( "Data Damping",  &mDataDamping,      "min=0.0 max=0.99 step=0.01" );
    mParams->addParam( "Use log",       &mDataIsLog );
    mParams->addParam( "Spread",        &mDataSpread,       "min=0.0 max=1.0 step=0.01" );
    mParams->addParam( "Spread Offset", &mDataSpreadOffset, "min=0.0 max=1.0 step=0.01" );
    mParams->addParam( "Feature",       mAvailableFeatures, &mActiveFeature );
}
Пример #6
0
void PointCloudApp::setup()
{
    mCamUi = CameraUi(&mCam);

	gl::enable( GL_TEXTURE_2D );
	
	mFrameRate		= 0.0f;
	mFullScreen		= false;
	mTimeStamp		= 0L;
	mTimeStampPrev	= mTimeStamp;
	
	loadGlsl();

	mDevice = Kinect2::Device::create();
	mDevice->start();
	mDevice->connectColorEventHandler( [ & ]( const Kinect2::ColorFrame& frame )
	{
		mSurfaceColor	= frame.getSurface();
	} );
	mDevice->connectDepthEventHandler( [ & ]( const Kinect2::DepthFrame& frame )
	{
		mChannelDepth	= frame.getChannel();
		mTimeStamp		= frame.getTimeStamp();
	} );

	//////////////////////////////////////////////////////////////////////////////////////////////

	ivec2 sz = Kinect2::DepthFrame().getSize();
	vector<vec2> vertices;
	for ( int32_t x = 0; x < sz.x; ++x ) {
		for ( int32_t y = 0; y < sz.y; ++y ) {
			vertices.push_back( vec2( x, y ) / vec2( sz ) );
		}
	}

	gl::VboRef vbo = gl::Vbo::create( GL_ARRAY_BUFFER, vertices.size() * sizeof( vec2 ), &vertices[ 0 ], GL_STATIC_DRAW );

	geom::BufferLayout layout;
	layout.append( geom::Attrib::POSITION, 2, sizeof( vec2 ), 0 );
	vector<pair<geom::BufferLayout, gl::VboRef>> vertexArrayBuffers = { make_pair( layout, vbo ) };

	mVboMesh = gl::VboMesh::create( vertices.size(), GL_POINTS, vertexArrayBuffers );

	//////////////////////////////////////////////////////////////////////////////////////////////
	
	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 120 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,				"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addButton( "Load GLSL",	[ & ]() { loadGlsl(); },	"key=g" );
	mParams->addButton( "Quit",			[ & ]() { quit(); },		"key=q" );

	resize();
}
void PinballWarpingApp::setupParams()
{
    mParams = params::InterfaceGl::create("params", ivec2(300,300));
    mParams->addParam("FPS", &mFps);
    mParams->addSeparator();
    mParams->addParam("Draw Image", &mDrawImage);
    mParams->addParam("Debugging", &mPinball.mDebug);
    mParams->addParam("Editing Locations", &mPinball.mIsInEditingMode).updateFn([this] {
        if (!mPinball.mDebug)
            mPinball.saveJson();
    });
  
}
Пример #8
0
void MotionBlurVelocityBufferApp::setup()
{
    mBackground = gl::Texture::create( loadImage( loadAsset( "background.jpg" ) ) );
    mGpuTimer = gl::QueryTimeSwapped::create();
    gl::enableVerticalSync();

    createGeometry();
    createBuffers();
    loadShaders();

#if ! defined( CINDER_ANDROID )
    mParams = params::InterfaceGl::create( "Motion Blur Options", ivec2( 250, 300 ) );
    mParams->addParam( "Average GPU Draw (ms)", &mAverageGpuTime );
    mParams->addParam( "Average CPU Draw (ms)", &mAverageCpuTime );
    mParams->addSeparator();
    mParams->addParam( "Enable Blur", &mBlurEnabled );
    mParams->addParam( "Show Velocity Buffers", &mDisplayVelocityBuffers );
    mParams->addParam( "Pause Animation", &mPaused );
    mParams->addParam( "Animation Speed", &mAnimationSpeed ).min( 0.05f ).step( 0.2f );
    mParams->addParam( "Max Samples", &mSampleCount ).min( 1 ).step( 2 );
    mParams->addParam( "Blur Noise", &mBlurNoise ).min( 0.0f ).step( 0.01f );
#endif

#if defined( CINDER_COCOA_TOUCH )
    getSignalSupportedOrientations().connect( [] { return InterfaceOrientation::LandscapeAll; } );
#endif
}
Пример #9
0
void ciApp::draw()
{
	gl::clear();

	gl::ScopedColor white(Color::white());

	auto get_center_rect = [&](Area area) ->Rectf { return Rectf(area).getCenteredFit(getWindowBounds(), true); };

	{	
		//auto tex = filter->getTexture();
		auto tex = vector_blur.getTexture();
		gl::draw(tex, get_center_rect(tex->getBounds()));
	}
	
	{
		gl::ScopedMatrices scpMatrix;
		gl::scale(0.2f, 0.2f);
		gl::draw(mTexture);
	}

	vector_blur.drawDebug(vec2(0, 0), 0.2f);

	mParams->draw();

	{
		TextLayout infoFps;
		infoFps.clear(ColorA(0.2f, 0.2f, 0.2f, 0.5f));
		infoFps.setColor(Color::white());
		infoFps.setFont(Font("Arial", 16));
		infoFps.setBorder(4, 2);
		infoFps.addLine("App Framerate: " + tostr(getAverageFps(), 1));
		auto tex = gl::Texture::create(infoFps.render(true));
		gl::draw(tex, ivec2(20, getWindowHeight() - tex->getHeight() - 20));
	}
}
Пример #10
0
void TextParticlesApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::color( 1, 1, 1 );
	gl::enableAlphaBlending();
	
	{
		gl::ScopedMatrices scpMtrx;
		
		// SET matrices so that by default, we are looking at a rect the size of the window
		lookAtTexture( mCam, getWindowSize() );
		
		gl::translate( mTextSize * vec2( -0.5 ) );
		
		gl::ScopedDepth scpDepth(	true );
//		gl::ScopedColor scpColor( 1, 0, 0 );
//		gl::drawStrokedRect( Rectf( 0, 0, mTextSize.x, mTextSize.y ) );
		
		gl::color( Color::white() );
		if( mActive ){
			gl::ScopedGlslProg render( mRenderProg );
			gl::ScopedVao vao( mAttributes[mSourceIndex] );
			gl::context()->setDefaultShaderVars();
			gl::drawArrays( GL_POINTS, 0, mTextParticleCount );
			
		}else{
			if( mString.length() > 0 )
				gl::draw( mTextFbo->getColorTexture() );
		}
		
	}
	
	mParams->draw();
}
Пример #11
0
void OpenCVTemplateApp::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    if(imageTexture) {

        unsigned int windowWidth = this->getWindow()->getWidth();
        unsigned int windowHeight = this->getWindow()->getHeight();
        gl::pushMatrices();
        gl::translate((windowWidth-image.cols)/2, (windowHeight-image.rows)/2);
        gl::draw(imageTexture);
        gl::popMatrices();
    }
    if(frameTexture) {
        gl::pushMatrices();
        unsigned int windowWidth = this->getWindow()->getWidth();
        unsigned int windowHeight = this->getWindow()->getHeight();
        gl::translate((windowWidth-frameWidth)/2, (windowHeight-frameHeight)/2);
        gl::draw(frameTexture);

        if(featurePoints.size() > 0) {
            gl::color(1,0,0);
            for(auto& p : featurePoints) {
                gl::drawSolidCircle(fromOcv(p), 1);
            }
            gl::color(1,1,1);
        }
        gl::popMatrices();
    }
    interface->draw();
}
Пример #12
0
void cApp::draw(){
    
    bOrtho ? mExp.beginOrtho( true ) : mExp.begin( camUi.getCamera() ); {
        
        gl::clear();    
        gl::enableDepthRead();
        gl::enableDepthWrite();
        gl::enableAlphaBlending();
        glPointSize(1);
        glLineWidth(1);
    
        if( !mExp.bRender && !mExp.bSnap ){ mt::drawCoordinate(10); }
        for( int i=0; i<rms.size(); i++){
            rms[rms.size()-i-1].draw();
        }
        
        norms.draw();
        
    }mExp.end();
    
    mExp.draw();
    
    if(gui) gui->draw();

    if( bStart && !bFall )frame++;
}
Пример #13
0
void FlockingApp::draw()
{	
	gl::clear( Color( 0, 0, 0 ), true );
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	// DRAW PARTICLES
	mParticleController.draw();
	
	// DRAW ZONE DIAGRAM
	gl::disableDepthRead();
	gl::disableDepthWrite();
	gl::setMatricesWindow( getWindowSize() );
	gl::pushModelView();
		gl::translate( Vec3f( 117.0f, getWindowHeight() - 117.0f, 0.0f ) );
		
		gl::color( ColorA( 0.25f, 0.25f, 1.0f, 1.0f ) );
		gl::drawSolidCircle( Vec2f::zero(), mZoneRadius );
		
		gl::color( ColorA( 1.0f, 1.0f, 1.0f, 0.25f ) );
		gl::drawStrokedCircle( Vec2f::zero(), 100.0f );
	gl::popModelView();
	
	// DRAW PARAMS WINDOW
	mParams->draw();
}
Пример #14
0
void ForestApp::draw()
{
    gl::clear( Color::gray(0.9f) );

    float wallWidth = getWindowWidth() * 0.75;
    float wallHeight = wallWidth / mStrandBox.mBorderRect.getAspectRatio();
    Vec2f wallSize(wallWidth, wallHeight);
    Vec2f wallTopLeft = getWindowCenter() - wallSize/2;

    // Wall coordinate system, Y=0 at bottom with +Y in growth direction
    gl::pushModelView();
    gl::translate(wallTopLeft.x, wallTopLeft.y + wallHeight);
    gl::scale(wallWidth, -wallWidth);

    // Drawing should be safe without acquiring the mutex (performance)
    mStrandBox.draw();
    mDots.draw();
    mPanels.draw();

    gl::popModelView();
    
    if (mShowMatrix) {
        mDots.drawAffinityMatrix();
    }
    mParams->draw();
}
void WaterSimulationApp::draw(){

	gl::clear( Color( 0.11f, 0.13f, 0.1f ) );
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	mParams->draw();

	gl::setMatrices(mMayaCam.getCamera());
	if(mDrawBox){
		glColor4f(0.2, 0.4, 0.5, 1);//orange
		gl::drawStrokedCube(boxCenter,boxDimension);
	}
	if(mDrawGravity){
		glColor4f(1.0f,0.3f,0.0f,0.5f);//red
		if(mDrawGravity)glColor4f(0.0f,1.0f,0.5f,1);//green
		gl::drawVector(boxCenter,(boxCenter-gravity),3.0f,1.0f);
	}

	//draw random force
	if(mDrawForce){
		if(randomForce.lengthSquared()!=0){
			glColor4f(1.0f,0.0f,0.0f,1);
			gl::drawVector(randomForceX,randomForce+randomForceX,1.0f,0.5f);
		}
	}

	fluidsys->draw();

}
void TextboxApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0.15f, 0.15f, 0.15f ) );
    gl::setMatricesWindow(app::getWindowSize());
  
    glAlphaFunc(GL_GREATER, 0.0);
    glEnable(GL_ALPHA_TEST);
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    
    glPushMatrix();
    glTranslatef(PADDING + mTextBox->getTopLeft().x,PADDING + mTextBox->getTopLeft().y,0);
    glColor3f(1,1,1);
    gl::draw(mTextBox->getTexture());
    
    if(TEXT_BOX_DEBUG_DRAW){
        mTextBox->debugDraw();
    }
    glPopMatrix();
    
    glDisable(GL_BLEND);
    glDisable(GL_ALPHA_TEST);
    glAlphaFunc(GL_GREATER, 0.5); // reset what seems to be cinders default
    
    mParams->draw();
}
Пример #17
0
void cApp::draw(){
    
    gl::enableAlphaBlending();
    glPointSize(1);
    glLineWidth(1);
    
    //bOrtho ? mExp.beginOrtho( true ) : mExp.begin( camUi.getCamera() ); {
    {
        mExp.bind();
        gl::clear();
        gl::enableDepthRead();
        gl::enableDepthWrite();

        for( int i=0; i<6; i++){
            gl::pushMatrices();
            gl::setMatrices( cams[i] );
            
            if( !mExp.bRender && !mExp.bSnap ){
                mt::drawCoordinate(160);
            }
            
            rms[i].draw();
            
            gl::popMatrices();
        }
    }mExp.end();

    mExp.draw();

    if(gui) gui->draw();

    if( bStart)frame++;
}
Пример #18
0
void TessellationShaderApp::setup()
{
	mTessLevelInner = mTessLevelOuter = 4;
	int maxPatchVertices = 0;
	glGetIntegerv( GL_MAX_PATCH_VERTICES, &maxPatchVertices );
	app::console() << "Max supported patch vertices " << maxPatchVertices << std::endl;



#if ! defined( CINDER_GL_ES )
	fs::path glDir = "ogl";
	mRadius = 200.0f;

	mParams = params::InterfaceGl::create( "Settings", ivec2( 200, 200 ) );
	mParams->addParam( "Radius", &mRadius, "step=1.0" );
	mParams->addParam( "Tess level inner", &mTessLevelInner, "min=0" );
	mParams->addParam( "Tess level outer", &mTessLevelOuter, "min=0" );
#else
	fs::path glDir = "es31a";
	mRadius = 400.0f;
#endif
	
	try {
		mGlsl = gl::GlslProg::create( gl::GlslProg::Format()
									 .vertex( loadAsset( glDir / "0_vert.glsl" ) )
									 .tessellationCtrl( loadAsset( glDir / "1_tess_ctrl.glsl" ) )
									 .tessellationEval( loadAsset( glDir / "2_tess_eval.glsl" ) )
#if defined( CINDER_GL_ES )
									 .geometry( loadAsset( glDir / "x_geom.glsl" ) )
#endif
									 .fragment( loadAsset( glDir / "3_frag.glsl" ) ) );
	}
	catch( const std::exception &ex ) {
		console() << ex.what() << endl;
		//quit();
	}

	mBatch = gl::VertBatch::create( GL_PATCHES );
	mBatch->color( 1.0f, 0.0f, 0.0f );
	mBatch->vertex( vec2( 1, -1 ) );
	mBatch->color( 0.0f, 1.0f, 0.0f );
	mBatch->vertex( vec2( 0 , 1 ) );
	mBatch->color( 0.0f, 0.0f, 1.0f );
	mBatch->vertex( vec2( -1, -1 ) );
	
	gl::patchParameteri( GL_PATCH_VERTICES, 3 );
}
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();
}
Пример #20
0
void FlockingApp::setup()
{	
	mCentralGravity = true;
	mFlatten		= false;
	mZoneRadius		= 30.0f;
	
	// SETUP CAMERA
	mCameraDistance = 500.0f;
	mEye			= Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCenter			= Vec3f::zero();
	mUp				= Vec3f::yAxis();
	mCam.setPerspective( 75.0f, getWindowAspectRatio(), 5.0f, 2000.0f );

	// SETUP PARAMS
	mParams = params::InterfaceGl::create( "Flocking", Vec2i( 200, 220 ) );
	mParams->addParam( "Scene Rotation", &mSceneRotation, "opened=1" );
	mParams->addSeparator();
	mParams->addParam( "Eye Distance", &mCameraDistance, "min=50.0 max=1500.0 step=50.0 keyIncr=s keyDecr=w" );
	mParams->addParam( "Center Gravity", &mCentralGravity, "keyIncr=g" );
	mParams->addParam( "Flatten", &mFlatten, "keyIncr=f" );
	mParams->addSeparator();
	mParams->addParam( "Zone Radius", &mZoneRadius, "min=10.0 max=100.0 step=1.0 keyIncr=z keyDecr=Z" );
	
	// CREATE PARTICLE CONTROLLER
	mParticleController.addParticles( NUM_INITIAL_PARTICLES );
}
void ImageRetargetingApp::drawLinearScaleWindow()
{
    gl::clear( Color( 0.f, 0.f, 0.f ) );
    
    if( originalTexture ) {
        gl::draw(originalTexture, *linearScaleRec);
    }
    linearScalingParams->draw();
}
Пример #22
0
void ThresholdTestApp::draw()
{
	gl::clear( Color( 0.1f, 0.1f, 0.15f ) );

	if( mTexture )
		gl::draw( mTexture );
	
	mParams->draw();
}
Пример #23
0
void SlingshotSmokeApp::setup()
{
	mVolumeMult = 5.0;

	mLastTime = 0;

	getWindowIndex(0)->getSignalDraw().connect([=]() { drawRender(); });

	mAudioSource = AudioSource();
	mAudioSource.setup();

	vec2 fluidResolution = vec2(512);
	vec2 smokeResolution = app::getWindowSize();

	mFluid = Fluid(fluidResolution);
	mSmokers.reserve(2);
	mSmokers.push_back(shared_ptr<FakeSmoker>(new FakeSmoker(fluidResolution, smokeResolution)));
	mSmokers.push_back(shared_ptr<PositionSmoker>(new PositionSmoker(fluidResolution, smokeResolution)));
	mSmokers.push_back(shared_ptr<TransitionSmoker>(new TransitionSmoker(fluidResolution, smokeResolution)));
	mSmokers.push_back(shared_ptr<BottomSmoker>(new BottomSmoker(fluidResolution, smokeResolution)));
	mCurrentSmoker = 0;

	mSmokers[mCurrentSmoker]->light(vec2(0.5, 0.2), mParams);


	gl::GlslProg::Format renderFormat;
	renderFormat.vertex(app::loadAsset("passthru.vert"));
	renderFormat.fragment(app::loadAsset("Smokers/smoke_draw.frag"));
	mRenderProg = gl::GlslProg::create(renderFormat);
	mRenderProg->uniform("i_resolution", smokeResolution);

	gl::Texture2d::Format texFmt;
	texFmt.setInternalFormat(GL_RGBA32F);
	texFmt.setDataType(GL_FLOAT);
	texFmt.setTarget(GL_TEXTURE_2D);
	texFmt.setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
	gl::Fbo::Format fmt;
	fmt.disableDepth()
		.setColorTextureFormat(texFmt);
	mSmokeField = PingPongFBO(fmt, smokeResolution, 4);


	// Do params last so that all the FBOs are in the right context
	vec2 paramsSize = vec2(255, 512);
	auto format = Window::Format();
	format.setSize(paramsSize + vec2(40, 20));
	format.setPos(ivec2(100));
	WindowRef paramsWindow = createWindow(format);
	paramsWindow->getSignalDraw().connect([=]() { drawParams(); });
	mParams = params::InterfaceGl::create(paramsWindow, "Options", paramsSize);

	mParams->addParam("Volume", &mVolumeMult)
		.max(10.0)
		.min(0.0)
		.step(0.1);
}
Пример #24
0
void AudioObjApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
    gl::enableAlphaBlending();
    gl::enableDepthRead();
    gl::enableDepthWrite();
    
    gl::pushMatrices();

	gl::setMatrices( mMayaCam.getCamera() );
	
	if ( mFeature && mFeatureTex )
	{
		mShader->bind();
		mFeatureTex.enableAndBind();
		mShader->uniform( "dataTex",		0 );
		mShader->uniform( "texWidth",		(float)mFeatureTex.getWidth() );
		mShader->uniform( "texHeight",		(float)mFeatureTex.getHeight() );
		mShader->uniform( "soundDataSize",  (float)mFeature->getSize() );
		mShader->uniform( "spread",         mFeatureSpread );
		mShader->uniform( "spreadOffset",   mFeatureSpreadOffset );
        mShader->uniform( "time",           (float)getElapsedSeconds() );
		mShader->uniform( "tintColor",      mObjColor );
	}
    
    if ( mRenderWireframe )
        gl::enableWireframe();
    
	gl::color( Color(1.0f, 0.0f, 0.0f ) );
    
	if ( mVbo )
	    gl::draw( mVbo );

    if ( mRenderWireframe )
        gl::disableWireframe();
    
	mShader->unbind();
	mFeatureTex.unbind();

	gl::color( Color::white() );
//	gl::drawCoordinateFrame();
  
	gl::popMatrices();
    
    gl::disableDepthRead();
    gl::disableDepthWrite();
    
	gl::setMatricesWindow( getWindowSize() );

	ciXtractReceiver::drawData( mFeature, Rectf( 15, getWindowHeight() - 150, 255, getWindowHeight() - 35 ) );
	
	gl::draw( mFeatureSurf );

    mParams->draw();
}
Пример #25
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
}
Пример #26
0
void ciApp::setup()
{
	setWindowSize(1280, 720);
	setFrameRate(60.f);
	
	int maxVertUniformsVect;
	glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &maxVertUniformsVect);

	mSize = 0;
	mSizePrev = -1;
	mSizeMax = 17;
	mAmplifier = 1.f;

	mExposure = 1.f;
	mGamma = 2.2f;

	printf("max uniform: %i, %i\n", maxVertUniformsVect, mSizeMax);

	mParams = params::InterfaceGl::create(getWindow(), "App parameters", ivec2(250, 300));
	mParams->setPosition(ivec2(20, 250));

	mTexture = gl::Texture::create(loadImage(loadFile(data_path + "demo.png")));
	mFbo = gl::Fbo::create(mTexture->getWidth(), mTexture->getHeight(), gl::Fbo::Format().colorTexture());
	//mShader.setup("filterGaussianBlur");

	filter = hb::GlslFilter::create(mTexture->getSize());
	filter->setParams(mParams);

	vector_blur.setup(getWindowSize());
	vector_blur.setParams(mParams);

	spout_receiver = hb::Receiver::create("Spout DX11 Sender");
	//spout_receiver = hbSpoutReceiver::create("KidsLandSea");
	spout_sender = hb::Sender::create("cinder_spout", mFbo->getWidth(), mFbo->getHeight());

#if 0
	auto ctx = audio::Context::master();

	// The InputDeviceNode is platform-specific, so you create it using a special method on the Context:
	mInputDeviceNode = ctx->createInputDeviceNode();

	// By providing an FFT size double that of the window size, we 'zero-pad' the analysis data, which gives
	// an increase in resolution of the resulting spectrum data.
	auto monitorFormat = audio::MonitorSpectralNode::Format().fftSize(2048).windowSize(1024);
	mMonitorSpectralNode = ctx->makeNode(new audio::MonitorSpectralNode(monitorFormat));

	mInputDeviceNode >> mMonitorSpectralNode;

	// InputDeviceNode (and all InputNode subclasses) need to be enabled()'s to process audio. So does the Context:
	mInputDeviceNode->enable();
	ctx->enable();
#endif
}
Пример #27
0
void RDiffusionApp::draw()
{
	gl::clear();
	gl::setMatricesWindow( getWindowSize() );
	gl::viewport( getWindowSize() );
	{
		gl::ScopedTextureBind bind( mFBOs[mCurrentFBO]->getColorTexture() );
		gl::drawSolidRect( getWindowBounds() );
	}
	
	mParams->draw();
}
Пример #28
0
void hidTestApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	
	gl::setMatricesWindow( getWindowSize() );
	
	mInteractionZonesDebug->draw();
	
	drawKey();
	
	mParams->draw();
}
Пример #29
0
void MASOSApp::update()
{
    if (mAngle != oldAngle)
    {
        scale = mProjectileUnderTest.calculateScale(mInitialVelocity, mAngle, mTerminalVelocity, getWindowCenter().x, getWindowCenter().y);
    }
    oldAngle = mAngle;

    if (scale != oldScale)
    {
        scale = mProjectileUnderTest.calculateScale(mInitialVelocity, mAngle, mTerminalVelocity, getWindowCenter().x, getWindowCenter().y);
    }
    oldScale = scale;

    if (mTerminalVelocity != oldTerminalVelocity)
    {
        scale = mProjectileUnderTest.calculateScale(mInitialVelocity, mAngle, mTerminalVelocity, getWindowCenter().x, getWindowCenter().y);
    }
    oldTerminalVelocity = mTerminalVelocity;

    if (mInitialVelocity != oldInitialVelocity)
    {
        scale = mProjectileUnderTest.calculateScale(mInitialVelocity, mAngle, mTerminalVelocity, getWindowCenter().x, getWindowCenter().y);
    }
    oldInitialVelocity =mInitialVelocity;
    

    float tmp = mProjectileUnderTest.mPosition.y;
    mProjectileUnderTest.update(mInitialVelocity, mAngle, mCurrentTime, mTerminalVelocity);
    if (mProjectileUnderTest.mPosition.y > 0)
    {
        mProjectileUnderTest.mPosition.y = 0;
        mIsPlaying = false;
    }
    if (tmp >= 0 && mProjectileUnderTest.mPosition.y >= 0)
    {
        mProjectileUnderTest.mPosition.y = 0;
        mIsPlaying = false;
        mCurrentTime = oldTime;
    }

    if (mProjectileUnderTest.mPosition.x < 0)
    {
        mProjectileUnderTest.mPosition.x = 0.f;
    }

    oldTime = mCurrentTime;
    currX = mProjectileUnderTest.mPosition.x;
    currY = -(mProjectileUnderTest.mPosition.y);
    if (currY == -0) currY = 0;
    mParams->setPosition(ivec2(0,0));
}
Пример #30
0
void NormalGetterApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
    
    if(mFbo && mOutputFbo){
        normalize(mFbo->getColorTexture());
        gl::draw(mOutputFbo->getColorTexture());
    }
    
  //  if(mFbo) gl::draw(mFbo->getColorTexture());
    mStatus->draw();
    mParams->draw();
}