# core/fullscreenpass (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/core/fullscreenpass/

Fullscreen pass. (one triangle covering the whole screen + fragment shader)

## FullscreenPass extends Object

Fullscreen pass. (one triangle covering the whole screen + fragment shader)
- The basic unit of screen level effects such as backgrounds / post processing.

Example: Fill the screen with a single fragment shader

```js
import { FullscreenPass } from "./build/vanilla.js";

const width = 320;
const height = 180;
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
document.body.appendChild(canvas);
const webGL2RenderingContext = canvas.getContext("webgl2");
const fragmentShaderSource = `#version 300 es
precision highp float;
in vec2 fragmentTextureCoordinate;
uniform vec3 tintColor;
out vec4 outputColor;
void main() {
	outputColor = vec4(fragmentTextureCoordinate * tintColor.rg, tintColor.b, 1.0);
}
`;
const fullscreenPass = new FullscreenPass(webGL2RenderingContext, fragmentShaderSource);
webGL2RenderingContext.viewport(0, 0, width, height);
fullscreenPass.useProgram();
const tintColorLocation = fullscreenPass.getUniformLocation("tintColor");
webGL2RenderingContext.uniform3f(tintColorLocation, 1.0, 0.6, 0.3);
fullscreenPass.draw();
const errorCode = webGL2RenderingContext.getError();
console.log(errorCode === webGL2RenderingContext.NO_ERROR);
```

- `constructor(webGL2RenderingContext, fragmentShaderSource)` (constructor, since 0.3.0): Constructor.
  - `webGL2RenderingContext` WebGL2RenderingContext: WebGL2 rendering context.
  - `fragmentShaderSource` string: Fragment shader GLSL ES 3.00 source. (leading and trailing whitespace is trimmed, receives fragmentCoordinate (-1 ~ 1) and fragmentTextureCoordinate (0 ~ 1) as in)
- `useProgram()` (method, since 0.4.0): Starts using the pass. (Binds the program and an empty vertex array, same as Rust use_program)
- `draw()` (method, since 0.3.0): Render. (Call after use() and setting uniforms)
- `getUniformLocation(uniformName)` (method, since 0.3.0): Returns the uniform location. (cached)
  - `uniformName` string: Uniform name.
  - returns WebGLUniformLocation: Uniform location. (null when not in the shader)
- `getWebGL2RenderingContext()` (method, since 0.3.0): Returns the rendering context.
  - returns WebGL2RenderingContext: Rendering context.
- `getShaderProgram()` (method, since 0.3.0): Returns the shader program.
  - returns ShaderProgram: Program linking the fullscreen vertex shader with the given fragment shader.
- `getVertexArray()` (method, since 0.3.0): Returns the vertex array.
  - returns WebGLVertexArrayObject: Empty vertex array without buffers. (the shader builds vertices from gl_VertexID)
- `destroy()` (method, since 0.4.0): Destroy. (Deletes the shader program and vertex array)
