# core/fullscreenpass (vanilla.js 0.4.0)

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

풀스크린 패스. (화면 전체를 덮는 삼각형 1개 + 프래그먼트 셰이더)

## FullscreenPass extends Object

풀스크린 패스. (화면 전체를 덮는 삼각형 1개 + 프래그먼트 셰이더)
- 배경 / 포스트 프로세싱 등 화면 단위 효과의 기본 단위.

예제: 프래그먼트 셰이더 하나로 화면 채우기

```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): 생성.
  - `webGL2RenderingContext` WebGL2RenderingContext: WebGL2 렌더링 컨텍스트.
  - `fragmentShaderSource` string: 프래그먼트 셰이더 GLSL ES 3.00 소스. (앞뒤 공백은 잘라 쓴다, in 으로 fragmentCoordinate(-1 ~ 1) 와 fragmentTextureCoordinate(0 ~ 1) 를 받는다)
- `useProgram()` (method, since 0.4.0): 패스 사용 시작. (프로그램 + 빈 버텍스 어레이 바인드, 러스트 판 use_program 과 같다)
- `draw()` (method, since 0.3.0): 출력. (use() 와 유니폼 설정 이후 호출)
- `getUniformLocation(uniformName)` (method, since 0.3.0): 유니폼 로케이션 반환. (캐시)
  - `uniformName` string: 유니폼 이름.
  - returns WebGLUniformLocation: 유니폼 위치. (셰이더에 없으면 null)
- `getWebGL2RenderingContext()` (method, since 0.3.0): 렌더링 컨텍스트 반환.
  - returns WebGL2RenderingContext: 렌더링 컨텍스트.
- `getShaderProgram()` (method, since 0.3.0): 셰이더 프로그램 반환.
  - returns ShaderProgram: 풀스크린 버텍스 셰이더와 받은 프래그먼트 셰이더를 링크한 프로그램.
- `getVertexArray()` (method, since 0.3.0): 버텍스 어레이 반환.
  - returns WebGLVertexArrayObject: 버퍼 없는 빈 버텍스 어레이. (정점은 gl_VertexID 로 셰이더가 만든다)
- `destroy()` (method, since 0.4.0): 파괴. (셰이더 프로그램과 버텍스 어레이를 지운다)
