Skip to content

Commit

Permalink
Fixed #83: Raw GLSL in a Shader renders correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Sep 24, 2023
1 parent 79beed6 commit db4d5eb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ object ShaderPrinter:
case ShaderAST.Block(ss) =>
renderStatements(ss)

case ShaderAST.ShaderBlock(None,None,None,ss) =>
renderStatements(ss)

case x =>
render(x)
.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,41 @@ class GLSLRawTests extends munit.FunSuite {
)
}

test("can embed raw Indigo vertex GLSL") {
inline def toEmbed: Shader[Unit, Unit] =
Shader {
RawGLSL(
"""
//#vertex_start
vec4 vertex(vec4 v){
return v;
}
//#vertex_end
"""
)
}

inline def fragment(inline embed: Shader[Unit, Unit]) =
Shader {
embed.run(())
}

val actual =
fragment(toEmbed).toGLSL[WebGL2].toOutput.code

// DebugAST.toAST(fragment)
// println(actual)

assertEquals(
actual,
s"""
|//#vertex_start
|vec4 vertex(vec4 v){
| return v;
|}
|//#vertex_end
|""".stripMargin.trim
)
}

}

0 comments on commit db4d5eb

Please sign in to comment.