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; }
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; }