From edd554c115b9359c4d6967f6f07ce4b6972c0d03 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 22 Jul 2012 01:33:42 +0200 Subject: [PATCH] Added support for EGL_KHR_create_context. --- src/x11_egl_opengl.c | 51 ++++++++++++++++++++++++++++++++++++++++++ src/x11_egl_platform.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/src/x11_egl_opengl.c b/src/x11_egl_opengl.c index 4db794ba..da92fb41 100644 --- a/src/x11_egl_opengl.c +++ b/src/x11_egl_opengl.c @@ -260,8 +260,56 @@ static int createContext(_GLFWwindow* window, setEGLattrib(attribs, index, EGL_CONTEXT_CLIENT_VERSION, wndconfig->glMajor); } else + { eglBindAPI(EGL_OPENGL_API); + if (_glfwLibrary.EGL.KHR_create_context) + { + setEGLattrib(attribs, index, EGL_CONTEXT_MAJOR_VERSION_KHR, wndconfig->glMajor); + setEGLattrib(attribs, index, EGL_CONTEXT_MINOR_VERSION_KHR, wndconfig->glMinor); + + if (wndconfig->glForward || wndconfig->glDebug || wndconfig->glRobustness) + { + int flags = 0; + + if (wndconfig->glForward) + flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR; + + if (wndconfig->glDebug) + flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR; + + if (wndconfig->glRobustness) + flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR; + + setEGLattrib(attribs, index, EGL_CONTEXT_FLAGS_KHR, flags); + } + + if (wndconfig->glProfile) + { + int flags = 0; + + if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE) + flags = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR; + else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE) + flags = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR; + + setEGLattrib(attribs, index, EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, flags); + } + + if (wndconfig->glRobustness) + { + int strategy; + + if (wndconfig->glRobustness == GLFW_OPENGL_NO_RESET_NOTIFICATION) + strategy = EGL_NO_RESET_NOTIFICATION_KHR; + else if (wndconfig->glRobustness == GLFW_OPENGL_LOSE_CONTEXT_ON_RESET) + strategy = EGL_LOSE_CONTEXT_ON_RESET_KHR; + + setEGLattrib(attribs, index, EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, strategy); + } + } + } + setEGLattrib(attribs, index, EGL_NONE, EGL_NONE); window->EGL.context = eglCreateContext(_glfwLibrary.EGL.display, @@ -337,6 +385,9 @@ int _glfwInitOpenGL(void) return GL_FALSE; } + if (_glfwPlatformExtensionSupported("EGL_KHR_create_context")) + _glfwLibrary.EGL.KHR_create_context = GL_TRUE; + return GL_TRUE; } diff --git a/src/x11_egl_platform.h b/src/x11_egl_platform.h index f3974676..d3e70055 100644 --- a/src/x11_egl_platform.h +++ b/src/x11_egl_platform.h @@ -85,6 +85,8 @@ typedef struct _GLFWlibraryEGL EGLDisplay display; EGLint majorVersion, minorVersion; + GLboolean KHR_create_context; + #if defined(_GLFW_DLOPEN_LIBEGL) void* libEGL; // dlopen handle for libEGL.so #endif