Java Code Examples for javax.microedition.khronos.egl.EGL10#eglGetCurrentContext()

The following examples show how to use javax.microedition.khronos.egl.EGL10#eglGetCurrentContext() . 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: WindowSurface.java    From OpenGLESRecorder with Apache License 2.0 5 votes vote down vote up
public WindowSurface(EGLConfig eglConfig, Surface encodeSurface) {
    mEglConfig = eglConfig;
    mEgl= (EGL10) EGLContext.getEGL();
    mEglContext = mEgl.eglGetCurrentContext();
    mEglDisplay = mEgl.eglGetCurrentDisplay();
    mWindowSurface = mEgl.eglGetCurrentSurface(EGL10.EGL_DRAW);
    mEncoderSurface = createWindowSurface(encodeSurface);
    Log.i(TAG, "eglCreateWindowSurface:" + mEgl.eglGetError());
}
 
Example 2
Source File: EGLBase10.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 現在のスレッドの既存のレンダリングコンテキストがあればそれを共有して
 * 新しいレンダリングコンテキストを生成する
 * 既存のレンダリングコンテキストが存在していなければ独立したレンダリングコンテキストを
 * 生成する
 * @param maxClientVersion
 * @param withDepthBuffer
 * @param stencilBits
 * @param isRecordable
 * @return
 */
/*package*/ static EGLBase createFromCurrentImpl(final int maxClientVersion,
	final boolean withDepthBuffer, final int stencilBits, final boolean isRecordable) {

	Context context = null;
	final EGL10 egl10 = (EGL10)EGLContext.getEGL();
	final EGLContext currentContext = egl10.eglGetCurrentContext();
	final EGLSurface currentSurface = egl10.eglGetCurrentSurface(EGL10.EGL_DRAW);
	if ((currentContext != null) && (currentSurface != null)) {
		context = wrap(currentContext);
	}
	return new EGLBase10(maxClientVersion, context, withDepthBuffer, stencilBits, isRecordable);
}
 
Example 3
Source File: UnityPlayer.java    From HoloKilo with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void executeGLThreadJobs() {
    // Here it is certain that the Unity renderer is active.
    // Attempt to find the GL context to share with the holokilo
    // opengl context. The two contexts run side by side, the unity
    // context runs in background and passes its results to holokilo.
    EGL10 egl = ((EGL10)EGLContext.getEGL());
    final EGLContext con = egl.eglGetCurrentContext();

    if (majorVersionUnity == -1 && !con.equals(EGL10.EGL_NO_CONTEXT)) {
        String versionString = GLES10.glGetString(GLES10.GL_VERSION);

        for (int i = 0; i < versionString.length(); i++) {
            int cha = versionString.charAt(i);
            if (Character.isDigit(cha)) {
                majorVersionUnity = Character.getNumericValue(cha);
                break;
            }
        }
        Log.d(Config.TAG, "GL Version: " + majorVersionUnity);
    }

    // Rescale the unity surface to 1x1 pixel to hide,
    // but keep it regular sized to show the unity splashscreen,
    // in accordance with their license agreement.
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (con.equals(EGL10.EGL_NO_CONTEXT)) {
                // no current context.
            } else if (surface == null) {
                surface = new UnitySurfaceView(activity, con, majorVersionUnity);

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    // Do nothing
                }

                activity.getLayout().addView(surface);
                UnityPlayer.this.setLayoutParams(layoutParams);
            } else if (surface.getEglContext().hashCode() != con.hashCode()) {
                removeView(surface);
                surface.onPause();
                activity.getLayout().removeView(surface);

                surface = new UnitySurfaceView(activity, con, majorVersionUnity);
                activity.getLayout().addView(surface, 0);
            }
        }
    });
}