add vsync option

This commit is contained in:
griffi-gh 2023-05-16 12:20:09 +02:00
parent ce8ad9098f
commit fb68f8d12d
2 changed files with 9 additions and 8 deletions

View file

@ -74,6 +74,7 @@ impl Renderer {
let cb = ContextBuilder::new() let cb = ContextBuilder::new()
.with_depth_buffer(24) .with_depth_buffer(24)
.with_multisampling(settings.msaa.unwrap_or_default()) .with_multisampling(settings.msaa.unwrap_or_default())
.with_vsync(settings.vsync)
.with_gl_profile(GlProfile::Core); .with_gl_profile(GlProfile::Core);
let display = Display::new(wb, cb, event_loop) let display = Display::new(wb, cb, event_loop)
@ -81,14 +82,12 @@ impl Renderer {
log::info!("Vendor: {}", display.get_opengl_vendor_string()); log::info!("Vendor: {}", display.get_opengl_vendor_string());
log::info!("Renderer: {}", display.get_opengl_renderer_string()); log::info!("Renderer: {}", display.get_opengl_renderer_string());
log::info!("OpenGL {}", display.get_opengl_version_string()); log::info!("OpenGL: {}", display.get_opengl_version_string());
log::info!("Supports GLSL {:?}", display.get_supported_glsl_version()); log::info!("Supports GLSL: {:?}", display.get_supported_glsl_version());
if display.is_context_loss_possible() { log::info!("Framebuffer dimensions: {:?}", display.get_framebuffer_dimensions());
log::warn!("ogl context loss possible"); if display.is_context_loss_possible() { log::warn!("OpenGL context loss possible") }
} if display.is_robust() { log::warn!("OpenGL implementation is not robust") }
if display.is_robust() { if display.is_debug() { log::info!("OpenGL context is in debug mode") }
log::warn!("ogl implementation is not robust");
}
assert!(display.is_glsl_version_supported(&Version(Api::GlEs, 3, 0)), "GLES 3.0 is not supported"); assert!(display.is_glsl_version_supported(&Version(Api::GlEs, 3, 0)), "GLES 3.0 is not supported");

View file

@ -11,6 +11,7 @@ pub struct FullscreenSettings {
#[derive(Unique)] #[derive(Unique)]
pub struct GameSettings { pub struct GameSettings {
pub vsync: bool,
pub fullscreen: Option<FullscreenSettings>, pub fullscreen: Option<FullscreenSettings>,
pub msaa: Option<u16>, pub msaa: Option<u16>,
pub max_anisotropy: Option<u16>, pub max_anisotropy: Option<u16>,
@ -22,6 +23,7 @@ pub struct GameSettings {
impl Default for GameSettings { impl Default for GameSettings {
fn default() -> Self { fn default() -> Self {
Self { Self {
vsync: false,
fullscreen: None, fullscreen: None,
msaa: Some(4), //not used yet msaa: Some(4), //not used yet
max_anisotropy: Some(16), max_anisotropy: Some(16),