Ejemplo n.º 1
0
EGLConfig
sge::opengl::egl::visual::choose_config(
	fcppt::log::object &_log,
	EGLDisplay const _display,
	sge::opengl::egl::attribute_vector const &_attributes
)
{
	EGLConfig result;

	EGLint num_config;

	if(
		::eglChooseConfig(
			_display,
			_attributes.data(),
			&result,
			1,
			&num_config
		)
		!=
		EGL_TRUE
	)
		throw
			sge::renderer::exception(
				FCPPT_TEXT("eglChooseConfig failed")
			);

	if(
		num_config
		<=
		0
	)
		throw
			sge::renderer::exception(
				FCPPT_TEXT("No matching EGL configs")
			);

	if(
		num_config
		!=
		1
	)
		FCPPT_LOG_WARNING(
			_log,
			fcppt::log::_
				<< FCPPT_TEXT("Multiple EGL configs are matching. Choosing the first one.")
		);

	return
		result;
}
Ejemplo n.º 2
0
EGLConfig
sge::opengl::egl::visual::to_config(
	fcppt::log::object &_log,
	EGLDisplay const _egl_display,
	awl::visual::object const &_visual
)
{
	return
		fcppt::optional::maybe(
			fcppt::cast::dynamic_cross<
				sge::opengl::egl::visual::base const
			>(
				_visual
			),
			[
				&_log,
				_egl_display
			]
			{
				FCPPT_LOG_WARNING(
					_log,
					fcppt::log::_
						<< FCPPT_TEXT("Visual is not an EGL visual.")
				);

				return
					sge::opengl::egl::visual::choose_config(
						_log,
						_egl_display,
						sge::opengl::egl::attribute_vector{
							EGL_NONE
						}
					);
			},
			[](
				fcppt::reference<
					sge::opengl::egl::visual::base const
				> const _sge_visual
			)
			{
				return
					_sge_visual.get().config();
			}
		);
}
Ejemplo n.º 3
0
sge::input::impl::multi_processor::multi_processor(
	fcppt::log::object &_log,
	sge::window::object const &_window,
	sge::window::system const &_window_system,
	sge::input::impl::system_ptr_vector const &_systems
)
:
	sge::input::processor(),
	processors_(
		fcppt::algorithm::map_optional<
			sge::input::impl::multi_processor::processor_vector
		>(
			_systems,
			[
				&_log,
				&_window,
				&_window_system
			](
				sge::input::system_unique_ptr const &_system
			)
			{
				typedef
				fcppt::optional::object<
					sge::input::processor_unique_ptr
				>
				optional_processor;

				try
				{
					return
						optional_processor{
							_system->create_processor(
								_window,
								_window_system
							)
						};
				}
				catch(
					fcppt::cast::bad_dynamic const &_error
				)
				{
					FCPPT_LOG_WARNING(
						_log,
						fcppt::log::_
							<<
							FCPPT_TEXT("Unusuable input plugin: ")
							<<
							_error.string()
					);

					return
						optional_processor{};
				}
			}
		)
	),
	keyboard_discover_(),
	keyboard_remove_(),
	mouse_discover_(),
	mouse_remove_(),
	focus_discover_(),
	focus_remove_(),
	cursor_discover_(),
	cursor_remove_(),
	joypad_discover_(),
	joypad_remove_(),
	connections_(
		fcppt::algorithm::map_concat<
			sge::input::impl::multi_processor::connection_container
		>(
			processors_,
			[
				this
			](
				sge::input::processor_unique_ptr const &_processor
			)
			{
				return
					fcppt::assign::make_container<
						sge::input::impl::multi_processor::connection_container
					>(
						_processor->keyboard_discover_callback(
							sge::input::keyboard::discover_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_keyboard_discover,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->keyboard_remove_callback(
							sge::input::keyboard::remove_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_keyboard_remove,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->mouse_discover_callback(
							sge::input::mouse::discover_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_mouse_discover,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->mouse_remove_callback(
							sge::input::mouse::remove_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_mouse_remove,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->focus_discover_callback(
							sge::input::focus::discover_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_focus_discover,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->focus_remove_callback(
							sge::input::focus::remove_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_focus_remove,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->cursor_discover_callback(
							sge::input::cursor::discover_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_cursor_discover,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->cursor_remove_callback(
							sge::input::cursor::remove_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_cursor_remove,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->joypad_discover_callback(
							sge::input::joypad::discover_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_joypad_discover,
									this,
									std::placeholders::_1
								)
							}
						),
						_processor->joypad_remove_callback(
							sge::input::joypad::remove_callback{
								std::bind(
									&sge::input::impl::multi_processor::on_joypad_remove,
									this,
									std::placeholders::_1
								)
							}
						)
					);
			}
		)
	)
{
}