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

The following examples show how to use android.opengl.EGL14#eglCreateWindowSurface() . 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 9 votes vote down vote up
private EGLSurface createWindowSurface(final Object nativeWindow) {
    LogUtil.i(TAG, "createWindowSurface:nativeWindow=" + nativeWindow);

    final int[] surfaceAttribs = {
        EGL14.EGL_NONE
    };
    EGLSurface result = null;
    try {
        result =
            EGL14.eglCreateWindowSurface(mEglDisplay, mEglConfig, nativeWindow, surfaceAttribs,
                0);
    } catch (final IllegalArgumentException e) {
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example 2
Source File: EglCore.java    From MockCamera with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an EGL surface associated with a Surface.
 * <p/>
 * If this is destined for MediaCodec, the EGLConfig should have the "recordable" attribute.
 */
public EGLSurface createWindowSurface(Object surface) {
    if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
        throw new RuntimeException("invalid surface: " + surface);
    }

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    EGLSurface eglSurface = EGL14.eglCreateWindowSurface(eGLDisplay, eGLConfig, surface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
    return eglSurface;
}
 
Example 3
Source File: EglCore.java    From Lassi-Android with MIT License 6 votes vote down vote up
/**
 * Creates an EGL surface associated with a Surface.
 * <p>
 * If this is destined for MediaCodec, the EGLConfig should have the "recordable" attribute.
 */
public EGLSurface createWindowSurface(Object surface) {
    if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
        throw new RuntimeException("invalid surface: " + surface);
    }

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
    return eglSurface;
}
 
Example 4
Source File: EglCore.java    From AndroidPlayground with MIT License 6 votes vote down vote up
/**
 * Creates an EGL surface associated with a Surface.
 * <p>
 * If this is destined for MediaCodec, the EGLConfig should have the "recordable" attribute.
 */
public EGLSurface createWindowSurface(Object surface) {
    if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
        throw new RuntimeException("invalid surface: " + surface);
    }

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
    return eglSurface;
}
 
Example 5
Source File: EglCore.java    From LiveVideoBroadcaster with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an EGL surface associated with a Surface.
 * <p>
 * If this is destined for MediaCodec, the EGLConfig should have the "recordable" attribute.
 */
public EGLSurface createWindowSurface(Object surface) {
    if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
        throw new RuntimeException("invalid surface: " + surface);
    }

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    EGLSurface eglSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, surface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
    return eglSurface;
}
 
Example 6
Source File: EGLBase.java    From AudioVideoRecordingSample with Apache License 2.0 5 votes vote down vote up
private EGLSurface createWindowSurface(final Object nativeWindow) {
	if (DEBUG) Log.v(TAG, "createWindowSurface:nativeWindow=" + nativeWindow);

       final int[] surfaceAttribs = {
               EGL14.EGL_NONE
       };
	EGLSurface result = null;
	try {
		result = EGL14.eglCreateWindowSurface(mEglDisplay, mEglConfig, nativeWindow, surfaceAttribs, 0);
	} catch (final IllegalArgumentException e) {
		Log.e(TAG, "eglCreateWindowSurface", e);
	}
	return result;
}
 
Example 7
Source File: EGLBase.java    From MegviiFacepp-Android-SDK with Apache License 2.0 5 votes vote down vote up
private EGLSurface createWindowSurface(final Object nativeWindow) {
	if (DEBUG) Log.v(TAG, "createWindowSurface:nativeWindow=" + nativeWindow);

       final int[] surfaceAttribs = {
               EGL14.EGL_NONE
       };
	EGLSurface result = null;
	try {
		result = EGL14.eglCreateWindowSurface(mEglDisplay, mEglConfig, nativeWindow, surfaceAttribs, 0);
	} catch (final IllegalArgumentException e) {
		Log.e(TAG, "eglCreateWindowSurface", e);
	}
	return result;
}
 
