From 6f236f6f2f65c5c185133c09e02ea6cfdf6b0aef Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Wed, 1 Nov 2017 12:56:40 +0100 Subject: [PATCH] Fix OSMesa context creation error for GL 3.x versions --- Cargo.toml | 2 +- src/platform/with_osmesa/mod.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 882bc9c..c748c63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "offscreen_gl_context" license = "MIT / Apache-2.0" -version = "0.12.0" +version = "0.12.1" authors = ["Emilio Cobos Álvarez ", "The Servo Project Developers"] description = "Creation and manipulation of HW accelerated offscreen rendering contexts in multiple platforms. Originally intended for the Servo project's WebGL implementation." repository = "https://github.com/emilio/rust-offscreen-rendering-context" diff --git a/src/platform/with_osmesa/mod.rs b/src/platform/with_osmesa/mod.rs index 536d407..69d8608 100644 --- a/src/platform/with_osmesa/mod.rs +++ b/src/platform/with_osmesa/mod.rs @@ -38,7 +38,10 @@ impl OSMesaContext { } let (major, minor) = match api_version { - GLVersion::Major(major) => (major, 1), // OpenGL 2.1, 3.1 + // OSMesa only supports compatibility (non-Core) profiles in GL versions <= 3.0. + // A 3.0 compatibility profile is preferred for a major 3 context version (e.g. WebGL 2). + // A 2.1 profile is created for a major 2 context version (e.g. WebGL 1). + GLVersion::Major(major) => (major, if major >= 3 { 0 } else { 1 }), GLVersion::MajorMinor(major, minor) => (major, minor) };