projects
/
gltest.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make the shaders work on NVidia
[gltest.git]
/
eglbackend.cpp
diff --git
a/eglbackend.cpp
b/eglbackend.cpp
index 2717b8648e648d1a270b85d889aa6f04fd4172b2..47e03844d0462497bcd1949c5d1f2f3bd8a6d56a 100644
(file)
--- a/
eglbackend.cpp
+++ b/
eglbackend.cpp
@@
-24,8
+24,8
@@
#include <EGL/eglext.h>
#include <EGL/eglext.h>
-#if !defined(CON_GL1) && !defined(CON_GLES2)
-#error "Valid GL contexts for EGL are: GL1, GLES2"
+#if !defined(CON_GL1) && !defined(CON_GL
3) && !defined(CON_GL
ES2)
+#error "Valid GL contexts for EGL are: GL1, GL
3, GL
ES2"
#endif
static const char *eglErrorToString(EGLint e)
#endif
static const char *eglErrorToString(EGLint e)
@@
-66,6
+66,10
@@
static const EGLint configAttribs[] = {
static const EGLint contextAttribs[] = {
#ifdef CON_GLES2
EGL_CONTEXT_CLIENT_VERSION, 2,
static const EGLint contextAttribs[] = {
#ifdef CON_GLES2
EGL_CONTEXT_CLIENT_VERSION, 2,
+#elif CON_GL3
+ EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
+ EGL_CONTEXT_MINOR_VERSION_KHR, 0,
+ EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
#endif
EGL_NONE
};
#endif
EGL_NONE
};
@@
-81,9
+85,9
@@
VisualID EGLBackend::initialize(Display *xDisplay)
if (eglInitialize(display, &eglMajor, &eglMinor) == EGL_FALSE)
dieEgl("Failed to initialize EGL");
printf("Using EGL version: %d.%d\n", eglMajor, eglMinor);
if (eglInitialize(display, &eglMajor, &eglMinor) == EGL_FALSE)
dieEgl("Failed to initialize EGL");
printf("Using EGL version: %d.%d\n", eglMajor, eglMinor);
- if (eglMajor == 1 && eglMinor <
3
) {
- // Choosing the GL context version requires EGL 1.3
- die("Need at least EGL 1.
3
to function properly\n");
+ if (eglMajor == 1 && eglMinor <
4
) {
+ // Choosing the GL context version requires EGL 1.3
, creating an OpenGL 3 context requires EGL 1.4
+ die("Need at least EGL 1.
4
to function properly\n");
}
#ifdef CON_GLES2
if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE)
}
#ifdef CON_GLES2
if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE)
@@
-91,6
+95,12
@@
VisualID EGLBackend::initialize(Display *xDisplay)
if (eglBindAPI(EGL_OPENGL_API) == EGL_FALSE)
#endif
dieEgl("Failed to bind API");
if (eglBindAPI(EGL_OPENGL_API) == EGL_FALSE)
#endif
dieEgl("Failed to bind API");
+ // check for the extension we need
+#ifdef CON_GL3
+ if (!haveEGLExtension("EGL_KHR_create_context")) {
+ die("Required EGL extension EGL_KHR_create_context is not supported\n");
+ }
+#endif
// get an appropriate config
EGLConfig configs[1];
EGLint count;
// get an appropriate config
EGLConfig configs[1];
EGLint count;
@@
-108,6
+118,13
@@
VisualID EGLBackend::initialize(Display *xDisplay)
return (VisualID)val;
}
return (VisualID)val;
}
+bool EGLBackend::haveEGLExtension(const std::string &name)
+{
+ assert(display != EGL_NO_DISPLAY);
+ std::string extensions = eglQueryString(display, EGL_EXTENSIONS);
+ return (std::string(" "+extensions+" ").find(" "+name+" ") != std::string::npos);
+}
+
void EGLBackend::createContext(Window window)
{
assert(display != EGL_NO_DISPLAY && context == EGL_NO_CONTEXT);
void EGLBackend::createContext(Window window)
{
assert(display != EGL_NO_DISPLAY && context == EGL_NO_CONTEXT);