Commit a7553519 authored by Nigel Stewart's avatar Nigel Stewart
Browse files

EGL fix: eglewInit and glewinfo need to manually load some EGL functions

parent 84b733d9
......@@ -18,11 +18,19 @@ GLenum eglewInit ()
const GLubyte* version;
const GLubyte* extStart;
const GLubyte* extEnd;
PFNEGLGETDISPLAYPROC getDisplay = NULL;
PFNEGLQUERYSTRINGPROC queryString = NULL;
/* Load necessary entry points */
getDisplay = (PFNEGLGETDISPLAYPROC) glewGetProcAddress("eglGetDisplay");
queryString = (PFNEGLQUERYSTRINGPROC) glewGetProcAddress("eglQueryString");
if (!getDisplay || !queryString)
return 1;
/* query EGK version */
major = 0;
minor = 0;
version = (const GLubyte*) eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_VERSION);
version = (const GLubyte*) queryString(getDisplay(EGL_DEFAULT_DISPLAY), EGL_VERSION);
dot = _glewStrCLen(version, '.');
if (dot != 0)
{
......@@ -38,7 +46,7 @@ GLenum eglewInit ()
EGLEW_VERSION_1_0 = EGLEW_VERSION_1_1 == GL_TRUE || ( major == 1 && minor >= 0 ) ? GL_TRUE : GL_FALSE;
/* query EGL extension string */
extStart = (const GLubyte*) eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS);
extStart = (const GLubyte*) queryString(getDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS);
if (extStart == 0)
extStart = (const GLubyte *)"";
extEnd = extStart + _glewStrLen(extStart);
......
......@@ -84,6 +84,7 @@ int main (int argc, char** argv)
glewInfo();
#if defined(GLEW_OSMESA)
#elif defined(GLEW_EGL)
eglewInfo();
#elif defined(_WIN32)
wglewInfo();
#else
......@@ -135,7 +136,7 @@ GLboolean glewParseArgs (int argc, char** argv, struct createParams *params)
{
if (++p >= argc) return GL_TRUE;
params->display = argv[p++];
}
}
else if (!strcmp(argv[p], "-visual"))
{
if (++p >= argc) return GL_TRUE;
......@@ -169,16 +170,36 @@ GLboolean glewCreateContext (struct createParams *params)
};
EGLConfig config;
EGLint numConfig;
display = eglGetDisplay((EGLNativeDisplayType) 0);
if (!eglInitialize(display, &majorVersion, &minorVersion))
PFNEGLGETDISPLAYPROC getDisplay = NULL;
PFNEGLINITIALIZEPROC initialize = NULL;
PFNEGLBINDAPIPROC bindAPI = NULL;
PFNEGLCHOOSECONFIGPROC chooseConfig = NULL;
PFNEGLCREATEWINDOWSURFACEPROC createWindowSurface = NULL;
PFNEGLCREATECONTEXTPROC createContext = NULL;
PFNEGLMAKECURRENTPROC makeCurrent = NULL;
/* Load necessary entry points */
getDisplay = (PFNEGLGETDISPLAYPROC) eglGetProcAddress("eglGetDisplay");
initialize = (PFNEGLINITIALIZEPROC) eglGetProcAddress("eglInitialize");
bindAPI = (PFNEGLBINDAPIPROC) eglGetProcAddress("eglBindAPI");
chooseConfig = (PFNEGLCHOOSECONFIGPROC) eglGetProcAddress("eglChooseConfig");
createWindowSurface = (PFNEGLCREATEWINDOWSURFACEPROC) eglGetProcAddress("eglCreateWindowSurface");
createContext = (PFNEGLCREATECONTEXTPROC) eglGetProcAddress("eglCreateContext");
makeCurrent = (PFNEGLMAKECURRENTPROC) eglGetProcAddress("eglMakeCurrent");
if (!getDisplay || !initialize || !bindAPI || !chooseConfig || !createWindowSurface || !createContext || !makeCurrent)
return GL_TRUE;
display = getDisplay((EGLNativeDisplayType) 0);
if (!initialize(display, &majorVersion, &minorVersion))
return GL_TRUE;
eglBindAPI(EGL_OPENGL_API);
if (!eglChooseConfig(display, attr, &config, 1, &numConfig) || (numConfig != 1))
bindAPI(EGL_OPENGL_API);
if (!chooseConfig(display, attr, &config, 1, &numConfig) || (numConfig != 1))
return GL_TRUE;
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL);
ctx = eglCreateContext(display, config, NULL, NULL);
surface = createWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL);
ctx = createContext(display, config, NULL, NULL);
if (NULL == ctx) return GL_TRUE;
eglMakeCurrent(display, surface, surface, ctx);
makeCurrent(display, surface, surface, ctx);
return GL_FALSE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment