Package com.banuba.sdk.internal.gl
Class EglCore
java.lang.Object
com.banuba.sdk.internal.gl.EglCore
Core EGL state (display, context, config).
The EGLContext must only be attached to one thread at a time. This class is not thread-safe.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constructor flag: surface must be recordable.static final int
Constructor flag: ask for GLES3, fall back to GLES2 if not available. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionandroid.opengl.EGLSurface
createOffscreenSurface
(int width, int height) Creates an EGL surface associated with an offscreen buffer.android.opengl.EGLSurface
createWindowSurface
(Object surface) Creates an EGL surface associated with a Surface.protected void
finalize()
android.opengl.EGLContext
int
Returns the GLES version this context is configured for (currently 2 or 3).boolean
isCurrent
(android.opengl.EGLSurface eglSurface) Returns true if our context and the specified surface are current.static void
logCurrent
(String msg) Writes the current display, context, and surface to the logvoid
makeCurrent
(android.opengl.EGLSurface eglSurface) Makes our EGL context current, using the supplied surface for both "draw" and "read".void
makeCurrent
(android.opengl.EGLSurface drawSurface, android.opengl.EGLSurface readSurface) Makes our EGL context current, using the supplied "draw" and "read" surfaces.void
Makes no context current.queryString
(int what) Queries a string value.int
querySurface
(android.opengl.EGLSurface eglSurface, int what) Performs a simple surface query.void
release()
Discards all resources held by this class, notably the EGL context.void
releaseSurface
(android.opengl.EGLSurface eglSurface) Destroys the specified surface.void
setPresentationTime
(android.opengl.EGLSurface eglSurface, long nsecs) Sends the presentation time stamp to EGL.boolean
swapBuffers
(android.opengl.EGLSurface eglSurface) Calls eglSwapBuffers.
-
Field Details
-
FLAG_RECORDABLE
public static final int FLAG_RECORDABLEConstructor flag: surface must be recordable. This discourages EGL from using a pixel format that cannot be converted efficiently to something usable by the video encoder.- See Also:
-
FLAG_TRY_GLES3
public static final int FLAG_TRY_GLES3Constructor flag: ask for GLES3, fall back to GLES2 if not available. Without this flag, GLES2 is used.- See Also:
-
-
Constructor Details
-
EglCore
public EglCore()Prepares EGL display and context.Equivalent to EglCore(null, 0).
-
EglCore
public EglCore(android.opengl.EGLContext sharedContext, int flags) Prepares EGL display and context.- Parameters:
sharedContext
- The context to share, or null if sharing is not desired.flags
- Configuration bit flags, e.g. FLAG_RECORDABLE.
-
-
Method Details
-
getEGLContext
public android.opengl.EGLContext getEGLContext() -
release
public void release()Discards all resources held by this class, notably the EGL context. This must be called from the thread where the context was created.On completion, no context will be current.
-
finalize
-
releaseSurface
public void releaseSurface(android.opengl.EGLSurface eglSurface) Destroys the specified surface. Note the EGLSurface won't actually be destroyed if it's still current in a context. -
createWindowSurface
Creates an EGL surface associated with a Surface.If this is destined for MediaCodec, the EGLConfig should have the "recordable" attribute.
-
createOffscreenSurface
public android.opengl.EGLSurface createOffscreenSurface(int width, int height) Creates an EGL surface associated with an offscreen buffer. -
makeCurrent
public void makeCurrent(android.opengl.EGLSurface eglSurface) Makes our EGL context current, using the supplied surface for both "draw" and "read". -
makeCurrent
public void makeCurrent(android.opengl.EGLSurface drawSurface, android.opengl.EGLSurface readSurface) Makes our EGL context current, using the supplied "draw" and "read" surfaces. -
makeNothingCurrent
public void makeNothingCurrent()Makes no context current. -
swapBuffers
public boolean swapBuffers(android.opengl.EGLSurface eglSurface) Calls eglSwapBuffers. Use this to "publish" the current frame.- Returns:
- false on failure
-
setPresentationTime
public void setPresentationTime(android.opengl.EGLSurface eglSurface, long nsecs) Sends the presentation time stamp to EGL. Time is expressed in nanoseconds. -
isCurrent
public boolean isCurrent(android.opengl.EGLSurface eglSurface) Returns true if our context and the specified surface are current. -
querySurface
public int querySurface(android.opengl.EGLSurface eglSurface, int what) Performs a simple surface query. -
queryString
Queries a string value. -
getGlVersion
public int getGlVersion()Returns the GLES version this context is configured for (currently 2 or 3). -
logCurrent
Writes the current display, context, and surface to the log
-