Java Code Examples for android.opengl.EGL14#eglQueryContext()

The following examples show how to use android.opengl.EGL14#eglQueryContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EGLBase.java    From Tok-Android with GNU General Public License v3.0 5 votes vote down vote up
private void init(EGLContext shared_context, final boolean with_depth_buffer,
    final boolean isRecordable) {
    LogUtil.i(TAG, "init:");
    if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("EGL already set up");
    }

    mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("eglGetDisplay failed");
    }

    final int[] version = new int[2];
    if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
        mEglDisplay = null;
        throw new RuntimeException("eglInitialize failed");
    }

    shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
    if (mEglContext == EGL14.EGL_NO_CONTEXT) {
        mEglConfig = getConfig(with_depth_buffer, isRecordable);
        if (mEglConfig == null) {
            throw new RuntimeException("chooseConfig failed");
        }
        // create EGL rendering context
        mEglContext = createContext(shared_context);
    }
    // confirm whether the EGL rendering context is successfully created
    final int[] values = new int[1];
    EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values,
        0);
    LogUtil.i(TAG, "EGLContext created, client version " + values[0]);
    makeDefault();    // makeCurrent(EGL14.EGL_NO_SURFACE);
}
 
Example 2
Source File: EGLBase.java    From In77Camera with MIT License 5 votes vote down vote up
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) {
	if (DEBUG) Log.v(TAG, "init:");
       if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("EGL already set up");
       }

       mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
       if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("eglGetDisplay failed");
       }

	final int[] version = new int[2];
       if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
       	mEglDisplay = null;
           throw new RuntimeException("eglInitialize failed");
       }

	shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
       if (mEglContext == EGL14.EGL_NO_CONTEXT) {
           mEglConfig = getConfig(with_depth_buffer, isRecordable);
           if (mEglConfig == null) {
               throw new RuntimeException("chooseConfig failed");
           }
           // create EGL rendering context
        mEglContext = createContext(shared_context);
       }
       // confirm whether the EGL rendering context is successfully created
       final int[] values = new int[1];
       EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
       if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]);
       makeDefault();	// makeCurrent(EGL14.EGL_NO_SURFACE);
}
 
Example 3
Source File: EGLBase.java    From CameraRecorder-android with MIT License 5 votes vote down vote up
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) {
    if (DEBUG) Log.v(TAG, "init:");
    if (eglDisplay != EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("EGL already set up");
    }

    eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (eglDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("eglGetDisplay failed");
    }

    final int[] version = new int[2];
    if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) {
        eglDisplay = null;
        throw new RuntimeException("eglInitialize failed");
    }

    shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
    if (eglContext == EGL14.EGL_NO_CONTEXT) {
        eglConfig = getConfig(with_depth_buffer, isRecordable);
        if (eglConfig == null) {
            throw new RuntimeException("chooseConfig failed");
        }
        // create EGL rendering context
        eglContext = createContext(shared_context);
    }
    // confirm whether the EGL rendering context is successfully created
    final int[] values = new int[1];
    EGL14.eglQueryContext(eglDisplay, eglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
    if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]);
    makeDefault();    // makeCurrent(EGL14.EGL_NO_SURFACE);
}
 
Example 4
Source File: EGLBase.java    From Fatigue-Detection with MIT License 5 votes vote down vote up
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) {
	if (DEBUG) Log.v(TAG, "init:");
       if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("EGL already set up");
       }

       mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
       if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("eglGetDisplay failed");
       }

	final int[] version = new int[2];
       if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
       	mEglDisplay = null;
           throw new RuntimeException("eglInitialize failed");
       }

	shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
       if (mEglContext == EGL14.EGL_NO_CONTEXT) {
           mEglConfig = getConfig(with_depth_buffer, isRecordable);
           if (mEglConfig == null) {
               throw new RuntimeException("chooseConfig failed");
           }
           // create EGL rendering context
        mEglContext = createContext(shared_context);
       }
       // confirm whether the EGL rendering context is successfully created
       final int[] values = new int[1];
       EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
       if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]);
       makeDefault();	// makeCurrent(EGL14.EGL_NO_SURFACE);
}
 
