• Renders an app into a browser DOM node.

    Parameters

    • app: ((gl: WebGL2RenderingContext) => Promise<((deltaTime: number) => void)>)

      An app that you want to display. An app is an async function that returns a render loop callback.

        • (gl): Promise<((deltaTime: number) => void)>
        • Parameters

          • gl: WebGL2RenderingContext

          Returns Promise<((deltaTime: number) => void)>

    • domNode: Element

      A DOM element. miniengine will display the app you pass inside this DOM element.

    Returns Promise<void>

    import { render } from '@miniengine/core';
    import app from './app';

    render(app, document.getElementById('root')!);
  • Renders an app into an existing WebGL2RenderingContext.

    Type Parameters

    • T extends WebGL2RenderingContext

    Parameters

    • app: ((gl: T) => Promise<((deltaTime: number) => void)>)

      An app that you want to display. An app is an async function that returns a render loop callback.

        • (gl): Promise<((deltaTime: number) => void)>
        • Parameters

          • gl: T

          Returns Promise<((deltaTime: number) => void)>

    • gl: T

      A WebGL2RenderingContext. miniengine will display the app you pass inside this WebGL2RenderingContext.

    Returns Promise<void>

    import { render } from '@miniengine/core';
    import app from './app';

    const canvas = document.getElementById('canvas')!;
    const gl = canvas.getContext('webgl2')!;
    render(app, gl);