Skip to content

Commit

Permalink
feat(webgl): update DefShaderOpts & defShader()
Browse files Browse the repository at this point in the history
- add `logger` option to use temp. logger for compiled GLSL output
  • Loading branch information
postspectacular committed Oct 25, 2023
1 parent 733331a commit 800318f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/webgl/src/api/shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
IRelease,
NumericArray,
} from "@thi.ng/api";
import type { ILogger } from "@thi.ng/logger";
import type { Func, Sym } from "@thi.ng/shader-ast";
import type { GLSLTarget } from "@thi.ng/shader-ast-glsl";
import type { ReadonlyVec } from "@thi.ng/vectors";
Expand Down Expand Up @@ -294,6 +295,10 @@ export interface ShaderPresetOpts<T> {
}

export interface DefShaderOpts {
/**
* Logger to use for compiled shader output (if not given uses current {@link LOGGER}).
*/
logger: ILogger;
/**
* Number of fractional digits for GLSL float literals
*/
Expand Down
5 changes: 3 additions & 2 deletions packages/webgl/src/shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ export const defShader = (
const srcFS = isFunction(spec.fs)
? shaderSourceFromAST(spec, "fs", version, opts)
: prepareShaderSource(spec, "fs", version);
LOGGER.debug(srcVS);
LOGGER.debug(srcFS);
const logger = opts?.logger || LOGGER;
logger.debug(srcVS);
logger.debug(srcFS);
initShaderExtensions(gl, spec.ext);
const vs = compileShader(gl, gl.VERTEX_SHADER, srcVS);
const fs = compileShader(gl, gl.FRAGMENT_SHADER, srcFS);
Expand Down

0 comments on commit 800318f

Please sign in to comment.