Exemple #1
0
void ChargesApp::setup()
{
	//gl::disableVerticalSync();

	gl::Fbo::Format format;
	format.enableDepthBuffer( false );
	format.setSamples( 4 );

	mFbo = gl::Fbo( 1280, 800, format );
	mKawaseBloom = mndl::gl::fx::KawaseBloom( mFbo.getWidth(), mFbo.getHeight() );

	mEffectCharge.setup();
	mEffectCharge.instantiate();
	mEffectCharge.setBounds( mFbo.getBounds() );

	// Leap
	mLeap = LeapSdk::Device::create();
	mLeapCallbackId = mLeap->addCallback( &ChargesApp::onFrame, this );

	// params
	mndl::kit::params::PInterfaceGl::load( "params.xml" );
	mParams = mndl::kit::params::PInterfaceGl( "Parameters", Vec2i( 200, 300 ) );
	mParams.addPersistentSizeAndPosition();
	mParams.addParam( "Fps", &mFps, "", true );
	mParams.addSeparator();
	mParams.addPersistentParam( "Line width", &mLineWidth, 4.5f, "min=.5 max=10 step=.1" );
	mParams.addPersistentParam( "Bloom strength", &mBloomStrength, .8f, "min=0 max=1 step=.05" );
	mParams.addPersistentParam( "Finger disapperance thr", &mFingerDisapperanceThreshold, .1f, "min=0 max=2 step=.05" );

	mndl::kit::params::PInterfaceGl::showAllParams( false );
}
Exemple #2
0
// Set up
void LeapApp::setup()
{
	// Set up OpenGL
	gl::enable( GL_LINE_SMOOTH );
	glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); 
	gl::enable( GL_POLYGON_SMOOTH );
	glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );

	// Set up camera
	mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.01f, 1000.0f );
	mCamera.lookAt( Vec3f( 0.0f, 125.0f, 500.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) );
	
	// Start device
	mLeap = Device::create();
	mLeap->addCallback( &LeapApp::onFrame, this );

	// Params
	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mParams = params::InterfaceGl( "Params", Vec2i( 200, 105 ) );
	mParams.addParam( "Frame rate",		&mFrameRate,						"", true );
	mParams.addParam( "Full screen",	&mFullScreen,						"key=f"		);
	mParams.addButton( "Screen shot",	bind( &LeapApp::screenShot, this ), "key=space" );
	mParams.addButton( "Quit",			bind( &LeapApp::quit, this ),		"key=q" );
}
void LeapPalmDirectionApp::setup()
{
	mLeap = LeapSdk::Device::create();
	mCallbackId = mLeap->addCallback( &LeapPalmDirectionApp::onFrame, this );

	mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.01f, 1000.0f );
	mCamera.lookAt( Vec3f( 0.0f, 250.0f, 500.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) );
}
void _TBOX_PREFIX_App::setup()
{	 
	// Set up OpenGL
	gl::enableAlphaBlending();
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	// Set up camera
	mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.01f, 1000.0f );
	mCamera.lookAt( Vec3f( 0.0f, 125.0f, 500.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) );
	
	// Start device
	mLeap 		= LeapSdk::Device::create();
	mCallbackId = mLeap->addCallback( &_TBOX_PREFIX_App::onFrame, this );
}
Exemple #5
0
void BrainbowApp::setup()
{
    // LOAD AUDIO
    mAudio = AudioCont();
    mAudio.setUp();
    
    // START SCENE 1
    sceneOne = true;
    sceneTwo = false;
    
    // Set up OpenGL
    
	gl::enableAlphaBlending();
	gl::enableDepthRead();
	gl::enableDepthWrite();
    
    gongTimer.start();
    ballTimer.start();
    
    // LIGHTING
    //here
    glPolygonOffset( 1.0f, 1.0f );
	glEnable( GL_LIGHTING );
	glEnable( GL_DEPTH_TEST );
    
    
    mLight = new gl::Light( gl::Light::POINT, 0 );
	mLight->lookAt( Vec3f( 1, 5, 1 ), Vec3f (getWindowWidth(), getWindowHeight() * 0.5f, 0.0f ));
    mLight->setAmbient( Color( 0.3f, 0.3f, 0.3f ) );
	mLight->setDiffuse( Color( 1.0f, 1.0f, 1.0f ) );
	mLight->setSpecular( Color( 1.0f, 1.0f, 1.0f ) );
	mLight->setShadowParams( 60.0f, 0.5f, 8.0f );
    //	mLight->update( *mCamera );
	mLight->enable();
    
    
    //LOAD SHAPES
    colorSat = 1.0f;
    
	sphereMaterial.setSpecular( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
	sphereMaterial.setDiffuse( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
	sphereMaterial.setAmbient( ColorA(colorSat-0.3f, colorSat, colorSat, .05f ) );
	sphereMaterial.setShininess( 1.0f );
    
    sphereMaterial.setEmission(ColorA(1, 1, 1, 1 ));
    gl::Material cylMaterial;
    cylMaterial.setSpecular( ColorA(0, 1.0f, 1.0f, .2f ));
	cylMaterial.setDiffuse( ColorA(0, 1.0f, 1.0f, .2f ) );
	cylMaterial.setAmbient( ColorA(0, 1.0f, 1.0f, .2f ) );
	cylMaterial.setShininess( 600.0f );
    cylMaterial.setEmission(ColorA(1, 1, 1, 1 ));
    
    gl::Material curMaterial;
    curMaterial.setSpecular( ColorA(1, .5, 0, .5f ));
	curMaterial.setDiffuse( ColorA(1, .5, 0, .5f ) );
	curMaterial.setAmbient( ColorA(1, 1.0f, 1.0f, .05f ) );
	curMaterial.setShininess( 600.0f );
    curMaterial.setEmission(ColorA(1, 1, 1, 1 ));
    
    
	discMaterial.setSpecular( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
	discMaterial.setDiffuse( ColorA(colorSat-0.3f, colorSat, colorSat, .4f ) );
	discMaterial.setAmbient( ColorA(colorSat-0.3f, colorSat, colorSat, .05f ) );
	discMaterial.setShininess( 600.0f );
    discMaterial.setEmission(ColorA(1, 1, 1, 1 ));
    
    initShadowMap();
    
    mCloud = SphereCloud(0, 70);
    
    mDiamond = gl::DisplayList( GL_COMPILE );
    mDiamond.newList();
    gl::drawSphere(Vec3f(0, 0, 0), 300, 4);
    mDiamond.endList();
    mDiamond.setMaterial( sphereMaterial );
    
    mCyl = gl::DisplayList( GL_COMPILE );
    mCyl.newList();
    //    gl::drawCylinder(200, 200, 200);
    gl::drawColorCube(Vec3f(0, 0, 0), Vec3f(300, 300, 300));
    mCyl.endList();
    mCyl.setMaterial(cylMaterial);
    
    mCur = gl::DisplayList( GL_COMPILE );
    mCur.newList();
    gl::drawSphere(Vec3f(0, 0, 0), 5);
    mCur.endList();
    mCur.setMaterial(curMaterial);
    
    mDisc = gl::DisplayList( GL_COMPILE );
    mDisc.newList();
    gl::drawSolidCircle(Vec2f(0, 0), 60, 6);
    mDisc.endList();
    mDisc.setMaterial( discMaterial );
	
	// START LEAP
	mLeap 		= LeapSdk::Device::create();
	mCallbackId = mLeap->addCallback( &BrainbowApp::onFrame, this );
    
    
    mShader = gl::GlslProg( loadResource( RES_SHADOWMAP_VERT ), loadResource( RES_SHADOWMAP_FRAG ) );
	mShader.bind();
	mShader.uniform( "depthTexture", 0 );
}
Exemple #6
0
// Set up
void UiApp::setup()
{
	glShadeModel( GL_FLAT );
	
	// Set up camera
	mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 45.0f, 0.01f, 1000.0f );
	mOffset = Vec3f( 240.0f, -480.0f, 0.0f );
	
	// Start device
	mLeap = Device::create();
	mLeap->addCallback( &UiApp::onFrame, this );
	
	// Load cursor textures
	for ( size_t i = 0; i < 3; ++i ) {
		switch ( (CursorType)i ) {
			case CursorType::GRAB:
				mTexture[ i ] = gl::Texture( loadImage( loadResource( RES_TEX_GRAB ) ) );
				break;
			case CursorType::HAND:
				mTexture[ i ] = gl::Texture( loadImage( loadResource( RES_TEX_HAND ) ) );
				break;
			case CursorType::TOUCH:
				mTexture[ i ] = gl::Texture( loadImage( loadResource( RES_TEX_TOUCH ) ) );
				break;
			case NONE:
				break;
		}
		mTexture[ i ].setFlipped( true );
		mTexture[ i ].setMagFilter( GL_NEAREST );
		mTexture[ i ].setMinFilter( GL_NEAREST );
	}
	
	// Initialize cursor
	mCursorType				= CursorType::NONE;
	mCursorPosition			= Vec3f::zero();
	mCursorPositionTarget	= Vec3f::zero();
	
	// Load UI textures
	mButton[ 0 ]	= gl::Texture( loadImage( loadResource( RES_TEX_BUTTON_OFF ) ) );
	mButton[ 1 ]	= gl::Texture( loadImage( loadResource( RES_TEX_BUTTON_ON ) ) );
	mSlider			= gl::Texture( loadImage( loadResource( RES_TEX_SLIDER ) ) );
	mTrack			= gl::Texture( loadImage( loadResource( RES_TEX_TRACK ) ) );

	// Flip textures
	mButton[ 0 ].setFlipped( true );
	mButton[ 1 ].setFlipped( true );
	mSlider.setFlipped( true );
	mTrack.setFlipped( true );
	
	// Disable anti-aliasing
	mButton[ 0 ].setMagFilter( GL_NEAREST );
	mButton[ 0 ].setMinFilter( GL_NEAREST );
	mButton[ 1 ].setMagFilter( GL_NEAREST );
	mButton[ 1 ].setMinFilter( GL_NEAREST );
	mSlider.setMagFilter( GL_NEAREST );
	mSlider.setMinFilter( GL_NEAREST );
	mTrack.setMagFilter( GL_NEAREST );
	mTrack.setMinFilter( GL_NEAREST );
	
	// Initialize buttons
	Vec3f position( -120.0f, 950.0f, 0.0f );
	for ( size_t i = 0; i < 3; ++i, position.x += 320.0f ) {
		mButtonPosition[ i ]	= position;
		mButtonState[ i ]		= false;
	}
	
	// Initialize sliider
	mTrackPosition		= Vec3f( 0.0f, 700.0f, 0.0f );
	mSliderPosition		= mTrackPosition;
	mSliderPosition.y	-= 45.0f;
	
	// Params
	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mParams = params::InterfaceGl( "Params", Vec2i( 200, 105 ) );
	mParams.addParam( "Frame rate",		&mFrameRate,						"", true );
	mParams.addParam( "Full screen",	&mFullScreen,						"key=f"		);
	mParams.addButton( "Screen shot",	bind( &UiApp::screenShot, this ),	"key=space" );
	mParams.addButton( "Quit",			bind( &UiApp::quit, this ),			"key=q" );
}
// Set up
void GestureApp::setup()
{
	// Set up OpenGL
	gl::enable( GL_POLYGON_SMOOTH );
	glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
	
	// UI
	mBackgroundBrightness	= 0.0f;
	mBackgroundColor		= Colorf( 0.0f, 0.1f, 0.2f );
	mCircleResolution		= 32;
	mDialBrightness			= 0.0f;
	mDialPosition			= Vec2f( 155.0f, 230.0f );
	mDialRadius				= 120.0f;
	mDialSpeed				= 0.21f;
	mDialValue				= 0.0f;
	mDialValueDest			= mDialValue;
	mDotRadius				= 3.0f;
	mDotSpacing				= mDotRadius * 3.0f;
	mFadeSpeed				= 0.95f;
	mKeySpacing				= 25.0f;
	mKeyRect				= Rectf( mKeySpacing, 360.0f + mKeySpacing, 600.0f, 600.0f );
	mKeySize				= 60.0f;
	mPointableRadius		= 15.0f;
	mSwipeBrightness		= 0.0f;
	mSwipePos				= 0.0f;
	mSwipePosDest			= mSwipePos;
	mSwipePosSpeed			= 0.33f;
	mSwipeRect				= Rectf( 310.0f, 100.0f, 595.0f, 360.0f );
	mSwipeStep				= 0.033f;
	
	// Sets master offset
	resize();
	
	// Lay out keys
	float spacing = mKeySize + mKeySpacing;
	for ( float y = mKeyRect.y1; y < mKeyRect.y2; y += spacing ) {
		for ( float x = mKeyRect.x1; x < mKeyRect.x2; x += spacing ) {
			Rectf bounds( x, y, x + mKeySize, y + mKeySize );
			Key key( bounds );
			mKeys.push_back( key );
		}
	}
	
	// Start device
	mLeap 		= Device::create();
	mCallbackId = mLeap->addCallback( &GestureApp::onFrame, this );

	// Enable all gesture types
	mLeap->enableGesture( Gesture::Type::TYPE_CIRCLE );
	mLeap->enableGesture( Gesture::Type::TYPE_KEY_TAP );
	mLeap->enableGesture( Gesture::Type::TYPE_SCREEN_TAP );
	mLeap->enableGesture( Gesture::Type::TYPE_SWIPE );
	
	// Params
	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mParams = params::InterfaceGl( "Params", Vec2i( 200, 105 ) );
	mParams.addParam( "Frame rate",		&mFrameRate,						"", true );
	mParams.addParam( "Full screen",	&mFullScreen,						"key=f"		);
	mParams.addButton( "Screen shot",	bind( &GestureApp::screenShot, this ), "key=space" );
	mParams.addButton( "Quit",			bind( &GestureApp::quit, this ),		"key=q" );
}