Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/shader_canvas/core/webgl_textures/create_texture.ts>CreateTexture

A rendering engine where you can write WebGL 2.0 shaders using custom tags.
Latest
class CreateTexture
import { CreateTexture } from "https://deno.land/x/shader_canvas@v1.1.1/core/webgl_textures/create_texture.ts";

Properties

private
whenLoaded

Promise that resolves when all dependencies have registered their tag in the customElements global Web Components registry.

This is used in the async initialize() function, to ensure that its code only runs when all the tags it depends are available.

bindTexture: (() => void)

This function is a wrapper to the gl.bindTexture() function. It is useful to allow a texture to be bound without having to keep track of its texture id.

It is created in the initialize() function.

It defaults to a no-op.

texture: WebGLTexture | null

The WebGL Texture id returned after gl.createTexture() is called

Methods

initialize(gl: WebGL2RenderingContext)

Initializing a texture consists in calling the initialization function for each child instance.

This function creates the bindTexture function above, which allows to set this texture id as the target for further WebGL actions

Static Properties

tag: string

<{{texture-name}}> {#CreateTexture}

You chose the tag name for your textures when declaring them. This name is then used to reference this Texture in other Shader Canvas containers and parts (like draw calls).

The allowed children of a Texture are:

Example

<shader-canvas>
  <webgl-canvas>
    <webgl-textures>
      <such-an-awesome-image>
        <tex-image-2d src="#texture"></tex-image-2d>
      </such-an-awesome-image>
   </textures>
  </webgl-canvas>
  <img id="texture" src="awesome-texture.png">
</shader-canvas>

For a usable example check the 2nd example - texture quad

This custom named tag is meant to be used as a child of the <webgl-textures> container tag.