GLRenderer.RenderTarget
class GLRenderer.RenderTarget
Handle to a android.view.Surface that is given to GLRenderer to handle rendering.
Summary
Public functions |
|
|---|---|
Unit |
detach(Removes the corresponding |
Boolean |
Determines if the current RenderTarget is attached to GLRenderer. |
Unit |
requestRender(Request that this |
Unit |
resize(Resize the RenderTarget to the specified width and height. |
Public functions
detach
fun detach(
cancelPending: Boolean,
onDetachComplete: ((GLRenderer.RenderTarget) -> Unit)? = null
): Unit
Removes the corresponding RenderTarget from management of the GLThread. This destroys the EGLSurface associated with this surface and subsequent requests to render into the surface with the provided token are ignored.
If the cancelPending flag is set to true, any queued request to render that has not started yet is cancelled. However, if this is invoked in the middle of the frame being rendered, it will continue to process the current frame.
Additionally if this flag is false, all pending requests to render will be processed before the RenderTarget is detached.
This is a convenience method around GLRenderer.detach
Note the detach operation will only occur if the RenderTarget is attached, that is isAttached returns true. If the RenderTarget is detached or the GLRenderer that created this RenderTarget is stopped, this is a no-op.
isAttached
fun isAttached(): Boolean
Determines if the current RenderTarget is attached to GLRenderer. This is true until detach has been called. If the RenderTarget is no longer in an attached state (i.e. this returns false). Subsequent calls to requestRender will be ignored.
requestRender
fun requestRender(
@WorkerThread onRenderComplete: ((GLRenderer.RenderTarget) -> Unit)? = null
): Unit
Request that this RenderTarget should have its contents redrawn. This consumes an optional callback that is invoked on the backing thread when the rendering is completed.
Note the render operation will only occur if the RenderTarget is attached, that is isAttached returns true. If the RenderTarget is detached or the GLRenderer that created this RenderTarget is stopped, this is a no-op.
| Parameters | |
|---|---|
@WorkerThread onRenderComplete: ((GLRenderer.RenderTarget) -> Unit)? = null |
Optional callback called on the backing thread when rendering is finished |
resize
fun resize(
width: Int,
height: Int,
@WorkerThread onResizeComplete: ((GLRenderer.RenderTarget) -> Unit)? = null
): Unit
Resize the RenderTarget to the specified width and height. This will destroy the EGLSurface created by RenderCallback.onSurfaceCreated and invoke it again with the updated dimensions. An optional callback is invoked on the backing thread after the resize operation is complete
Note the resize operation will only occur if the RenderTarget is attached, that is isAttached returns true. If the RenderTarget is detached or the GLRenderer that created this RenderTarget is stopped, this is a no-op.
| Parameters | |
|---|---|
width: Int |
New target width to resize the RenderTarget |
height: Int |
New target height to resize the RenderTarget |
@WorkerThread onResizeComplete: ((GLRenderer.RenderTarget) -> Unit)? = null |
Optional callback invoked after the resize is complete |