gophergfx
    Preparing search index...

    Class Renderer

    Creates a renderer object to use for drawing to a WebGL2 canvas

    Index
    • Creates a WebGL context for the given canvas element

      Parameters

      • enableStencilBuffer: boolean = false

        Whether to enable the stencil buffer for the WebGL context

      Returns Renderer

    background: Color

    The background color of the viewport

    gfxCanvas: HTMLCanvasElement

    The canvas element that the renderer draws to

    gl: WebGL2RenderingContext

    The WebGL2 context used by the renderer

    viewport: Viewport

    The viewport of the renderer

    • Gets the normalized device coordinates from the provided mouse coordinates.

      Parameters

      • mouseX: number

        The x coordinate of the mouse.

      • mouseY: number

        The y coordinate of the mouse.

      Returns Vector2

      The normalized device coordinates.

    • Draws the scene using the provided camera.

      Parameters

      • scene: Scene

        The scene to draw.

      • camera: Camera

        The camera used to draw the scene.

      Returns void

    • Resizes the graphics canvas and adjusts the viewport to maintain the provided aspect ratio.

      Parameters

      • width: number

        The width of the graphics canvas in pixels.

      • height: number

        The height of the graphics canvas in pixels.

      • aspectRatio: number

        The aspect ratio of the graphics canvas.

      Returns void