From ed5d48f136c216e5de04264fc2e1f928109bf9f4 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 7 Oct 2018 10:08:24 -0700 Subject: [PATCH] Clamp NUM_SAMPLES glTexImage2DMultisample at GL_MAX_SAMPLES, since not all systems support >1 see https://github.com/iceiix/steven/issues/5#issuecomment-427669426 --- src/gl/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gl/mod.rs b/src/gl/mod.rs index 14a9206..b2e95d9 100644 --- a/src/gl/mod.rs +++ b/src/gl/mod.rs @@ -370,8 +370,18 @@ impl Texture { format: TextureFormat, fixed: bool) { unsafe { + let result: &mut [i32] = &mut [0; 1]; + gl::GetIntegerv(gl::MAX_SAMPLES, &mut result[0]); + let use_samples = + if samples > result[0] { + println!("glTexImage2DMultisample: requested {} samples but GL_MAX_SAMPLES is {}", samples, result[0]); + result[0] + } else { + samples + }; + gl::TexImage2DMultisample(target, - samples, + use_samples, format, width as i32, height as i32,