library / com.otaliastudios.opengl.surface / EglSurface

EglSurface

abstract class EglSurface

Common base class for EGL surfaces. There can be multiple base surfaces associated with a single EglCore object.

Constructors

<init>

EglSurface(eglCore: EglCore, eglSurface: EGLSurface)

Common base class for EGL surfaces. There can be multiple base surfaces associated with a single EglCore object.

Properties

eglCore

var eglCore: EglCore

eglSurface

var eglSurface: EGLSurface

Functions

getHeight

fun getHeight(): Int

Returns the surface's height, in pixels.

getWidth

fun getWidth(): Int

Returns the surface's width, in pixels.

isCurrent

fun isCurrent(): Boolean

Whether this surface is current on the attached EglCore.

makeCurrent

fun makeCurrent(): Unit

Makes our EGL context and surface current.

fun makeCurrent(readSurface: EglSurface): Unit

Makes our EGL context and surface current for drawing, using the supplied surface for reading.

makeNothingCurrent

fun makeNothingCurrent(): Unit

Makes no surface current for the attached eglCore.

release

open fun release(): Unit

Release the EGL surface.

setHeight

fun setHeight(height: Int): Unit

Can be called by subclasses whose height is guaranteed to never change, so we can cache this value. For window surfaces, this should not be called.

setPresentationTime

fun setPresentationTime(nsecs: Long): Unit

Sends the presentation time stamp to EGL. nsecs is the timestamp in nanoseconds.

setWidth

fun setWidth(width: Int): Unit

Can be called by subclasses whose width is guaranteed to never change, so we can cache this value. For window surfaces, this should not be called.

toByteArray

fun toByteArray(format: CompressFormat = Bitmap.CompressFormat.PNG): ByteArray

Saves the EGL surface to given format. Expects that this object's EGL surface is current.

toFile

fun toFile(file: File, format: CompressFormat = Bitmap.CompressFormat.PNG): Unit

Saves the EGL surface to a file. Expects that this object's EGL surface is current.

toOutputStream

fun toOutputStream(stream: OutputStream, format: CompressFormat = Bitmap.CompressFormat.PNG): Unit

Saves the EGL surface to the given output stream. Expects that this object's EGL surface is current.

Companion Object Properties

TAG

val TAG: String

Inheritors

EglOffscreenSurface

open class EglOffscreenSurface : EglSurface

A pbuffer EGL surface.

EglWindowSurface

open class EglWindowSurface : EglSurface

Recordable EGL window surface. It's good practice to explicitly release() the surface, preferably from a finally block.