opengl: remove some errors, fix some animation bugs

This commit is contained in:
Bixilon 2022-02-26 19:12:09 +01:00
parent 173b28b6e6
commit 0a8c1f974e
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 13 additions and 4 deletions

View File

@ -104,8 +104,13 @@ class OpenGLShader(
renderWindow.renderSystem.shaders += this renderWindow.renderSystem.shaders += this
} }
private fun getUniformLocation(uniformName: String): Int { private fun getUniformLocation(uniformName: String): Int {
return glGetUniformLocation(shader, uniformName) val location = glGetUniformLocation(shader, uniformName)
if (location < 0) {
throw IllegalArgumentException("No uniform named$uniformName!")
}
return location
} }
override fun setFloat(uniformName: String, value: Float) { override fun setFloat(uniformName: String, value: Float) {
@ -151,7 +156,11 @@ class OpenGLShader(
} }
override fun setUniformBuffer(uniformName: String, uniformBuffer: OpenGLUniformBuffer) { override fun setUniformBuffer(uniformName: String, uniformBuffer: OpenGLUniformBuffer) {
glUniformBlockBinding(shader, glGetUniformBlockIndex(shader, uniformName), uniformBuffer.bindingIndex) val index = glGetUniformBlockIndex(shader, uniformName)
if (index < 0) {
throw IllegalArgumentException("No uniform buffer called $uniformName")
}
glUniformBlockBinding(shader, index, uniformBuffer.bindingIndex)
} }
fun unsafeUse() { fun unsafeUse() {

View File

@ -169,7 +169,7 @@ class OpenGLTextureArray(
for ((level, data) in mipMaps.withIndex()) { for ((level, data) in mipMaps.withIndex()) {
val size = texture.size shr level val size = texture.size shr level
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0, 0, renderData.index, size.x, size.y, level + 1, GL_RGBA, GL_UNSIGNED_BYTE, data) glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0, 0, renderData.index, size.x, size.y, 1, GL_RGBA, GL_UNSIGNED_BYTE, data)
} }
texture.data = null texture.data = null

View File

@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft. * This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/ */
layout(std140) uniform uAnimationBuffer layout(std140) uniform uSpriteBuffer
{ {
uvec4 uAnimationData[ANIMATED_TEXTURE_COUNT]; uvec4 uAnimationData[ANIMATED_TEXTURE_COUNT];
}; };