From 4727c8ca14f2d278a74e0abe64b7a31e68238a8a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 9 Jun 2019 13:59:59 +0300 Subject: [PATCH] Add a core profile flag to OpenGL context options --- source/graphics/glcontext.cpp | 5 +++-- source/graphics/glcontext.h | 1 + source/graphics/glx/glcontext.cpp | 6 ++++++ source/graphics/wgl/glcontext.cpp | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/graphics/glcontext.cpp b/source/graphics/glcontext.cpp index df6ad60..0274c9e 100644 --- a/source/graphics/glcontext.cpp +++ b/source/graphics/glcontext.cpp @@ -14,14 +14,15 @@ GLOptions::GLOptions(): doublebuffer(true), multisample(0), forward_compatible(false), + core_profile(false), gl_version_major(0), gl_version_minor(0) { } unsupported_gl_mode::unsupported_gl_mode(const GLOptions &opts): - runtime_error(format("{ .alpha=%s, .stencil=%s, .doublebuffer=%s, .multisample=%d, .forward_compatible=%s, .gl_version=%d.%d }", - opts.alpha, opts.stencil, opts.doublebuffer, opts.multisample, opts.forward_compatible, opts.gl_version_major, opts.gl_version_minor)) + runtime_error(format("{ .alpha=%s, .stencil=%s, .doublebuffer=%s, .multisample=%d, .forward_compatible=%s, .core_profile=%s, .gl_version=%d.%d }", + opts.alpha, opts.stencil, opts.doublebuffer, opts.multisample, opts.forward_compatible, opts.core_profile, opts.gl_version_major, opts.gl_version_minor)) { } diff --git a/source/graphics/glcontext.h b/source/graphics/glcontext.h index 8c8b499..ef6ef1b 100644 --- a/source/graphics/glcontext.h +++ b/source/graphics/glcontext.h @@ -16,6 +16,7 @@ struct GLOptions bool doublebuffer; unsigned multisample; bool forward_compatible; + bool core_profile; unsigned gl_version_major; unsigned gl_version_minor; diff --git a/source/graphics/glx/glcontext.cpp b/source/graphics/glx/glcontext.cpp index 54541e9..3ee8865 100644 --- a/source/graphics/glx/glcontext.cpp +++ b/source/graphics/glx/glcontext.cpp @@ -114,6 +114,12 @@ void GLContext::platform_init(const GLOptions &opts) ctx_attribs.push_back(GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB); } + if(opts.core_profile) + { + ctx_attribs.push_back(GLX_CONTEXT_PROFILE_MASK_ARB); + ctx_attribs.push_back(GLX_CONTEXT_CORE_PROFILE_BIT_ARB); + } + if(opts.gl_version_major) { ctx_attribs.push_back(GLX_CONTEXT_MAJOR_VERSION_ARB); diff --git a/source/graphics/wgl/glcontext.cpp b/source/graphics/wgl/glcontext.cpp index 35ec8e9..ebca3f1 100644 --- a/source/graphics/wgl/glcontext.cpp +++ b/source/graphics/wgl/glcontext.cpp @@ -60,6 +60,12 @@ void GLContext::platform_init(const GLOptions &opts) ctx_attribs.push_back(WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB); } + if(opts.core_profile) + { + ctx_attribs.push_back(WGL_CONTEXT_PROFILE_MASK_ARB); + ctx_attribs.push_back(WGL_CONTEXT_CORE_PROFILE_BIT_ARB); + } + if(opts.gl_version_major) { ctx_attribs.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB); -- 2.43.0