EGLHelper
Declaration
public class Strawberry.Android.Helpers.EGLHelper
Properties
HasContext
bool HasContext { get }
HasDisplay
bool HasDisplay { get }
IsInitialized
bool IsInitialized { get }
ContextWasPreserved
True if the context survived the last surface destruction. Check this after BindSurface to know if GPU resources need restoration.
bool ContextWasPreserved { get }
Methods
Init
Full initialization — creates display, config, context, and surface. Call this on the game loop thread only.
void Init(Surface surface)
Parameters:
| Name | Type | Description |
|---|---|---|
surface |
Android.Views.Surface |
MakeCurrent
void MakeCurrent()
SwapBuffers
void SwapBuffers()
NotifySurfaceDestroyed
Called from the UI thread's surfaceDestroyed. Does NOT touch EGL — just sets a flag for the game loop thread. The game loop thread will see running=false and stop itself.
void NotifySurfaceDestroyed()
NotifySurfaceCreated
Called from the UI thread's surfaceCreated. Stores the new surface for the game loop thread to consume. Does NOT touch EGL — no MakeCurrent on the UI thread.
void NotifySurfaceCreated(Surface surface)
Parameters:
| Name | Type | Description |
|---|---|---|
surface |
Android.Views.Surface |
ConsumePendingSurface
Returns the pending surface and clears it. Called on the game loop thread when doing a full Init().
Surface ConsumePendingSurface()
BindSurface
Called on the game loop thread to bind the pending surface to the existing context. Returns true if context survived and surface was bound. Returns false if context was lost — you must call Init() + restore resources.
bool BindSurface()
ReleaseSurface
Releases the surface on the game loop thread. Call this when the game loop thread detects surface destruction.
void ReleaseSurface()
CleanUp
Full cleanup — destroys surface, context, and display. Only call this on the game loop thread when the activity is truly finishing.
void CleanUp()
GetScreenSize
Vector2 GetScreenSize()