diff options
author | Mike Erwin <significant.bit@gmail.com> | 2015-12-07 02:00:22 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2015-12-07 02:02:07 +0300 |
commit | 8cfcc444c63fc6346f70899d593c3adaf1f4c748 (patch) | |
tree | 19f9abb22b3400acd27a1350baff17e88c976db1 /source/blender/gpu | |
parent | 1858823d3b9d7488ada8400393cb97efe2468efd (diff) |
OpenGL: new GPU_legacy_support() function
Is current context compatible with legacy GL (version 2.1)?
My earlier approach -- checking for GLEW_ARB_compatibility -- was not
enough.
This should always return true if we set our GL context up properly. It
will return false when we switch to core profile.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_extensions.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 27 |
2 files changed, 25 insertions, 3 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index e07f9025090..a5bcedb5f0e 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -59,6 +59,7 @@ typedef struct GPUProgram GPUProgram; void GPU_extensions_disable(void); +bool GPU_legacy_support(void); bool GPU_glsl_support(void); bool GPU_non_power_of_two_support(void); bool GPU_display_list_support(void); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 5e2fa19a754..4f3b84ced24 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -265,6 +265,27 @@ void gpu_extensions_exit(void) GPU_invalid_tex_free(); } +bool GPU_legacy_support(void) +{ + // return whether or not current GL context is compatible with legacy OpenGL + + if (GLEW_VERSION_3_2) { + static GLint profile = 0; + + if (profile == 0) { + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile); + } + + return profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; + } + else if (GLEW_VERSION_3_1) { + return GLEW_ARB_compatibility; + } + else { + return true; + } +} + bool GPU_glsl_support(void) { /* always supported, still queried by game engine */ @@ -298,12 +319,12 @@ bool GPU_geometry_shader_support(void) * core profile clashes with our other shaders so accept compatibility only * other GL versions can use EXT_geometry_shader4 if available */ - return (GLEW_VERSION_3_2 && GLEW_ARB_compatibility) || GLEW_EXT_geometry_shader4; + return (GLEW_VERSION_3_2 && GPU_legacy_support()) || GLEW_EXT_geometry_shader4; } static bool GPU_geometry_shader_support_via_extension(void) { - return GLEW_EXT_geometry_shader4 && !(GLEW_VERSION_3_2 && GLEW_ARB_compatibility); + return GLEW_EXT_geometry_shader4 && !(GLEW_VERSION_3_2 && GPU_legacy_support()); } bool GPU_instanced_drawing_support(void) @@ -1646,7 +1667,7 @@ static void shader_print_errors(const char *task, const char *log, const char ** static const char *gpu_shader_version(void) { if (GLEW_VERSION_3_2) { - if (GLEW_ARB_compatibility) { + if (GPU_legacy_support()) { return "#version 150 compatibility\n"; /* highest version that is widely supported * gives us native geometry shaders! |