Table of Contents

Interface ILoopProvider

Namespace
KeenEyes
Assembly
KeenEyes.Abstractions.dll

Interface for plugins that provide a main loop (window, game loop, etc.).

public interface ILoopProvider

Examples

// Plugins implement ILoopProvider to provide main loops
public class MyGraphicsPlugin : IWorldPlugin
{
    public void Install(IPluginContext context)
    {
        var loopProvider = new MyLoopProvider();
        context.SetExtension<ILoopProvider>(loopProvider);
    }
}

Remarks

This interface enables backend-agnostic main loop configuration. Plugins that create windows or game loops implement this interface to provide a standardized way to hook into the application lifecycle.

The WorldRunnerBuilder (from KeenEyes.Runtime) uses this interface to wire up the world's update loop without coupling to specific backends like Silk.NET or SDL.

Properties

IsInitialized

Gets whether the loop provider is initialized.

bool IsInitialized { get; }

Property Value

bool

Methods

Initialize()

Initializes the loop provider (creates window, etc.).

void Initialize()

InvokeOnRenderThread(Action)

Queues an action to run on the render thread (fire-and-forget).

void InvokeOnRenderThread(Action action)

Parameters

action Action

The action to execute on the render thread.

Remarks

Use this for render thread operations where you don't need to wait for completion.

InvokeOnRenderThreadAsync<T>(Func<T>)

Queues an action to run on the render thread and waits for completion.

Task<T> InvokeOnRenderThreadAsync<T>(Func<T> action)

Parameters

action Func<T>

The action to execute on the render thread.

Returns

Task<T>

A task that completes with the result when the action has executed.

Type Parameters

T

The return type of the action.

Remarks

Use this method when you need to perform operations that require the render thread's OpenGL context (e.g., reading framebuffers, creating textures). The action will be executed during the next render frame.

Run()

Runs the main loop. Blocks until closed.

void Run()

Events

OnClosing

Raised when the loop is closing.

event Action? OnClosing

Event Type

Action

OnReady

Raised once when the loop is ready (e.g., window created, context available).

event Action? OnReady

Event Type

Action

OnRender

Raised each frame for rendering.

event Action<float>? OnRender

Event Type

Action<float>

OnResize

Raised when the window or viewport is resized.

event Action<int, int>? OnResize

Event Type

Action<int, int>

Remarks

Parameters are the new width and height in logical points - the same space pointer positions are reported in - which makes this the event UI layout should follow. On a HiDPI display these are smaller than the framebuffer's pixel size, so anything measured in pixels (viewports, render targets) must be sized from the graphics context's framebuffer size instead.

OnUpdate

Raised each frame for update logic.

event Action<float>? OnUpdate

Event Type

Action<float>