Example 5
Source File: EGLEnvironment.java    From EZFilter with MIT License 5 votes vote down vote up
private void init(EGLContext sharedContext, final boolean withDepthBuffer) {
    if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("EGL already set up");
    }

    mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("eglGetDisplay failed");
    }

    final int[] version = new int[2];
    if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
        mEglDisplay = null;
        throw new RuntimeException("eglInitialize failed");
    }

    sharedContext = sharedContext != null ? sharedContext : EGL14.EGL_NO_CONTEXT;
    if (mEglContext == EGL14.EGL_NO_CONTEXT) {
        mEglConfig = getConfig(withDepthBuffer);
        if (mEglConfig == null) {
            throw new RuntimeException("chooseConfig failed");
        }
        // create EGL rendering context
        mEglContext = createContext(sharedContext);
    }
    // confirm whether the EGL rendering context is successfully created
    final int[] values = new int[1];
    EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
    makeDefault();
}
 
Example 6
Source File: EGLBase.java    From MegviiFacepp-Android-SDK with Apache License 2.0 5 votes vote down vote up
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) {
	if (DEBUG) Log.v(TAG, "init:");
       if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("EGL already set up");
       }

       mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
       if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("eglGetDisplay failed");
       }

	final int[] version = new int[2];
       if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
       	mEglDisplay = null;
           throw new RuntimeException("eglInitialize failed");
       }

	shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
       if (mEglContext == EGL14.EGL_NO_CONTEXT) {
           mEglConfig = getConfig(with_depth_buffer, isRecordable);
           if (mEglConfig == null) {
               throw new RuntimeException("chooseConfig failed");
           }
           // create EGL rendering context
        mEglContext = createContext(shared_context);
       }
       // confirm whether the EGL rendering context is successfully created
       final int[] values = new int[1];
       EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
       if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]);
       makeDefault();	// makeCurrent(EGL14.EGL_NO_SURFACE);
}
 
Example 7
Source File: EGLBase.java    From UVCCameraZxing with Apache License 2.0 5 votes vote down vote up
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) {
	if (DEBUG) Log.v(TAG, "init:");
       if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("EGL already set up");
       }

       mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
       if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("eglGetDisplay failed");
       }

	final int[] version = new int[2];
       if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
       	mEglDisplay = null;
           throw new RuntimeException("eglInitialize failed");
       }

	shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
       if (mEglContext == EGL14.EGL_NO_CONTEXT) {
           mEglConfig = getConfig(with_depth_buffer, isRecordable);
           if (mEglConfig == null) {
               throw new RuntimeException("chooseConfig failed");
           }
           // create EGL rendering context
        mEglContext = createContext(shared_context);
       }
       // confirm whether the EGL rendering context is successfully created
       final int[] values = new int[1];
       EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
       if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]);
       makeDefault();	// makeCurrent(EGL14.EGL_NO_SURFACE);
}
 
Example 8
Source File: EGLBase.java    From TimeLapseRecordingSample with Apache License 2.0 5 votes vote down vote up
private void init(EGLContext shared_context, boolean with_depth_buffer, boolean isRecordable) {
	if (DEBUG) Log.v(TAG, "init:");
       if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("EGL already set up");
       }

       mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
       if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("eglGetDisplay failed");
       }

	final int[] version = new int[2];
       if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
       	mEglDisplay = null;
           throw new RuntimeException("eglInitialize failed");
       }

	shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
       if (mEglContext == EGL14.EGL_NO_CONTEXT) {
           mEglConfig = getConfig(with_depth_buffer, isRecordable);
           if (mEglConfig == null) {
               throw new RuntimeException("chooseConfig failed");
           }
           // create EGL rendering context
        mEglContext = createContext(shared_context);
       }
       // confirm whether the EGL rendering context is successfully created
       final int[] values = new int[1];
       EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
       if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]);
       makeDefault();	// makeCurrent(EGL14.EGL_NO_SURFACE);
}
 
Example 9
Source File: EGLBase.java    From AudioVideoPlayerSample with Apache License 2.0 5 votes vote down vote up
private void init(EGLContext shared_context, boolean with_depth_buffer) {
	if (DEBUG) Log.v(TAG, "init:");
       if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("EGL already set up");
       }

       mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
       if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("eglGetDisplay failed");
       }

	final int[] version = new int[2];
       if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
       	mEglDisplay = null;
           throw new RuntimeException("eglInitialize failed");
       }

	shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
       if (mEglContext == EGL14.EGL_NO_CONTEXT) {
           mEglConfig = getConfig(with_depth_buffer);
           if (mEglConfig == null) {
               throw new RuntimeException("chooseConfig failed");
           }
           // create EGL rendering context
        mEglContext = createContext(shared_context);
       }
       // confirm whether the EGL rendering context is successfully created
       final int[] values = new int[1];
       EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
       if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]);
}
 
