Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Program<I, O>

Representation of a WebGLProgram, its UBOs and textures.

example

Using @gdgt/hlsl-loader you can create a program like this:

import { Program } from '@gdgt/webgl';
import * as myShader from './myShader.hlsl';

const program = new Program( myShader );

// you can now compile the program...
await program.compile();

// ... and use it afterwards
program.use();
someGeometry.draw();

Type Parameters

Hierarchy

  • default
    • Program

Index

Properties

ready: Promise<void>
ubos: UbosFromIntrospection<I, O>

Individual member views of UBOs specific to this program.

textures: TexturesFromIntrospection<I>

Texture slots used by this program.

Constructors

Methods

  • Instructs the program to use the given buffer as the source for the uniform block with the given name.

    remarks

    Note that this will not call delete() on the previously assigned buffer. This will have to be done manually, to avoid the accumulation of orphaned buffers.

    Type Parameters

    • U extends string | number | symbol = keyof I["ubos"]

    Parameters

    • name: U

      Name of the uniform block.

    • buffer: Uniformbuffer<I["ubos"][U]>

      Buffer to use as the data source.

    Returns boolean

    true if the operation was successful, false otherwise.

  • uploadUbosSync(): void
  • Returns the underlying WebGLProgram, once ready.

    If the program was not compiled before calling getProgram(), it will be compiled implicitly. Ideally, you should await compile() first.

    Returns Promise<WebGLProgram>

    The underlying WebGLProgram

  • use(): boolean
  • Sets the program and all UBOs and textures up for usage.

    Returns boolean

    true if the program has been successfully set up, false if something went wrong.

Generated using TypeDoc