sge::opengl::wgl::visual::attribute_container sge::opengl::wgl::visual::make_attributes( sge::opengl::wgl::visual::config const &_config, sge::renderer::pixel_format::object const &_format ) { sge::opengl::wgl::visual::pixel_format_types const pixel_format_types( fcppt::optional::to_exception( _config.pixel_format_types(), []{ return sge::renderer::unsupported( FCPPT_TEXT("WGL pixel formats"), FCPPT_TEXT(""), FCPPT_TEXT("WGLEW_EXT_pixel_format, WGLEW_ARB_pixel_format") ); } ) ); sge::opengl::wgl::visual::attribute_container ret{ pixel_format_types.draw_to_window().get(), GL_TRUE, pixel_format_types.support_opengl().get(), GL_TRUE, pixel_format_types.double_buffer().get(), GL_TRUE, pixel_format_types.pixel_type().get(), pixel_format_types.pixel_type_rgba().get(), pixel_format_types.color_bits().get(), fcppt::cast::to_signed( sge::renderer::pixel_format::color_bits( _format.color() ).get() ) }; fcppt::optional::maybe_void( sge::renderer::pixel_format::depth_bits( _format.depth_stencil() ), [ &pixel_format_types, &ret ]( sge::renderer::pixel_format::bit_count const _depth_bits ) { ret.push_back( pixel_format_types.depth_bits().get() ); ret.push_back( fcppt::cast::to_signed( _depth_bits.get() ) ); } ); fcppt::optional::maybe_void( sge::renderer::pixel_format::stencil_bits( _format.depth_stencil() ), [ &pixel_format_types, &ret ]( sge::renderer::pixel_format::bit_count const _stencil_bits ) { ret.push_back( pixel_format_types.stencil_bits().get() ); ret.push_back( fcppt::cast::to_signed( _stencil_bits.get() ) ); } ); fcppt::optional::maybe_void( _format.multi_samples(), [ &_config, &ret ]( sge::renderer::pixel_format::multi_samples const _multi_samples ) { ret.push_back( fcppt::optional::to_exception( _config.multi_sample_flag(), []{ return sge::renderer::unsupported( FCPPT_TEXT("Multi sampling"), FCPPT_TEXT(""), FCPPT_TEXT("WGLEW_EXT_multisample, WGLEW_ARB_multisample") ); } ) ); ret.push_back( fcppt::cast::to_signed( _multi_samples.get() ) ); } ); if( _format.srgb() != sge::renderer::pixel_format::srgb::no ) fcppt::optional::maybe( _config.srgb_flag(), [ &_format ]{ if( _format.srgb() == sge::renderer::pixel_format::srgb::yes ) throw sge::renderer::unsupported( FCPPT_TEXT("SRGB framebuffer"), FCPPT_TEXT(""), FCPPT_TEXT("WGLEW_EXT_framebuffer_sRGB, WGLEW_ARB_framebuffer_sRGB") ); }, [ &ret ]( int const _srgb_flag ) { ret.push_back( _srgb_flag ); ret.push_back( GL_TRUE ); } ); // End ret.push_back( 0 ); return ret; }
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; }
sge::opengl::glx::visual::attribute_container sge::opengl::glx::visual::make_attributes( sge::opengl::glx::visual::optional_srgb_flag const _srgb_flag, sge::renderer::pixel_format::object const &_format ) { sge::opengl::glx::visual::attribute_container ret; ret.push_back( GLX_RGBA ); ret.push_back( GLX_DOUBLEBUFFER ); { sge::opengl::glx::visual::rgb_triple const rgb( sge::opengl::glx::visual::convert_color( _format.color() ) ); ret.push_back( GLX_RED_SIZE ); ret.push_back( rgb.red().get() ); ret.push_back( GLX_BLUE_SIZE ); ret.push_back( rgb.blue().get() ); ret.push_back( GLX_GREEN_SIZE ); ret.push_back( rgb.green().get() ); } fcppt::optional::maybe_void( sge::renderer::pixel_format::depth_bits( _format.depth_stencil() ), [ &ret ]( sge::renderer::pixel_format::bit_count const _depth_bits ) { ret.push_back( GLX_DEPTH_SIZE ); ret.push_back( fcppt::cast::to_signed( _depth_bits.get() ) ); } ); fcppt::optional::maybe_void( sge::renderer::pixel_format::stencil_bits( _format.depth_stencil() ), [ &ret ]( sge::renderer::pixel_format::bit_count const _stencil_bits ) { ret.push_back( GLX_STENCIL_SIZE ); ret.push_back( fcppt::cast::to_signed( _stencil_bits.get() ) ); } ); fcppt::optional::maybe_void( _format.multi_samples(), [ &ret ]( sge::renderer::pixel_format::multi_samples const _samples ) { ret.push_back( GLX_SAMPLE_BUFFERS ); ret.push_back( GL_TRUE ); ret.push_back( GLX_SAMPLES ); ret.push_back( fcppt::cast::to_signed( _samples.get() ) ); } ); if( _format.srgb() != sge::renderer::pixel_format::srgb::no ) fcppt::optional::maybe( _srgb_flag, [ &_format ]{ if( _format.srgb() == sge::renderer::pixel_format::srgb::yes ) throw sge::renderer::unsupported( FCPPT_TEXT("sRGB visuals"), FCPPT_TEXT(""), FCPPT_TEXT("GLX_EXT_framebuffer_sRGB, GLX_ARB_framebuffer_sRGB") ); }, [ &ret ]( sge::opengl::glx::visual::srgb_flag const _flag ) { ret.push_back( _flag.get() ); ret.push_back( GL_TRUE ); } ); ret.push_back( None ); return ret; }