// Set up void TracerApp::setup() { // Set up camera mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.01f, 1000.0f ); mCamera.lookAt( Vec3f( 0.0f, 93.75f, 250.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) ); // Start device mDevice = Device::create(); mDevice->connectEventHandler( &TracerApp::onFrame, this ); // Load shaders try { mShader[ 0 ] = gl::GlslProg( loadResource( RES_GLSL_PASS_THROUGH_VERT ), loadResource( RES_GLSL_BLUR_X_FRAG ) ); } catch ( gl::GlslProgCompileExc ex ) { console() << "Unable to compile blur X shader: \n" << string( ex.what() ) << "\n"; quit(); } try { mShader[ 1 ] = gl::GlslProg( loadResource( RES_GLSL_PASS_THROUGH_VERT ), loadResource( RES_GLSL_BLUR_Y_FRAG ) ); } catch ( gl::GlslProgCompileExc ex ) { console() << "Unable to compile blur Y shader: \n" << string( ex.what() ) << "\n"; quit(); } // Params mFrameRate = 0.0f; mParams = params::InterfaceGl( "Params", Vec2i( 200, 105 ) ); mParams.addParam( "Frame rate", &mFrameRate, "", true ); mParams.addButton( "Screen shot", bind( &TracerApp::screenShot, this ), "key=space" ); mParams.addButton( "Quit", bind( &TracerApp::quit, this ), "key=q" ); // Enable polygon smoothing gl::enable( GL_POLYGON_SMOOTH ); glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); // Set up FBOs gl::Fbo::Format format; #if defined( CINDER_MSW ) format.setColorInternalFormat( GL_RGBA32F ); #else format.setColorInternalFormat( GL_RGBA32F_ARB ); #endif format.setMinFilter( GL_LINEAR ); format.setMagFilter( GL_LINEAR ); format.setWrap( GL_CLAMP, GL_CLAMP ); for ( size_t i = 0; i < 3; ++i ) { mFbo[ i ] = gl::Fbo( getWindowWidth(), getWindowHeight(), format ); mFbo[ i ].bindFramebuffer(); gl::setViewport( mFbo[ i ].getBounds() ); gl::clear(); mFbo[ i ].unbindFramebuffer(); } glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); }
void CinderProjectApp::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 = LeapMotion::Device::create(); mLeap->connectEventHandler( &CinderProjectApp::onFrame, this ); }
void ImageApp::setup() { gl::enable( GL_TEXTURE_2D ); mDevice = Device::create(); mDevice->connectEventHandler( [ & ]( Leap::Frame frame ) { mFrame = frame; } ); mFrameRate = 0.0f; mFullScreen = false; mParams = params::InterfaceGl::create( "Params", Vec2i( 200, 105 ) ); mParams->addParam( "Frame rate", &mFrameRate, "", true ); mParams->addParam( "Full screen", &mFullScreen ).key( "f" ); mParams->addButton( "Screen shot", [ & ]() { screenShot(); }, "key=space" ); mParams->addButton( "Quit", [ & ]() { quit(); }, "key=q" ); }
void LeapApp::setup() { gl::enable( GL_LINE_SMOOTH ); glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); gl::enable( GL_POLYGON_SMOOTH ); glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 1.0f, 1000.0f ); mCamera.lookAt( Vec3f( 0.0f, 250.0f, 500.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) ); mDevice = Device::create(); mDevice->connectEventHandler( &LeapApp::onFrame, this ); mFrameRate = 0.0f; mFullScreen = false; mParams = params::InterfaceGl::create( "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" ); }
// Set up void UiApp::setup() { glShadeModel( GL_FLAT ); // Start device mDevice = Device::create(); mDevice->connectEventHandler( &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 ].setMagFilter( GL_NEAREST ); mTexture[ i ].setMinFilter( GL_NEAREST ); } // Initialize cursor mCursorType = CursorType::NONE; mCursorPosition = Vec2f::zero(); mCursorPositionTarget = Vec2f::zero(); mFingerTipPosition = Vec2i::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 ) ) ); // 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 ); // 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" ); // Run resize to initialize layout resize(); }