示例#1
0
	Game() {
		getLog().addDevice( new StreamLogDevice(std::cout) );

		win_.reset		( new Window( *this ) );
		inp_.reset		( new Input( *this ) );
		scene_.reset	( new ChcSceneManager(*this) );
		asmg_.reset		( new AssetManager( *this ) );

		asmg_->addContentFactory< ImageContent >( "img" );
		auto vms = VideoMode::getAvailable();
		
		std::sort( vms.begin(), vms.end(),
			[]( VideoMode &a, VideoMode &b ) {
				return a.getWidth() < b.getWidth();
			}
		);
		VideoMode vm = vms.back();
		vm.setFullscreen( true );
		//vm.setSize( 1920, 800 );
		vm.setVSync(true);
		vm.setDecorated( true );
		vm.setBpp( 32 );
		
		win_->setVideoMode( vm );
		
		addTask( *win_ );
		addTask( *inp_ );

		win_->addTask( *scene_ );
		
		inp_->addInputListener(*this);

		setupGL();
		loadTexture();
		createCamera();
		createLevel();

		ctrl_.reset( new CameraControl( *this ) );
		ctrl_->connect();
		

		BlockPlacer *pl = new BlockPlacer( *world_ );
		
		inp_->addInputListener( *pl );
		scene_->getRoot().createChild().attachEntity( *pl );		
	}
示例#2
0
	void Window::setVSync( bool vsync ) {
		log << "VSync change to " << vsync << ".\n";
		VideoMode newMode = mode_;
		newMode.setVSync(vsync);
		setVideoMode(newMode);
	}