summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2015-01-05 13:43:10 +0000
committerJosé Fonseca <jfonseca@vmware.com>2015-01-05 14:42:00 +0000
commit4f3d5e3a17351437413b6fe30300c69230a4aeeb (patch)
treef637ec1bfe3a835de8965a4a5401919728b039ba
parente4b063bda99d8962823a6d4544eba04d3eb27619 (diff)
glws: Avoid referring to PROFILE_xxx directly in EGL backend.
-rw-r--r--retrace/glws_egl_xlib.cpp70
1 files changed, 42 insertions, 28 deletions
diff --git a/retrace/glws_egl_xlib.cpp b/retrace/glws_egl_xlib.cpp
index a22c97e1..e5adcd29 100644
--- a/retrace/glws_egl_xlib.cpp
+++ b/retrace/glws_egl_xlib.cpp
@@ -273,22 +273,29 @@ createVisual(bool doubleBuffer, unsigned samples, Profile profile) {
};
const EGLint *api_bits;
- switch(profile) {
- default:
+ ProfileDesc desc;
+ getProfileDesc(profile, desc);
+
+ if (desc.api == API_GL) {
if (!has_EGL_KHR_create_context) {
return NULL;
}
- /* pass-through */
- case PROFILE_COMPAT:
api_bits = api_bits_gl;
- break;
- case PROFILE_ES1:
- api_bits = api_bits_gles1;
- break;
- case PROFILE_ES2:
- api_bits = api_bits_gles2;
- break;
- };
+ } else if (desc.api == API_GLES) {
+ switch (desc.major) {
+ case 1:
+ api_bits = api_bits_gles1;
+ break;
+ case 2:
+ api_bits = api_bits_gles2;
+ break;
+ default:
+ return NULL;
+ }
+ } else {
+ assert(0);
+ return NULL;
+ }
for (int i = 0; i < 7; i++) {
Attributes<EGLint> attribs;
@@ -364,30 +371,37 @@ createContext(const Visual *_visual, Context *shareContext, bool debug)
ProfileDesc desc;
getProfileDesc(profile, desc);
- switch (profile) {
- case PROFILE_COMPAT:
+ if (desc.api == API_GL) {
load("libGL.so.1");
eglBindAPI(EGL_OPENGL_API);
- break;
- case PROFILE_ES1:
- load("libGLESv1_CM.so.1");
- eglBindAPI(EGL_OPENGL_ES_API);
- break;
- case PROFILE_ES2:
- load("libGLESv2.so.2");
+
+ if (has_EGL_KHR_create_context) {
+ attribs.add(EGL_CONTEXT_MAJOR_VERSION_KHR, desc.major);
+ attribs.add(EGL_CONTEXT_MINOR_VERSION_KHR, desc.minor);
+ int profileMask = desc.core ? EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR : EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
+ attribs.add(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, profileMask);
+ } else if (desc.versionGreaterOrEqual(3, 2)) {
+ std::cerr << "error: EGL_KHR_create_context not supported\n";
+ return NULL;
+ }
+ } else if (desc.api == API_GLES) {
+ if (desc.major >= 2) {
+ load("libGLESv2.so.2");
+ } else {
+ load("libGLESv1_CM.so.1");
+ }
+
eglBindAPI(EGL_OPENGL_ES_API);
- attribs.add(EGL_CONTEXT_CLIENT_VERSION, 2);
- break;
- default:
+
if (has_EGL_KHR_create_context) {
attribs.add(EGL_CONTEXT_MAJOR_VERSION_KHR, desc.major);
attribs.add(EGL_CONTEXT_MINOR_VERSION_KHR, desc.minor);
- if (desc.core) {
- attribs.add(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR);
- }
} else {
- return NULL;
+ attribs.add(EGL_CONTEXT_CLIENT_VERSION, desc.major);
}
+ } else {
+ assert(0);
+ return NULL;
}
if (debug && has_EGL_KHR_create_context) {