Example 10
Source File: EGLBase.java    From AudioVideoRecordingSample with Apache License 2.0 5 votes vote down vote up
private void init(EGLContext shared_context, final boolean with_depth_buffer, final boolean isRecordable) {
	if (DEBUG) Log.v(TAG, "init:");
       if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("EGL already set up");
       }

       mEglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
       if (mEglDisplay == EGL14.EGL_NO_DISPLAY) {
           throw new RuntimeException("eglGetDisplay failed");
       }

	final int[] version = new int[2];
       if (!EGL14.eglInitialize(mEglDisplay, version, 0, version, 1)) {
       	mEglDisplay = null;
           throw new RuntimeException("eglInitialize failed");
       }

	shared_context = shared_context != null ? shared_context : EGL14.EGL_NO_CONTEXT;
       if (mEglContext == EGL14.EGL_NO_CONTEXT) {
           mEglConfig = getConfig(with_depth_buffer, isRecordable);
           if (mEglConfig == null) {
               throw new RuntimeException("chooseConfig failed");
           }
           // create EGL rendering context
        mEglContext = createContext(shared_context);
       }
       // confirm whether the EGL rendering context is successfully created
       final int[] values = new int[1];
       EGL14.eglQueryContext(mEglDisplay, mEglContext, EGL14.EGL_CONTEXT_CLIENT_VERSION, values, 0);
       if (DEBUG) Log.d(TAG, "EGLContext created, client version " + values[0]);
       makeDefault();	// makeCurrent(EGL14.EGL_NO_SURFACE);
}
 
Example 11
Source File: GLSurfaceView2.java    From java6-android-glframework with Mozilla Public License 2.0 4 votes vote down vote up
public EGLContext createContext(EGLDisplay display, EGLConfig config)
{
   // If minor version is specified then use EGL_CONTEXT_MAJOR_VERSION_KHR / EGL_CONTEXT_MINOR_VERSION_KHR
   // otherwise use EGL_CONTEXT_CLIENT_VERSION

   int majorGLVersion = eglContextGLESVersion.getMajorVersion();
   int minorGLVersion = eglContextGLESVersion.getMinorVersion();

   int majorMinorAttribList[] = new int[]{ EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR, majorGLVersion,
    EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR, minorGLVersion, EGL14.EGL_NONE };

   int majorAttribList[] = new int[]{ EGL14.EGL_CONTEXT_CLIENT_VERSION, majorGLVersion, EGL14.EGL_NONE };

   EGLContext context = null;

   if (minorGLVersion != 0)
   {
      context = EGL14.eglCreateContext(display, config, EGL14.EGL_NO_CONTEXT,
       majorGLVersion != 0 ? majorMinorAttribList : null, 0);
   }

   if (context == null || context.equals(EGL14.EGL_NO_CONTEXT))
   {
      Log.d(s_TAG, "DefaultContextFactory - createContext: Could create requested context: "
       +eglContextGLESVersion);

      Log.d(s_TAG, "DefaultContextFactory - createContest: " +
       "Attempting to create context based on major GLES version: " +majorGLVersion);

      context = EGL14.eglCreateContext(display, config, EGL14.EGL_NO_CONTEXT,
       majorGLVersion != 0 ? majorAttribList : null, 0);

      minorGLVersion = 0;
   }

   int clientValue[] = new int[1];

   EGL14.eglQueryContext(display, context, EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR, clientValue, 0);
   if (EGL14.eglGetError() != EGL14.EGL_BAD_ATTRIBUTE)
   {
      majorGLVersion = clientValue[0];
   }

   EGL14.eglQueryContext(display, context, EGLExt.EGL_CONTEXT_MINOR_VERSION_KHR, clientValue, 0);
   if (EGL14.eglGetError() != EGL14.EGL_BAD_ATTRIBUTE)
   {
      minorGLVersion = clientValue[0];
   }

   GLSurfaceView2.this.actualEGLContextGLESVersion = AndroidGLESUtil.getGLVersion(majorGLVersion, minorGLVersion);

   return context;
}