Skip to content

Commit 55c47c9

Browse files
committed
cleanup
1 parent 97e9e91 commit 55c47c9

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

common/src/main/kotlin/com/lambda/graphics/shader/ParsedShader.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class ParsedShader(path: String) {
7979
val name = fieldMatch.groupValues[2]
8080

8181
val flag = fieldMatch.groupValues[3]
82+
.removePrefix("#").trim()
8283
.takeIf { it.isNotEmpty() }
83-
?.removePrefix("#")
8484

8585
Field(type, name, flag)
8686
}.toMutableSet()

common/src/main/kotlin/com/lambda/graphics/shader/ShaderInterp.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ fun buildShaderSource(path: String): Pair<String, String> {
4545
forEach { uniform ->
4646
val line = "uniform ${uniform.type} ${uniform.name};"
4747

48-
when (uniform.flag?.trim()) {
48+
when (uniform.flag) {
4949
"vertex" -> vertex += line
5050
"fragment" -> fragment += line
51-
else -> {
52-
vertex += line; fragment += line
53-
}
51+
"global" -> { vertex += line; fragment += line }
52+
else -> throw IllegalStateException("Destination of \"$line\" is not specified")
5453
}
5554
}
5655

@@ -86,7 +85,7 @@ fun buildShaderSource(path: String): Pair<String, String> {
8685
}
8786

8887
export.flag?.let { expr -> /* Add assignment if present */
89-
autoAssignment.appendLine(" ${export.name} = ${expr.trim()};")
88+
autoAssignment.appendLine(" ${export.name} = ${expr};")
9089
}
9190
}
9291

@@ -123,5 +122,4 @@ private fun MutableSet<ParsedShader.Method>.takeMain(name: String) = firstOrNull
123122
it.name == name && it.returnType == "void" && it.parameters.isEmpty()
124123
}.apply(this::remove) ?: ParsedShader.Method(name, "void", "", "")
125124

126-
127125
private const val HEADER = "#version 330 core"

0 commit comments

Comments
 (0)