]> git.tdb.fi Git - libs/gui.git/commitdiff
Add a core profile flag to OpenGL context options
authorMikko Rasa <tdb@tdb.fi>
Sun, 9 Jun 2019 10:59:59 +0000 (13:59 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 9 Jun 2019 10:59:59 +0000 (13:59 +0300)
source/graphics/glcontext.cpp
source/graphics/glcontext.h
source/graphics/glx/glcontext.cpp
source/graphics/wgl/glcontext.cpp

index df6ad604ef7d2b9a4eb563abb7f1c4a458787e9f..0274c9e216bdd7065084b73f74cf69a6ce2077e0 100644 (file)
@@ -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))
 { }
 
 
index 8c8b49968b91090809b2e746cabe2716707468d4..ef6ef1b60f25989431e4d710c5916a84bdc64af1 100644 (file)
@@ -16,6 +16,7 @@ struct GLOptions
        bool doublebuffer;
        unsigned multisample;
        bool forward_compatible;
+       bool core_profile;
        unsigned gl_version_major;
        unsigned gl_version_minor;
 
index 54541e969802216d19b51fe79ee40d05555c0471..3ee8865d7559e0890df797cb79ef893097f50847 100644 (file)
@@ -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);
index 35ec8e9b1983471f5dd12e476f4a662d2deaa7c4..ebca3f1912ef9ee67e1570c41ae71e98c5cb281f 100644 (file)
@@ -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);