mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
fix some shader bugs
This commit is contained in:
parent
237b63ae91
commit
2c2ec5bd9f
@ -60,6 +60,10 @@ interface Shader {
|
||||
is Vec4 -> setVec4(uniformName, data)
|
||||
is Vec3 -> setVec3(uniformName, data)
|
||||
is Vec2 -> setVec2(uniformName, data)
|
||||
is RGBColor -> setRGBColor(uniformName, data)
|
||||
is UniformBuffer -> setUniformBuffer(uniformName, data)
|
||||
// ToDo: Texture
|
||||
else -> error("Don't know what todo with uniform type ${data::class.simpleName}!")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,9 @@ class GLSLShaderCode(
|
||||
continue
|
||||
}
|
||||
val reader = GLSLStringReader(line.removePrefix("uniform "))
|
||||
reader.skipWhitespaces()
|
||||
reader.readUnquotedString() // data type
|
||||
reader.skipWhitespaces()
|
||||
|
||||
uniforms += reader.readUnquotedString()
|
||||
}
|
||||
|
@ -42,18 +42,21 @@ class OpenGLShader(
|
||||
private set
|
||||
val defines: MutableMap<String, Any> = mutableMapOf()
|
||||
private var shader = -1
|
||||
override var uniforms: List<String> = listOf()
|
||||
override var uniforms: MutableList<String> = mutableListOf()
|
||||
private set
|
||||
|
||||
private fun load(resourceLocation: ResourceLocation, shaderType: Int): Int {
|
||||
val code = GLSLShaderCode(renderWindow, renderWindow.connection.assetsManager.readStringAsset(resourceLocation))
|
||||
|
||||
code.defines += defines
|
||||
|
||||
val program = glCreateShaderObjectARB(shaderType)
|
||||
if (program.toLong() == MemoryUtil.NULL) {
|
||||
throw ShaderLoadingException()
|
||||
}
|
||||
|
||||
this.uniforms += code.uniforms
|
||||
|
||||
glShaderSourceARB(program, code.code)
|
||||
glCompileShaderARB(program)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user