Skip to content

Commit

Permalink
refactor(shader-ast-glsl): update impl for new idxm node type
Browse files Browse the repository at this point in the history
- in GLSL this is same result as normal `idx` node
  • Loading branch information
postspectacular committed Aug 14, 2021
1 parent c710d81 commit 75439ca
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/shader-ast-glsl/src/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
defTarget,
FnCall,
FuncArg,
Index,
IndexM,
isMat,
isVec,
itemType,
Expand Down Expand Up @@ -90,6 +92,9 @@ export const targetGLSL = (opts?: Partial<GLSLOpts>) => {
return res.join("");
};

const emitIndex = (t: Index<any> | IndexM<any>) =>
`${emit(t.val)}[${emit(t.id)}]`;

const emit: Fn<Term<any>, string> = defTarget({
arg: (t) => $decl(t, true),

Expand Down Expand Up @@ -123,7 +128,8 @@ export const targetGLSL = (opts?: Partial<GLSLOpts>) => {
t.iter ? emit(t.iter) : ""
}) ${emit(t.scope)}`,

idx: (t) => `${emit(t.val)}[${emit(t.id)}]`,
idx: emitIndex,
idxm: emitIndex,

if: (t) => {
const res = `if (${emit(t.test)}) ` + emit(t.t);
Expand Down

0 comments on commit 75439ca

Please sign in to comment.