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

This commit is contained in:
Nigel Stewart 2016-01-24 21:55:33 +10:00
parent 84b733d9bb
commit a755351991
2 changed files with 39 additions and 10 deletions

View File

@ -18,11 +18,19 @@ GLenum eglewInit ()
const GLubyte* version; const GLubyte* version;
const GLubyte* extStart; const GLubyte* extStart;
const GLubyte* extEnd; 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 */ /* query EGK version */
major = 0; major = 0;
minor = 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, '.'); dot = _glewStrCLen(version, '.');
if (dot != 0) 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; EGLEW_VERSION_1_0 = EGLEW_VERSION_1_1 == GL_TRUE || ( major == 1 && minor >= 0 ) ? GL_TRUE : GL_FALSE;
/* query EGL extension string */ /* 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) if (extStart == 0)
extStart = (const GLubyte *)""; extStart = (const GLubyte *)"";
extEnd = extStart + _glewStrLen(extStart); extEnd = extStart + _glewStrLen(extStart);

View File

@ -84,6 +84,7 @@ int main (int argc, char** argv)
glewInfo(); glewInfo();
#if defined(GLEW_OSMESA) #if defined(GLEW_OSMESA)
#elif defined(GLEW_EGL) #elif defined(GLEW_EGL)
eglewInfo();
#elif defined(_WIN32) #elif defined(_WIN32)
wglewInfo(); wglewInfo();
#else #else
@ -169,16 +170,36 @@ GLboolean glewCreateContext (struct createParams *params)
}; };
EGLConfig config; EGLConfig config;
EGLint numConfig; 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; return GL_TRUE;
eglBindAPI(EGL_OPENGL_API);
if (!eglChooseConfig(display, attr, &config, 1, &numConfig) || (numConfig != 1)) display = getDisplay((EGLNativeDisplayType) 0);
if (!initialize(display, &majorVersion, &minorVersion))
return GL_TRUE; return GL_TRUE;
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL); bindAPI(EGL_OPENGL_API);
ctx = eglCreateContext(display, config, NULL, NULL); if (!chooseConfig(display, attr, &config, 1, &numConfig) || (numConfig != 1))
return GL_TRUE;
surface = createWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL);
ctx = createContext(display, config, NULL, NULL);
if (NULL == ctx) return GL_TRUE; if (NULL == ctx) return GL_TRUE;
eglMakeCurrent(display, surface, surface, ctx); makeCurrent(display, surface, surface, ctx);
return GL_FALSE; return GL_FALSE;
} }