emitGlslFragment
이 페이지에서

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

매개변수

m ModuleDecl

the module to emit.

stage선택 사항 'vertex' | 'fragment'

which stage’s scope to emit; omit for the whole module.

opts선택 사항 GlslEmitOptions & { entryPoints?: boolean }

the GlslEmitOptions, plus entryPoints to keep the entries.

반환값

EmitFragment

the fragment: its source, preamble, declares and requires.

예외

Error

the 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 기준

이 페이지 편집 문제 보고