emitGlslFragment()
함수, 출력 분류
Emit a module as a GLSL ES 3.00 fragment for a host that owns the program: the declarations and helper functions, without #version, without the precision lines and, by default, without the stage entry point.
import { emitGlslFragment } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function emitGlslFragment( m: ModuleDecl, stage?: 'vertex' | 'fragment', opts?: GlslEmitOptions & { entryPoints?: boolean },): EmitFragment매개변수
mModuleDeclthe module to emit.
stage선택 사항'vertex' | 'fragment'which stage’s scope to emit; omit for the whole module.
opts선택 사항GlslEmitOptions & { entryPoints?: boolean }the
GlslEmitOptions, plusentryPointsto keep the entries.
반환값
the fragment: its source, preamble, declares and requires.
예외
Errorthe same errors as
emitGlslModule.
설명
The host splices the returned source into
a program it assembles itself.
What the header would have carried comes back as data in EmitFragment.preamble:
the #version line, any #extension … : require a declared capability needs, and the
precision lines, including the ones for the integer and array sampler types derived from
the module’s texture bindings. A host merges and de-duplicates those across the
fragments it assembles.
Entry points are omitted unless opts.entryPoints is true. They are listed in
declares.entryPoints either way, and they still decide the stage scope, so the
fragment carries exactly the helpers, structs and bindings the stage’s entry reaches.
예제
예제
import { emitGlslFragment } from 'typeshade'
const frag = emitGlslFragment(MODULE, 'fragment')// frag.preamble: ['#version 300 es', 'precision highp float;', 'precision highp int;']// frag.source: the declarations and helpers, ready to splice into a host program대상별 지원
| 대상 | 지원 | 비고 |
|---|---|---|
| WGSL (WebGPU) | 해당 없음 | |
| GLSL ES 3.00 (WebGL2) | 지원 | Writes GLSL ES 3.00 for WebGL2. |
| CPU 오라클 | 해당 없음 |
관련 가이드
함께 보기
소스
src/core/backends/glsl.ts, 2508행, 커밋 c66579bf 기준