Added support for EGL_KHR_create_context.

This commit is contained in:
Camilla Berglund 2012-07-22 01:33:42 +02:00
parent 3b6ec4e775
commit edd554c115
2 changed files with 53 additions and 0 deletions

View File

@ -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;
}

View File

@ -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