Beispiel #1
0
void
sge::opengl::target::read_pixels(
	sge::renderer::pixel_pos const _pos,
	sge::renderer::screen_size const _size,
	sge::opengl::color_order const _format,
	sge::opengl::color_base_type const _format_type,
	sge::renderer::raw_pointer const _dest
)
{
	sge::opengl::call(
		::glReadPixels,
		fcppt::cast::size<
			GLint
		>(
			_pos.x()
		),
		fcppt::cast::size<
			GLint
		>(
			_pos.y()
		),
		fcppt::cast::size<
			GLsizei
		>(
			fcppt::cast::to_signed(
				_size.w()
			)
		),
		fcppt::cast::size<
			GLsizei
		>(
			fcppt::cast::to_signed(
				_size.h()
			)
		),
		_format.get(),
		_format_type.get(),
		fcppt::cast::to_void_ptr(
			_dest
		)
	);

	SGE_OPENGL_CHECK_STATE(
		FCPPT_TEXT("glReadPixels failed"),
		sge::renderer::exception
	)
}
Beispiel #2
0
D3DPRESENT_PARAMETERS
sge::d3d9::parameters::create(
	sge::renderer::pixel_format::object const &_pixel_format,
	sge::renderer::display_mode::parameters const &_parameters,
	awl::window::object &_window
)
{
	sge::renderer::screen_size const back_buffer_size(
		sge::d3d9::parameters::extract_size(
			_parameters.display_mode(),
			_window
		)
	);

	bool const has_depth_stencil(
		_pixel_format.depth_stencil()
		!=
		sge::renderer::pixel_format::depth_stencil::off
	);

	D3DPRESENT_PARAMETERS const ret =
	{
		back_buffer_size.w(), // BackBufferWidth
		back_buffer_size.h(), // BackBufferHeight
		sge::d3d9::parameters::convert::bit_depth(
			_pixel_format.color()
		), // BackBufferFormat
		1u, // BackBufferCount,
		sge::d3d9::parameters::convert::multi_sample(
			_pixel_format.multi_samples()
		),
		sge::d3d9::parameters::convert::multi_sample_quality(
			_pixel_format.multi_samples()
		),
		D3DSWAPEFFECT_DISCARD, // SwapEffect
		fcppt::cast::dynamic_cross_exn<
			awl::backends::windows::window::object &
		>(
			_window
		).hwnd(), // hDeviceWindow
		!_parameters.display_mode().has_value(), // Windowed
		has_depth_stencil, // EnableAutoDepthStencil
		sge::d3d9::parameters::convert::depth_stencil_buffer(
			_pixel_format.depth_stencil()
		), // AutoDepthStencilFormat
		has_depth_stencil
		?
			D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
		:
			0u, // Flags
		// FullScreen_RefreshRateInHz
		fcppt::optional::maybe(
			fcppt::optional::bind(
				_parameters.display_mode(),
				[](
					sge::renderer::display_mode::object const &_display_mode
				)
				{
					return
						_display_mode.refresh_rate();
				}
			),
			fcppt::const_(
				0u
			),
			[](
				sge::renderer::display_mode::refresh_rate const _refresh_rate
			)
			{
				return
					_refresh_rate.get();
			}
		)
		,
		_parameters.vsync()
		==
		sge::renderer::display_mode::vsync::on
		?
			D3DPRESENT_INTERVAL_ONE
		:
			D3DPRESENT_INTERVAL_IMMEDIATE // PresentationInterval
	};

	return
		ret;
}