From 48bcceaf611a17bb3795aa9fe25a0e0c726879f7 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Fri, 19 Oct 2012 07:48:07 +0200
Subject: EGLDrawableFactory: Detect ES1 implementation within ES2 library, if
 not found in ES1 library

This is the case in BCM-VC-IV blobs, tested on Raspeberry-Pi
---
 .../classes/jogamp/opengl/egl/EGLDrawableFactory.java  | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

(limited to 'src/jogl/classes')

diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index e985e63b2..dbe7ffa16 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -99,6 +99,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
         }
     }
 
+    private static final boolean includesES1(GLDynamicLookupHelper dl) {
+        return 0 != dl.dynamicLookupFunction("glLoadIdentity") &&
+               0 != dl.dynamicLookupFunction("glEnableClientState") &&
+               0 != dl.dynamicLookupFunction("glBegin") &&
+               0 != dl.dynamicLookupFunction("glColorPointer");
+    }
+    
     public EGLDrawableFactory() {
         super();
 
@@ -138,7 +145,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
                         System.err.println("Info: EGLDrawableFactory: EGL ES1 - OK, isANGLE: "+isANGLEES1);
                     }
                 } else if (DEBUG || GLProfile.DEBUG) {
-                    System.err.println("Info: EGLDrawableFactory: EGL ES1 - NOPE");
+                    System.err.println("Info: EGLDrawableFactory: EGL ES1 - NOPE (ES1 lib)");
                 }
             }
             if(!hasDesktopES2 && null==eglES2DynamicLookupHelper) {
@@ -153,10 +160,17 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
                 if(null!=tmp && tmp.isLibComplete()) {
                     eglES2DynamicLookupHelper = tmp;
                     EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
+                    final boolean includesES1 = null == eglES1DynamicLookupHelper && includesES1(eglES2DynamicLookupHelper);
+                    if(includesES1) {
+                        eglES1DynamicLookupHelper = tmp;
+                    }
                     final boolean isANGLEES2 = isANGLE(eglES2DynamicLookupHelper);
                     isANGLE |= isANGLEES2;
                     if (DEBUG || GLProfile.DEBUG) {
-                        System.err.println("Info: EGLDrawableFactory: EGL ES2 - OK, isANGLE: "+isANGLEES2);
+                        System.err.println("Info: EGLDrawableFactory: EGL ES2 - OK (includesES1 "+includesES1+", isANGLE: "+isANGLEES2+")");
+                        if(includesES1) {
+                            System.err.println("Info: EGLDrawableFactory: EGL ES1 - OK (ES2 lib)");
+                        }
                     }
                 } else if (DEBUG || GLProfile.DEBUG) {
                     System.err.println("Info: EGLDrawableFactory: EGL ES2 - NOPE");
-- 
cgit v1.2.3