Example 8
Source File: EglBase14.java    From VideoCRE with MIT License 5 votes vote down vote up
private void createSurfaceInternal(Object surface) {
  if (!(surface instanceof Surface) && !(surface instanceof SurfaceTexture)) {
    throw new IllegalStateException("Input must be either a Surface or SurfaceTexture");
  }
  checkIsNotReleased();
  if (eglSurface != EGL14.EGL_NO_SURFACE) {
    throw new RuntimeException("Already has an EGLSurface");
  }
  int[] surfaceAttribs = {EGL14.EGL_NONE};
  eglSurface = EGL14.eglCreateWindowSurface(eglDisplay, eglConfig, surface, surfaceAttribs, 0);
  if (eglSurface == EGL14.EGL_NO_SURFACE) {
    throw new RuntimeException(
        "Failed to create window surface: 0x" + Integer.toHexString(EGL14.eglGetError()));
  }
}
 
Example 9
Source File: InputSurface.java    From AndroidVideoSamples with Apache License 2.0 5 votes vote down vote up
/**
 * Prepares EGL. We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup() {
   mEGLDisplay = EGL14.eglGetDisplay( EGL14.EGL_DEFAULT_DISPLAY );
   if ( mEGLDisplay == EGL14.EGL_NO_DISPLAY ) {
      throw new RuntimeException( "unable to get EGL14 display" );
   }
   int[] version = new int[2];
   if ( !EGL14.eglInitialize( mEGLDisplay, version, 0, version, 1 ) ) {
      mEGLDisplay = null;
      throw new RuntimeException( "unable to initialize EGL14" );
   }
   // Configure EGL for pbuffer and OpenGL ES 2.0. We want enough RGB bits
   // to be able to tell if the frame is reasonable.
   int[] attribList = { EGL14.EGL_RED_SIZE, 8, EGL14.EGL_GREEN_SIZE, 8, EGL14.EGL_BLUE_SIZE, 8, EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RECORDABLE_ANDROID, 1, EGL14.EGL_NONE };
   EGLConfig[] configs = new EGLConfig[1];
   int[] numConfigs = new int[1];
   if ( !EGL14.eglChooseConfig( mEGLDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0 ) ) {
      throw new RuntimeException( "unable to find RGB888+recordable ES2 EGL config" );
   }
   // Configure context for OpenGL ES 2.0.
   int[] attrib_list = { EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE };
   mEGLContext = EGL14.eglCreateContext( mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0 );
   checkEglError( "eglCreateContext" );
   if ( mEGLContext == null ) {
      throw new RuntimeException( "null context" );
   }
   // Create a window surface, and attach it to the Surface we received.
   int[] surfaceAttribs = { EGL14.EGL_NONE };
   mEGLSurface = EGL14.eglCreateWindowSurface( mEGLDisplay, configs[0], mSurface, surfaceAttribs, 0 );
   checkEglError( "eglCreateWindowSurface" );
   if ( mEGLSurface == null ) {
      throw new RuntimeException( "surface was null" );
   }
}
 
Example 10
Source File: EGLBase.java    From UVCCameraZxing with Apache License 2.0 5 votes vote down vote up
private EGLSurface createWindowSurface(final Object nativeWindow) {
	if (DEBUG) Log.v(TAG, "createWindowSurface:");

       final int[] surfaceAttribs = {
               EGL14.EGL_NONE
       };
	EGLSurface result = null;
	try {
		result = EGL14.eglCreateWindowSurface(mEglDisplay, mEglConfig, nativeWindow, surfaceAttribs, 0);
	} catch (final IllegalArgumentException e) {
		Log.e(TAG, "eglCreateWindowSurface", e);
	}
	return result;
}
 
Example 11
Source File: SurfaceManager.java    From libstreaming with Apache License 2.0 4 votes vote down vote up
/**
 * Prepares EGL.  We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup() {
	mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
	if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
		throw new RuntimeException("unable to get EGL14 display");
	}
	int[] version = new int[2];
	if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
		throw new RuntimeException("unable to initialize EGL14");
	}

	// Configure EGL for recording and OpenGL ES 2.0.
	int[] attribList;
	if (mEGLSharedContext == null) {
		attribList = new int[] {
				EGL14.EGL_RED_SIZE, 8,
				EGL14.EGL_GREEN_SIZE, 8,
				EGL14.EGL_BLUE_SIZE, 8,
				EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
				EGL14.EGL_NONE
		};
	} else {
		attribList = new int[] {
				EGL14.EGL_RED_SIZE, 8,
				EGL14.EGL_GREEN_SIZE, 8,
				EGL14.EGL_BLUE_SIZE, 8,
				EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
				EGL_RECORDABLE_ANDROID, 1,
				EGL14.EGL_NONE
		};	
	}
	EGLConfig[] configs = new EGLConfig[1];
	int[] numConfigs = new int[1];
	EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
			numConfigs, 0);
	checkEglError("eglCreateContext RGB888+recordable ES2");

	// Configure context for OpenGL ES 2.0.
	int[] attrib_list = {
			EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
			EGL14.EGL_NONE
	};

	if (mEGLSharedContext == null) {
		mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0);
	} else {
		mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], mEGLSharedContext, attrib_list, 0);
	}
	checkEglError("eglCreateContext");

	// Create a window surface, and attach it to the Surface we received.
	int[] surfaceAttribs = {
			EGL14.EGL_NONE
	};
	mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
			surfaceAttribs, 0);
	checkEglError("eglCreateWindowSurface");

       GLES20.glDisable(GLES20.GL_DEPTH_TEST);
       GLES20.glDisable(GLES20.GL_CULL_FACE);
	
}
 
Example 12
Source File: InputSurface.java    From phoenix with Apache License 2.0 4 votes vote down vote up
/**
 * Prepares EGL.  We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup() {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
        mEGLDisplay = null;
        throw new RuntimeException("unable to initialize EGL14");
    }
    // Configure EGL for recordable and OpenGL ES 2.0.  We want enough RGB bits
    // to minimize artifacts from possible YUV conversion.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
    }
    // Configure context for OpenGL ES 2.0.
    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };
    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT,
            attrib_list, 0);
    checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new RuntimeException("null context");
    }
    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (mEGLSurface == null) {
        throw new RuntimeException("surface was null");
    }
}
 
Example 13
Source File: InputSurface.java    From SimpleVideoEditor with Apache License 2.0 4 votes vote down vote up
/**
 * Prepares EGL.  We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup() {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
        mEGLDisplay = null;
        throw new RuntimeException("unable to initialize EGL14");
    }
    // Configure EGL for pbuffer and OpenGL ES 2.0.  We want enough RGB bits
    // to be able to tell if the frame is reasonable.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
    }
    // Configure context for OpenGL ES 2.0.
    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };
    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT,
            attrib_list, 0);
    checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new RuntimeException("null context");
    }
    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (mEGLSurface == null) {
        throw new RuntimeException("surface was null");
    }
}
 
Example 14
Source File: CameraToMpegTest.java    From Android-MediaCodec-Examples with Apache License 2.0 4 votes vote down vote up
/**
 * Prepares EGL.  We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup() {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
        throw new RuntimeException("unable to initialize EGL14");
    }

    // Configure EGL for recording and OpenGL ES 2.0.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0);
    checkEglError("eglCreateContext RGB888+recordable ES2");

    // Configure context for OpenGL ES 2.0.
    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };
    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT,
            attrib_list, 0);
    checkEglError("eglCreateContext");

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
}
 
Example 15
Source File: EncoderSurface.java    From Mp4Composer-android with MIT License 4 votes vote down vote up
/**
 * Prepares EGL.  We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup(EGLContext shareContext) {
    eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (eglDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) {
        eglDisplay = null;
        throw new RuntimeException("unable to initialize EGL14");
    }
    // Configure EGL for recordable and OpenGL ES 2.0.  We want enough RGB bits
    // to minimize artifacts from possible YUV conversion.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(eglDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
    }
    // Configure context for OpenGL ES 2.0.
    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };
    eglContext = EGL14.eglCreateContext(eglDisplay, configs[0], shareContext != null ? shareContext : EGL14.EGL_NO_CONTEXT,
            attrib_list, 0);
    checkEglError("eglCreateContext");
    if (eglContext == null) {
        throw new RuntimeException("null context");
    }
    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    eglSurface = EGL14.eglCreateWindowSurface(eglDisplay, configs[0], surface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
}
 
Example 16
Source File: InputSurface.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Prepares EGL.  We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup() throws TranscodingException {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new TranscodingException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
        mEGLDisplay = null;
        throw new TranscodingException("unable to initialize EGL14");
    }

    // Configure EGL for pbuffer and OpenGL ES 2.0.  We want enough RGB bits
    // to be able to tell if the frame is reasonable.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        throw new TranscodingException("unable to find RGB888+recordable ES2 EGL config");
    }

    // Configure context for OpenGL ES 2.0.
    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };
    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT,
            attrib_list, 0);
    checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new TranscodingException("null context");
    }

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (mEGLSurface == null) {
        throw new TranscodingException("surface was null");
    }
}
 
Example 17
Source File: GLMovieRecorder.java    From PhotoMovie with Apache License 2.0 4 votes vote down vote up
/**
 * Prepares EGL.  We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup() {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
        throw new RuntimeException("unable to initialize EGL14");
    }

    // Configure EGL for recording and OpenGL ES 2.0.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_ALPHA_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    android.opengl.EGLConfig[] configs = new android.opengl.EGLConfig[1];
    int[] numConfigs = new int[1];
    EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0);
    checkEglError("eglCreateContext RGB888+recordable ES2");

    // Configure context for OpenGL ES 2.0.
    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };
    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT,
            attrib_list, 0);
    checkEglError("eglCreateContext");

    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
}
 
Example 18
Source File: InputSurface.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void eglSetup() {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
        mEGLDisplay = null;
        throw new RuntimeException("unable to initialize EGL14");
    }

    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
    }

    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };

    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0);
    checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new RuntimeException("null context");
    }

    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (mEGLSurface == null) {
        throw new RuntimeException("surface was null");
    }
}
 
Example 19
Source File: InputSurface.java    From phoenix with Apache License 2.0 4 votes vote down vote up
/**
 * Prepares EGL.  We want a GLES 2.0 context and a surface that supports recording.
 */
