Пример #1
0
awl::main::exit_code const
fruitapp::main(
	awl::main::function_context const &_main_function_context)
try
{
	fruitlib::signal_stack_printer::object stack_printer;

	fruitapp::machine machine(
		_main_function_context.argc(),
		_main_function_context.argv());

	fcppt::scoped_state_machine<fruitapp::machine> scoped_state_machine(
		machine);

	return
		machine.run();
}
catch (fcppt::exception const &e)
{
	fruitlib::message_box(
		FCPPT_TEXT("fcppt::exception: ")+
		e.string());
	return awl::main::exit_failure();
}
catch (std::exception const &e)
{
	fruitlib::message_box(
		FCPPT_TEXT("std::exception: ")+
		fcppt::from_std_string(
			e.what()));
	return awl::main::exit_failure();
}
Пример #2
0
awl::main::exit_code const
sgeroids::main(
	awl::main::function_context const &_main_function_context)
try
{
	sgeroids::state_machine::object machine(
		_main_function_context.argc(),
		_main_function_context.argv());

	fcppt::scoped_state_machine<sgeroids::state_machine::object> const scoped_machine(
		machine);

	return
		machine.run();
}
catch(
	fcppt::exception const &e)
{
	fcppt::io::cerr()
		<< FCPPT_TEXT("fcppt::exception: ")
		<< e.string()
		<< FCPPT_TEXT("\n");
	return awl::main::exit_failure();
}
catch(
	std::exception const &e)
{
	std::cerr
		<< "std::exception: "
		<< e.what()
		<< "\n";

	return awl::main::exit_failure();
}
Пример #3
0
awl::main::exit_code const
example_main(
	awl::main::function_context const &_main_function_context
)
try
{
	if(
		_main_function_context.argc() > 2
	)
	{
		fcppt::io::cerr()
			<< FCPPT_TEXT("Pass exactly one argument to show a given text")
			FCPPT_TEXT(" or pass nothing to see the default text.\n");

		return
			awl::main::exit_failure();
	}

	sge::systems::instance<
		boost::mpl::vector4<
			sge::systems::with_renderer<
				sge::systems::renderer_caps::ffp
			>,
			sge::systems::with_window,
			sge::systems::with_input<
				boost::mpl::vector1<
					sge::systems::keyboard_collector
				>
			>,
			sge::systems::with_image2d
		>
	> const sys(
		sge::systems::make_list
		(
			sge::systems::window(
				sge::systems::window_source(
					sge::systems::original_window(
						sge::window::title(
							FCPPT_TEXT("sge animtest")
						)
					)
				)
			)
		)
		(
			sge::systems::renderer(
				sge::renderer::pixel_format::object(
					sge::renderer::pixel_format::color::depth32,
					sge::renderer::pixel_format::depth_stencil::off,
					sge::renderer::pixel_format::optional_multi_samples(),
					sge::renderer::pixel_format::srgb::no
				),
				sge::renderer::display_mode::parameters(
					sge::renderer::display_mode::vsync::on,
					sge::renderer::display_mode::optional_object()
				),
				sge::viewport::optional_resize_callback{
					sge::viewport::center_on_resize(
						sge::window::dim{
							1024u,
							768u
						}
					)
				}
			)
		)
		(
			sge::systems::input(
				sge::systems::cursor_option_field::null()
			)
		)
		(
			sge::systems::image2d(
				sge::media::optional_extension_set(
					sge::media::extension_set{
						sge::media::extension(
							FCPPT_TEXT("png")
						)
					}
				)
			)
		)
	);

	sge::font::object_unique_ptr const font_object(
		sge::font::bitmap::create(
			sys.log_context(),
			sge::config::media_path()
			/ FCPPT_TEXT("fonts")
			/ FCPPT_TEXT("bitmap")
			/ FCPPT_TEXT("font.json"),
			sys.image_system()
		)
	);

	fcppt::signal::auto_connection const escape_connection(
		sge::systems::quit_on_escape(
			sys
		)
	);

	sge::font::string const string(
		_main_function_context.argc() == 2
		?
			sge::font::from_fcppt_string(
				fcppt::from_std_string(
					_main_function_context.argv()[1]
				)
			)
		:
			SGE_FONT_LIT("test abcd e 123456789 10 11")
	);

	sge::font::draw::static_text static_text_left(
		sys.renderer_device_ffp(),
		*font_object,
		string,
		sge::font::text_parameters(
			sge::font::align_h::variant(
				sge::font::align_h::left(
					sge::font::align_h::max_width(
						300
					)
				)
			)
		),
		sge::font::vector(
			100,
			100
		),
		sge::image::color::predef::white(),
		sge::renderer::texture::emulate_srgb::yes
	);

	sge::font::draw::static_text static_text_center(
		sys.renderer_device_ffp(),
		*font_object,
		string,
		sge::font::text_parameters(
			sge::font::align_h::variant(
				sge::font::align_h::center(
					sge::font::align_h::max_width(
						300
					)
				)
			)
		),
		sge::font::vector(
			400,
			100
		),
		sge::image::color::predef::white(),
		sge::renderer::texture::emulate_srgb::yes
	);

	sge::font::draw::static_text static_text_right(
		sys.renderer_device_ffp(),
		*font_object,
		string,
		sge::font::text_parameters(
			sge::font::align_h::variant(
				sge::font::align_h::right(
					sge::font::align_h::max_width(
						300
					)
				)
			)
		),
		sge::font::vector(
			700,
			100
		),
		sge::image::color::predef::white(),
		sge::renderer::texture::emulate_srgb::yes
	);

	while(
		sys.window_system().poll()
	)
	{
		sge::renderer::context::scoped_ffp const scoped_block(
			sys.renderer_device_ffp(),
			sys.renderer_device_ffp().onscreen_target()
		);

		scoped_block.get().clear(
			sge::renderer::clear::parameters()
			.back_buffer(
				sge::image::color::predef::black()
			)
		);

		static_text_left.draw(
			scoped_block.get()
		);

		static_text_center.draw(
			scoped_block.get()
		);

		static_text_right.draw(
			scoped_block.get()
		);
	}

	return
		sys.window_system().exit_code();
}
catch(
	fcppt::exception const &_exception
)
{
	fcppt::io::cerr()
		<< _exception.string()
		<< FCPPT_TEXT('\n');

	return awl::main::exit_failure();
}
catch(
	std::exception const &_exception
)
{
	std::cerr << _exception.what() << '\n';

	return awl::main::exit_failure();
}