From 5c3f8efd23282fc1e0e7d303e430bf8475ed4e1a Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 10 Apr 2015 13:18:26 +0200 Subject: [PATCH] Context config translation cleanup. --- src/egl_context.c | 21 ++++++++++++--------- src/glx_context.c | 26 +++++++++++++------------- src/wgl_context.c | 26 +++++++++++++------------- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index b15ca084..efb0d97e 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -320,17 +320,17 @@ int _glfwCreateContext(_GLFWwindow* window, if (_glfw.egl.KHR_create_context) { - int index = 0, mask = 0, flags = 0, strategy = 0; + int index = 0, mask = 0, flags = 0; if (ctxconfig->api == GLFW_OPENGL_API) { + if (ctxconfig->forward) + flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR; + if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR; else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE) mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR; - - if (ctxconfig->forward) - flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR; } if (ctxconfig->debug) @@ -339,9 +339,15 @@ int _glfwCreateContext(_GLFWwindow* window, if (ctxconfig->robustness) { if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION) - strategy = EGL_NO_RESET_NOTIFICATION_KHR; + { + setEGLattrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, + EGL_NO_RESET_NOTIFICATION_KHR); + } else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET) - strategy = EGL_LOSE_CONTEXT_ON_RESET_KHR; + { + setEGLattrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, + EGL_LOSE_CONTEXT_ON_RESET_KHR); + } flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR; } @@ -358,9 +364,6 @@ int _glfwCreateContext(_GLFWwindow* window, if (flags) setEGLattrib(EGL_CONTEXT_FLAGS_KHR, flags); - if (strategy) - setEGLattrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, strategy); - setEGLattrib(EGL_NONE, EGL_NONE); } else diff --git a/src/glx_context.c b/src/glx_context.c index ec34e8f1..d9127968 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -350,20 +350,17 @@ int _glfwCreateContext(_GLFWwindow* window, if (_glfw.glx.ARB_create_context) { - int index = 0, mask = 0, flags = 0, strategy = 0; + int index = 0, mask = 0, flags = 0; if (ctxconfig->api == GLFW_OPENGL_API) { if (ctxconfig->forward) flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; - if (ctxconfig->profile) - { - if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) - mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB; - else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE) - mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; - } + if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) + mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB; + else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE) + mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; } else mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT; @@ -376,9 +373,15 @@ int _glfwCreateContext(_GLFWwindow* window, if (_glfw.glx.ARB_create_context_robustness) { if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION) - strategy = GLX_NO_RESET_NOTIFICATION_ARB; + { + setGLXattrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, + GLX_NO_RESET_NOTIFICATION_ARB); + } else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET) - strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB; + { + setGLXattrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, + GLX_LOSE_CONTEXT_ON_RESET_ARB); + } flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB; } @@ -417,9 +420,6 @@ int _glfwCreateContext(_GLFWwindow* window, if (flags) setGLXattrib(GLX_CONTEXT_FLAGS_ARB, flags); - if (strategy) - setGLXattrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy); - setGLXattrib(None, None); window->glx.context = diff --git a/src/wgl_context.c b/src/wgl_context.c index 54051c50..ac41082e 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -380,20 +380,17 @@ int _glfwCreateContext(_GLFWwindow* window, if (window->wgl.ARB_create_context) { - int index = 0, mask = 0, flags = 0, strategy = 0; + int index = 0, mask = 0, flags = 0; if (ctxconfig->api == GLFW_OPENGL_API) { if (ctxconfig->forward) flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; - if (ctxconfig->profile) - { - if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) - mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB; - else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE) - mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; - } + if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE) + mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE) + mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; } else mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT; @@ -406,9 +403,15 @@ int _glfwCreateContext(_GLFWwindow* window, if (window->wgl.ARB_create_context_robustness) { if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION) - strategy = WGL_NO_RESET_NOTIFICATION_ARB; + { + setWGLattrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, + WGL_NO_RESET_NOTIFICATION_ARB); + } else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET) - strategy = WGL_LOSE_CONTEXT_ON_RESET_ARB; + { + setWGLattrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, + WGL_LOSE_CONTEXT_ON_RESET_ARB); + } flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB; } @@ -447,9 +450,6 @@ int _glfwCreateContext(_GLFWwindow* window, if (mask) setWGLattrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask); - if (strategy) - setWGLattrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy); - setWGLattrib(0, 0); window->wgl.context = window->wgl.CreateContextAttribsARB(window->wgl.dc,