mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-26 07:41:58 +00:00
eglewInit takes EGLDisplay parameter, will do eglIntialize internally, for now
This commit is contained in:
parent
15881f0421
commit
4d9010864e
@ -27,6 +27,12 @@
|
|||||||
#include <KHR/khrplatform.h>
|
#include <KHR/khrplatform.h>
|
||||||
#include <EGL/eglplatform.h>
|
#include <EGL/eglplatform.h>
|
||||||
|
|
||||||
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int32_t EGLint;
|
typedef int32_t EGLint;
|
||||||
|
|
||||||
typedef unsigned int EGLBoolean;
|
typedef unsigned int EGLBoolean;
|
||||||
@ -79,8 +85,3 @@ struct EGLClientPixmapHI;
|
|||||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
|
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
|
||||||
|
|
||||||
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname);
|
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
GLEWAPI GLenum GLEWAPIENTRY eglewInit ();
|
GLEWAPI GLenum GLEWAPIENTRY eglewInit (EGLDisplay display);
|
||||||
GLEWAPI GLboolean GLEWAPIENTRY eglewIsSupported (const char *name);
|
GLEWAPI GLboolean GLEWAPIENTRY eglewIsSupported (const char *name);
|
||||||
|
|
||||||
#define EGLEW_GET_VAR(x) (*(const GLboolean*)&x)
|
#define EGLEW_GET_VAR(x) (*(const GLboolean*)&x)
|
||||||
|
@ -11,32 +11,23 @@ GLboolean eglewGetExtension (const char* name)
|
|||||||
return _glewSearchExtension(name, start, end);
|
return _glewSearchExtension(name, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum eglewInit ()
|
GLenum eglewInit (EGLDisplay display)
|
||||||
{
|
{
|
||||||
GLuint dot;
|
EGLint major, minor;
|
||||||
GLint major, minor;
|
|
||||||
const GLubyte* version;
|
|
||||||
const GLubyte* extStart;
|
const GLubyte* extStart;
|
||||||
const GLubyte* extEnd;
|
const GLubyte* extEnd;
|
||||||
PFNEGLGETDISPLAYPROC getDisplay = NULL;
|
PFNEGLINITIALIZEPROC initialize = NULL;
|
||||||
PFNEGLQUERYSTRINGPROC queryString = NULL;
|
PFNEGLQUERYSTRINGPROC queryString = NULL;
|
||||||
|
|
||||||
/* Load necessary entry points */
|
/* Load necessary entry points */
|
||||||
getDisplay = (PFNEGLGETDISPLAYPROC) glewGetProcAddress("eglGetDisplay");
|
initialize = (PFNEGLINITIALIZEPROC) glewGetProcAddress("eglInitialize");
|
||||||
queryString = (PFNEGLQUERYSTRINGPROC) glewGetProcAddress("eglQueryString");
|
queryString = (PFNEGLQUERYSTRINGPROC) glewGetProcAddress("eglQueryString");
|
||||||
if (!getDisplay || !queryString)
|
if (!initialize || !queryString)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* query EGK version */
|
/* query EGK version */
|
||||||
major = 0;
|
if (initialize(display, &major, &minor) != EGL_TRUE)
|
||||||
minor = 0;
|
return 1;
|
||||||
version = (const GLubyte*) queryString(getDisplay(EGL_DEFAULT_DISPLAY), EGL_VERSION);
|
|
||||||
dot = _glewStrCLen(version, '.');
|
|
||||||
if (dot != 0)
|
|
||||||
{
|
|
||||||
major = version[dot-1]-'0';
|
|
||||||
minor = version[dot+1]-'0';
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLEW_VERSION_1_5 = ( major > 1 ) || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;
|
EGLEW_VERSION_1_5 = ( major > 1 ) || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;
|
||||||
EGLEW_VERSION_1_4 = EGLEW_VERSION_1_5 == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;
|
EGLEW_VERSION_1_4 = EGLEW_VERSION_1_5 == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;
|
||||||
@ -46,7 +37,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*) queryString(getDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS);
|
extStart = (const GLubyte*) queryString(display, EGL_EXTENSIONS);
|
||||||
if (extStart == 0)
|
if (extStart == 0)
|
||||||
extStart = (const GLubyte *)"";
|
extStart = (const GLubyte *)"";
|
||||||
extEnd = extStart + _glewStrLen(extStart);
|
extEnd = extStart + _glewStrLen(extStart);
|
||||||
|
@ -35,10 +35,14 @@ GLboolean glewExperimental = GL_FALSE;
|
|||||||
GLenum GLEWAPIENTRY glewInit (void)
|
GLenum GLEWAPIENTRY glewInit (void)
|
||||||
{
|
{
|
||||||
GLenum r;
|
GLenum r;
|
||||||
|
#if defined(GLEW_EGL)
|
||||||
|
PFNEGLGETCURRENTDISPLAYPROC getCurrentDisplay = NULL;
|
||||||
|
#endif
|
||||||
r = glewContextInit();
|
r = glewContextInit();
|
||||||
if ( r != 0 ) return r;
|
if ( r != 0 ) return r;
|
||||||
#if defined(GLEW_EGL)
|
#if defined(GLEW_EGL)
|
||||||
return eglewInit();
|
getCurrentDisplay = (PFNEGLGETCURRENTDISPLAYPROC) glewGetProcAddress("eglGetCurrentDisplay");
|
||||||
|
return eglewInit(getCurrentDisplay());
|
||||||
#elif defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
|
#elif defined(GLEW_OSMESA) || defined(__ANDROID__) || defined(__native_client__) || defined(__HAIKU__)
|
||||||
return r;
|
return r;
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
|
@ -159,18 +159,34 @@ EGLContext ctx;
|
|||||||
|
|
||||||
GLboolean glewCreateContext (struct createParams *params)
|
GLboolean glewCreateContext (struct createParams *params)
|
||||||
{
|
{
|
||||||
|
EGLDeviceEXT devices[1];
|
||||||
|
EGLint numDevices;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
EGLint majorVersion, minorVersion;
|
EGLint majorVersion, minorVersion;
|
||||||
const EGLint attr[] = {
|
static const EGLint configAttribs[] = {
|
||||||
EGL_BUFFER_SIZE, 32,
|
EGL_RED_SIZE, 1,
|
||||||
EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_CONFORMANT, EGL_OPENGL_BIT,
|
EGL_BLUE_SIZE, 1,
|
||||||
|
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
static const EGLint contextAttribs[] = {
|
||||||
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
static const EGLint pBufferAttribs[] = {
|
||||||
|
EGL_WIDTH, 128,
|
||||||
|
EGL_HEIGHT, 128,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLint numConfig;
|
EGLint numConfig;
|
||||||
|
EGLint error;
|
||||||
|
|
||||||
|
PFNEGLQUERYDEVICESEXTPROC queryDevices = NULL;
|
||||||
|
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay = NULL;
|
||||||
|
PFNEGLGETERRORPROC getError = NULL;
|
||||||
PFNEGLGETDISPLAYPROC getDisplay = NULL;
|
PFNEGLGETDISPLAYPROC getDisplay = NULL;
|
||||||
PFNEGLINITIALIZEPROC initialize = NULL;
|
PFNEGLINITIALIZEPROC initialize = NULL;
|
||||||
PFNEGLBINDAPIPROC bindAPI = NULL;
|
PFNEGLBINDAPIPROC bindAPI = NULL;
|
||||||
@ -178,28 +194,75 @@ GLboolean glewCreateContext (struct createParams *params)
|
|||||||
PFNEGLCREATEWINDOWSURFACEPROC createWindowSurface = NULL;
|
PFNEGLCREATEWINDOWSURFACEPROC createWindowSurface = NULL;
|
||||||
PFNEGLCREATECONTEXTPROC createContext = NULL;
|
PFNEGLCREATECONTEXTPROC createContext = NULL;
|
||||||
PFNEGLMAKECURRENTPROC makeCurrent = NULL;
|
PFNEGLMAKECURRENTPROC makeCurrent = NULL;
|
||||||
|
PFNEGLCREATEPBUFFERSURFACEPROC createPbufferSurface = NULL;
|
||||||
|
|
||||||
/* Load necessary entry points */
|
/* Load necessary entry points */
|
||||||
|
queryDevices = (PFNEGLQUERYDEVICESEXTPROC) eglGetProcAddress("eglQueryDevicesEXT");
|
||||||
|
getPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC) eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
|
getError = (PFNEGLGETERRORPROC) eglGetProcAddress("eglGetError");
|
||||||
getDisplay = (PFNEGLGETDISPLAYPROC) eglGetProcAddress("eglGetDisplay");
|
getDisplay = (PFNEGLGETDISPLAYPROC) eglGetProcAddress("eglGetDisplay");
|
||||||
initialize = (PFNEGLINITIALIZEPROC) eglGetProcAddress("eglInitialize");
|
initialize = (PFNEGLINITIALIZEPROC) eglGetProcAddress("eglInitialize");
|
||||||
bindAPI = (PFNEGLBINDAPIPROC) eglGetProcAddress("eglBindAPI");
|
bindAPI = (PFNEGLBINDAPIPROC) eglGetProcAddress("eglBindAPI");
|
||||||
chooseConfig = (PFNEGLCHOOSECONFIGPROC) eglGetProcAddress("eglChooseConfig");
|
chooseConfig = (PFNEGLCHOOSECONFIGPROC) eglGetProcAddress("eglChooseConfig");
|
||||||
createWindowSurface = (PFNEGLCREATEWINDOWSURFACEPROC) eglGetProcAddress("eglCreateWindowSurface");
|
createWindowSurface = (PFNEGLCREATEWINDOWSURFACEPROC) eglGetProcAddress("eglCreateWindowSurface");
|
||||||
|
createPbufferSurface = (PFNEGLCREATEPBUFFERSURFACEPROC) eglGetProcAddress("eglCreatePbufferSurface");
|
||||||
createContext = (PFNEGLCREATECONTEXTPROC) eglGetProcAddress("eglCreateContext");
|
createContext = (PFNEGLCREATECONTEXTPROC) eglGetProcAddress("eglCreateContext");
|
||||||
makeCurrent = (PFNEGLMAKECURRENTPROC) eglGetProcAddress("eglMakeCurrent");
|
makeCurrent = (PFNEGLMAKECURRENTPROC) eglGetProcAddress("eglMakeCurrent");
|
||||||
if (!getDisplay || !initialize || !bindAPI || !chooseConfig || !createWindowSurface || !createContext || !makeCurrent)
|
if (!getError || !getDisplay || !initialize || !bindAPI || !chooseConfig || !createWindowSurface || !createContext || !makeCurrent)
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
display = getDisplay((EGLNativeDisplayType) 0);
|
display = EGL_NO_DISPLAY;
|
||||||
if (!initialize(display, &majorVersion, &minorVersion))
|
if (queryDevices && getPlatformDisplay)
|
||||||
|
{
|
||||||
|
queryDevices(1, devices, &numDevices);
|
||||||
|
if (numDevices==1)
|
||||||
|
{
|
||||||
|
display = getPlatformDisplay(EGL_PLATFORM_DEVICE_EXT, devices[0], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (display==EGL_NO_DISPLAY)
|
||||||
|
{
|
||||||
|
display = getDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
}
|
||||||
|
if (display == EGL_NO_DISPLAY)
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
bindAPI(EGL_OPENGL_API);
|
|
||||||
if (!chooseConfig(display, attr, &config, 1, &numConfig) || (numConfig != 1))
|
eglewInit(display);
|
||||||
|
|
||||||
|
if (bindAPI(EGL_OPENGL_API) != EGL_TRUE)
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
|
if (chooseConfig(display, configAttribs, &config, 1, &numConfig) != EGL_TRUE || (numConfig != 1))
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
ctx = createContext(display, config, EGL_NO_CONTEXT, contextAttribs);
|
||||||
|
if (NULL == ctx)
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
surface = EGL_NO_SURFACE;
|
||||||
|
/* Create a p-buffer surface if possible */
|
||||||
|
if (createPbufferSurface)
|
||||||
|
{
|
||||||
|
surface = createPbufferSurface(display, config, pBufferAttribs);
|
||||||
|
}
|
||||||
|
/* Create a generic surface without a native window, if necessary */
|
||||||
|
if (surface==EGL_NO_SURFACE)
|
||||||
|
{
|
||||||
surface = createWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL);
|
surface = createWindowSurface(display, config, (EGLNativeWindowType) NULL, NULL);
|
||||||
ctx = createContext(display, config, NULL, NULL);
|
}
|
||||||
if (NULL == ctx) return GL_TRUE;
|
if (surface == EGL_NO_SURFACE)
|
||||||
makeCurrent(display, surface, surface, ctx);
|
return GL_TRUE;
|
||||||
|
|
||||||
|
if (makeCurrent(display, surface, surface, ctx) != EGL_TRUE)
|
||||||
|
return GL_TRUE;
|
||||||
|
|
||||||
|
error = getError();
|
||||||
|
if (error!=EGL_SUCCESS)
|
||||||
|
{
|
||||||
|
printf("eglGetError: %d\n", error);
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user