private void eglSetup() {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
        mEGLDisplay = null;
        throw new RuntimeException("unable to initialize EGL14");
    }
    // Configure EGL for recordable and OpenGL ES 2.0.  We want enough RGB bits
    // to minimize artifacts from possible YUV conversion.
    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
    }
    // Configure context for OpenGL ES 2.0.
    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };
    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT,
            attrib_list, 0);
    checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new RuntimeException("null context");
    }
    // Create a window surface, and attach it to the Surface we received.
    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (mEGLSurface == null) {
        throw new RuntimeException("surface was null");
    }
}
 
Example 20
Source File: InputSurface.java    From VideoProcessor with Apache License 2.0 4 votes vote down vote up
private void eglSetup() {
    mEGLDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
    if (mEGLDisplay == EGL14.EGL_NO_DISPLAY) {
        throw new RuntimeException("unable to get EGL14 display");
    }
    int[] version = new int[2];
    if (!EGL14.eglInitialize(mEGLDisplay, version, 0, version, 1)) {
        mEGLDisplay = null;
        throw new RuntimeException("unable to initialize EGL14");
    }

    int[] attribList = {
            EGL14.EGL_RED_SIZE, 8,
            EGL14.EGL_GREEN_SIZE, 8,
            EGL14.EGL_BLUE_SIZE, 8,
            EGL14.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_RECORDABLE_ANDROID, 1,
            EGL14.EGL_NONE
    };
    EGLConfig[] configs = new EGLConfig[1];
    int[] numConfigs = new int[1];
    if (!EGL14.eglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.length,
            numConfigs, 0)) {
        throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
    }

    int[] attrib_list = {
            EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL14.EGL_NONE
    };

    mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0);
    checkEglError("eglCreateContext");
    if (mEGLContext == null) {
        throw new RuntimeException("null context");
    }

    int[] surfaceAttribs = {
            EGL14.EGL_NONE
    };
    mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
            surfaceAttribs, 0);
    checkEglError("eglCreateWindowSurface");
    if (mEGLSurface == null) {
        throw new RuntimeException("surface was null");
    }
}