GLRenderer.RenderCallback


public interface GLRenderer.RenderCallback

Known direct subclasses
FrameBufferRenderer

GLRenderer.RenderCallback implementation that renders content into a frame buffer object backed by a HardwareBuffer object


Interface used for creating an EGLSurface with a user defined configuration from the provided surface as well as a callback used to render content into the surface for a given frame

Summary

Public methods

abstract void

Callback used to issue OpenGL drawing commands into the EGLSurface created in onSurfaceCreated.

default EGLSurface
@WorkerThread
onSurfaceCreated(
    @NonNull EGLSpec spec,
    @NonNull EGLConfig config,
    @NonNull Surface surface,
    int width,
    int height
)

Used to create a corresponding EGLSurface from the provided android.view.Surface instance.

Public methods

onDrawFrame

Added in 1.0.2
@WorkerThread
abstract void onDrawFrame(@NonNull EGLManager eglManager)

Callback used to issue OpenGL drawing commands into the EGLSurface created in onSurfaceCreated. This EGLSurface is guaranteed to be current before this callback is invoked and EGLManager.swapAndFlushBuffers will be invoked afterwards. If additional scratch EGLSurfaces are used here it is up to the implementation of this method to ensure that the proper surfaces are made current and the appropriate swap buffers call is made

This method is invoked on the backing thread

Parameters
@NonNull EGLManager eglManager

Handle to EGL dependencies

onSurfaceCreated

Added in 1.0.2
@WorkerThread
default EGLSurface onSurfaceCreated(
    @NonNull EGLSpec spec,
    @NonNull EGLConfig config,
    @NonNull Surface surface,
    int width,
    int height
)

Used to create a corresponding EGLSurface from the provided android.view.Surface instance. This enables consumers to configure the corresponding EGLSurface they wish to render into. The EGLSurface created here is guaranteed to be the current surface before onDrawFrame is called. That is, implementations of onDrawFrame do not need to call eglMakeCurrent on this EGLSurface.

This method is invoked on the GL thread.

The default implementation will create a window surface with EGL_WIDTH and EGL_HEIGHT set to width and height respectively. Implementations can override this method to provide additional EGLConfigAttributes for this surface (ex. EGL14.EGL_SINGLE_BUFFER.

Implementations can return null to indicate the default surface should be used. This is helpful in situations where content is to be rendered within a frame buffer object instead of to an EGLSurface

Parameters
@NonNull EGLSpec spec

EGLSpec used to create the corresponding EGLSurface

@NonNull EGLConfig config

EGLConfig used to create the corresponding EGLSurface

@NonNull Surface surface

android.view.Surface used to create an EGLSurface from

int width

Desired width of the surface to create

int height

Desired height of the surface to create