diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt index e76322fac..7523b4ce2 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt @@ -175,7 +175,7 @@ class WorldRenderer( } override fun postInit() { - check(renderWindow.textures.animator.animatedTextures.size < TextureArray.MAX_ANIMATED_TEXTURE) { "Can not have more than ${TextureArray.MAX_ANIMATED_TEXTURE} animated textures!" } + check(renderWindow.textures.animator.animatedTextures.size < TextureArray.MAX_ANIMATED_TEXTURES) { "Can not have more than ${TextureArray.MAX_ANIMATED_TEXTURES} animated textures!" } chunkShader = Shader( renderWindow = renderWindow, resourceLocation = ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "chunk"), diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/shader/Shader.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/shader/Shader.kt index 8014cc099..2efb0afc3 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/shader/Shader.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/shader/Shader.kt @@ -162,6 +162,10 @@ class Shader( glUniformBlockBinding(programId, glGetUniformBlockIndex(programId, uniformName), bindingIndex) } + fun getLog(): String { + return glGetShaderInfoLog(programId) + } + companion object { private val DEFAULT_DEFINES: Map Any?> = mapOf( @@ -173,7 +177,7 @@ class Shader( } }, "ANIMATED_TEXTURE_COUNT" to { - MMath.clamp(it.textures.animator.animatedTextures.size, 1, TextureArray.MAX_ANIMATED_TEXTURE) + MMath.clamp(it.textures.animator.animatedTextures.size, 1, TextureArray.MAX_ANIMATED_TEXTURES) } ) private var currentShaderInUse: Shader? = null // ToDo: This is not safe todo diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/textures/Texture.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/textures/Texture.kt index 4fa9862fc..203793c93 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/textures/Texture.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/textures/Texture.kt @@ -27,7 +27,7 @@ import java.io.FileNotFoundException import java.nio.ByteBuffer -class Texture( +data class Texture( val resourceLocation: ResourceLocation, ) { var arrayId = -1 diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/textures/TextureAnimation.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/textures/TextureAnimation.kt index b95ab1baa..11790fe6c 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/textures/TextureAnimation.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/textures/TextureAnimation.kt @@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.textures import de.bixilon.minosoft.gui.rendering.textures.properties.AnimationFrame -class TextureAnimation( +data class TextureAnimation( val texture: Texture, ) { var currentFrameIndex = 0 diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/textures/TextureArray.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/textures/TextureArray.kt index 6fcaa67a0..6b0f439d2 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/textures/TextureArray.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/textures/TextureArray.kt @@ -25,9 +25,7 @@ import de.matthiasmann.twl.utils.PNGDecoder import glm_.vec2.Vec2 import glm_.vec2.Vec2i import org.lwjgl.BufferUtils -import org.lwjgl.opengl.GL30.* -import org.lwjgl.opengl.GL31.GL_UNIFORM_BUFFER -import org.lwjgl.opengl.GL31.glBindBuffer +import org.lwjgl.opengl.GL31.* import java.nio.ByteBuffer class TextureArray(val allTextures: MutableMap) { @@ -327,6 +325,7 @@ class TextureArray(val allTextures: MutableMap) { shader.use() shader.setUniformBuffer(bufferName, 0) + glBindBufferBase(GL_UNIFORM_BUFFER, 0, animatedBufferDataId) } private fun uploadAnimatedStorageBuffer() { @@ -337,7 +336,7 @@ class TextureArray(val allTextures: MutableMap) { } companion object { - const val MAX_ANIMATED_TEXTURE = 4096 // 16kb / 4 (ints per animation) + const val MAX_ANIMATED_TEXTURES = 1024 // 16kb / 4 (ints per animation) / 4 bytes per int val TEXTURE_RESOLUTION_ID_MAP = arrayOf(16, 32, 64, 128, 256, 512, 1024) // A 12x12 texture will be saved in texture id 0 (in 0 are only 16x16 textures). Animated textures get split const val TEXTURE_MAX_RESOLUTION = 1024 const val MAX_MIPMAP_LEVELS = 5 diff --git a/src/main/java/de/bixilon/minosoft/util/logging/Log.kt b/src/main/java/de/bixilon/minosoft/util/logging/Log.kt index bb23a239b..2b9db4069 100644 --- a/src/main/java/de/bixilon/minosoft/util/logging/Log.kt +++ b/src/main/java/de/bixilon/minosoft/util/logging/Log.kt @@ -103,6 +103,9 @@ object Log { ChatComponent.of(stringWriter.toString(), ignoreJson = true) } is String -> { + if (message.isBlank()) { + return + } if (formatting.isNotEmpty()) { ChatComponent.of(message.format(*formatting), ignoreJson = true) } else {