EGLManager


class EGLManager


Class responsible for configuration of EGL related resources. This includes initialization of the corresponding EGL Display as well as EGL Context, among other EGL related facilities.

Summary

Public constructors

EGLManager(eglSpec: EGLSpec)

Public functions

EGLContext

Creates an EGLContext from the given EGLConfig returning null if the context could not be created

Unit

Initialize the EGLManager.

Boolean
isExtensionSupported(extensionName: String)

Determines whether the extension with the provided name is supported.

EGLConfig?
loadConfig(configAttributes: EGLConfigAttributes)

Attempt to load an EGLConfig instance from the given EGLConfigAttributes.

Boolean
makeCurrent(drawSurface: EGLSurface, readSurface: EGLSurface)

Binds the current context to the given draw and read surfaces.

Unit

Release the resources allocated by EGLManager.

Unit

Post EGL surface color buffer to a native window.

Public properties

EGLSurface

Returns the current surface used for drawing pixel content

EGLSurface

Returns the current surface used for reading back or copying pixels

EGLSurface

Returns the default surface.

EGLConfig?

Returns the EGLConfig used to load the current EGLContext.

EGLContext?

Returns the current EGLContext.

EGLSpec
EGLVersion

Returns the EGL version that is supported.

Public constructors

EGLManager

Added in 1.0.2
EGLManager(eglSpec: EGLSpec = EGLSpec.V14)

Public functions

createContext

Added in 1.0.2
fun createContext(config: EGLConfig): EGLContext

Creates an EGLContext from the given EGLConfig returning null if the context could not be created

Throws
androidx.graphics.opengl.egl.EGLException

if the default surface could not be made current after context creation

initialize

Added in 1.0.2
fun initialize(): Unit

Initialize the EGLManager. This initializes the default display as well as queries the supported extensions

isExtensionSupported

Added in 1.0.2
fun isExtensionSupported(extensionName: String): Boolean

Determines whether the extension with the provided name is supported. The string provided is expected to be one of the named extensions defined within the OpenGL extension documentation.

See EGLExt for additional documentation for given extension name constants and descriptions.

The set of supported extensions is configured after initialize is invoked. Attempts to query support for any extension beforehand will return false.

loadConfig

Added in 1.0.2
fun loadConfig(configAttributes: EGLConfigAttributes): EGLConfig?

Attempt to load an EGLConfig instance from the given EGLConfigAttributes. If the EGLConfig could not be loaded this returns null

makeCurrent

Added in 1.0.2
fun makeCurrent(drawSurface: EGLSurface, readSurface: EGLSurface = drawSurface): Boolean

Binds the current context to the given draw and read surfaces. The draw surface is used for all operations except for any pixel data read back or copy operations which are taken from the read surface.

The same EGLSurface may be specified for both draw and read surfaces.

If the context is not previously configured, the only valid parameters for the draw and read surfaces is EGL14.EGL_NO_SURFACE. This is useful to make sure there is always a surface specified and to release the current context without assigning a new one.

See https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglMakeCurrent.xhtml

Parameters
drawSurface: EGLSurface

Surface used for all operations that involve writing pixel information

readSurface: EGLSurface = drawSurface

Surface used for pixel data read back or copy operations. By default this is the same as drawSurface

release

Added in 1.0.2
fun release(): Unit

Release the resources allocated by EGLManager. This will destroy the corresponding EGLContext instance if it was previously initialized. The configured EGLVersion as well as EGLExtensions

swapAndFlushBuffers

Added in 1.0.2
fun swapAndFlushBuffers(): Unit

Post EGL surface color buffer to a native window. If the current drawing surface is single buffered this will flush the buffer

Public properties

currentDrawSurface

Added in 1.0.2
val currentDrawSurfaceEGLSurface

Returns the current surface used for drawing pixel content

currentReadSurface

Added in 1.0.2
val currentReadSurfaceEGLSurface

Returns the current surface used for reading back or copying pixels

defaultSurface

Added in 1.0.2
val defaultSurfaceEGLSurface

Returns the default surface. This can be an offscreen pixel buffer surface or EGL14.EGL_NO_SURFACE if the surfaceless context extension is supported.

eglConfig

Added in 1.0.2
val eglConfigEGLConfig?

Returns the EGLConfig used to load the current EGLContext. This is configured after createContext is invoked.

eglContext

Added in 1.0.2
val eglContextEGLContext?

Returns the current EGLContext. This parameter is configured after initialize is invoked

eglSpec

Added in 1.0.2
val eglSpecEGLSpec

eglVersion

Added in 1.0.2
val eglVersionEGLVersion

Returns the EGL version that is supported. This parameter is configured after initialize is invoked.