Exemplo n.º 1
0
GestureManager::GestureManager( const ci::app::WindowRef &window )
: mIsPanning( false )
{
	App::get()->getSignalUpdate().connect( bind( &GestureManager::update, this ) );
	window->getSignalTouchesBegan().connect( -5, bind( &GestureManager::touchesBegan, this, placeholders::_1 ) );
	window->getSignalTouchesMoved().connect( -5, bind( &GestureManager::touchesMoved, this, placeholders::_1 ) );
	window->getSignalTouchesEnded().connect( -5, bind( &GestureManager::touchesEnded, this, placeholders::_1 ) );
}
bool OculusRift::attachToWindow( const ci::app::WindowRef& window )
{
	if( ! mHmd )
		return false;
	
	if( ! isValid( window ) )
		return false;
	
	if( isDesktopExtended() ) {
		mImpl = std::unique_ptr<ExtendedModeImpl>( new ExtendedModeImpl{ this } );
	} else {
		mImpl = std::unique_ptr<DirectModeImpl>( new DirectModeImpl{ this } );
	}
	
	if( ! mImpl->initialize( window ) )
		return false;
	
	// Override the window's startDraw() and finishDraw() methods, so we can inject our own code.
	RendererGlRef rendererGl = std::dynamic_pointer_cast<RendererGl>( window->getRenderer() );
	if( rendererGl ) {
		rendererGl->setStartDrawFn( std::bind( &OculusRift::startDrawFn, this, std::placeholders::_1 ) );
		rendererGl->setFinishDrawFn( std::bind( &OculusRift::finishDrawFn, this, std::placeholders::_1 ) );
	}
	else {
		throw std::runtime_error( "OculusRift can only be used in combination with RendererGl." );
	}
	// Connect to the window close event, so we can properly destroy our HMD.
	window->getSignalClose().connect( std::bind( [&]( ovrHmd hmd ) { assert( hmd == mHmd ); detachFromWindow(); }, mHmd ) );
	
	ovrHmd_ConfigureTracking( mHmd, mTrackingCaps, 0 );
	ovrGLConfig cfg;
	cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
	cfg.OGL.Header.BackBufferSize = mHmd->Resolution;
	cfg.OGL.Header.Multisample = 1; // TODO: support multi-sampling
#if defined( CINDER_MSW )
	cfg.OGL.Window = static_cast<HWND>( window->getNative() );
	cfg.OGL.DC = window->getDc();
#endif
	if( ! ovrHmd_ConfigureRendering( mHmd, &cfg.Config, mDistortionCaps, mHmd->MaxEyeFov, mEyeRenderDesc ) ) {
		throw std::runtime_error( "Failed to configure rendering." );
	}
	updateHmdSettings();
	
	mWindow = window;
	return true;
}
Exemplo n.º 3
0
void Quaternions::connect( ci::app::WindowRef window )
{
  auto change_orientations = [this] {
    auto apply_options = timeline( ).apply( &_apply_orientation );
    rotateMore( apply_options );

    auto append_options = timeline( ).append( &_append_orientation );
    rotateMore( append_options );
  };

  storeConnection( window->getSignalTouchesBegan().connect( [=] ( app::TouchEvent &event ) {
    change_orientations();
  } ) );

  storeConnection( window->getSignalMouseDown().connect( [=] ( app::MouseEvent &event ) {
    change_orientations();
  } ) );
}
Exemplo n.º 4
0
void connectWindow( ci::app::WindowRef window )
{
	sWindowConnections = {
		window->getSignalMouseDown().connect( mouseDown ),
		window->getSignalMouseUp().connect( mouseUp ),
		window->getSignalMouseDrag().connect( mouseDrag ),
		window->getSignalMouseMove().connect( mouseMove ),
		window->getSignalMouseWheel().connect( mouseWheel ),
		window->getSignalKeyDown().connect( keyDown ),
		window->getSignalKeyUp().connect( keyUp ),
		window->getSignalResize().connect( resize ),
	};
}
Exemplo n.º 5
0
//
//  MARK: - RootNode
//
void RootNode::connect( ci::app::WindowRef window )
{
  storeConnection( window->getSignalTouchesBegan().connect( [this]( app::TouchEvent &event )
                                                           {
                                                             deepTouchesBegan( event );
                                                           } ) );
  storeConnection( window->getSignalTouchesMoved().connect( [this]( app::TouchEvent &event )
                                                           {
                                                             deepTouchesMoved( event );
                                                           } ) );
  storeConnection( window->getSignalTouchesEnded().connect( [this]( app::TouchEvent &event )
                                                           {
                                                             deepTouchesEnded( event );
                                                           } ) );

  storeConnection( window->getSignalMouseDown().connect( [this]( app::MouseEvent &event )
                                                        {
                                                          deepMouseDown( event );
                                                        } ) );
  storeConnection( window->getSignalMouseDrag().connect( [this]( app::MouseEvent &event )
                                                        {
                                                          deepMouseDrag( event );
                                                        } ) );
  storeConnection( window->getSignalMouseUp().connect( [this]( app::MouseEvent &event )
                                                      {
                                                        deepMouseUp( event );
                                                      } ) );
}
Exemplo n.º 6
0
void PretzelRoot::connectSignals(ci::app::WindowRef window)
{
    if( !mMouseBeganCallback.isConnected() ){
        
        // uses default priority 0
        mMouseBeganCallback = window->getSignalMouseDown().connect(std::bind(&PretzelRoot::onMouseDown, this, std::placeholders::_1));
        mMouseDragCallback = window->getSignalMouseDrag().connect(std::bind(&PretzelRoot::onMouseDragged, this, std::placeholders::_1));
        mMouseEndCallback = window->getSignalMouseUp().connect(std::bind(&PretzelRoot::onMouseUp, this, std::placeholders::_1));
        mMouseMovedCallback = window->getSignalMouseMove().connect(std::bind(&PretzelRoot::onMouseMoved, this, std::placeholders::_1));
        mKeyDownCallback = window->getSignalKeyDown().connect(std::bind(&PretzelRoot::onKeyDown, this, std::placeholders::_1));
        mMouseWheelCallback = window->getSignalMouseWheel().connect(std::bind(&PretzelRoot::onMouseWheel, this, std::placeholders::_1));
        
        mUpdateCallback = ci::app::App::get()->getSignalUpdate().connect(std::bind(&PretzelRoot::update, this));
    }
}