mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
rendering: animations: fix debug texture bug with mesa drivers
This commit is contained in:
parent
2ca3e66ac7
commit
c00dbb101b
@ -175,7 +175,7 @@ class WorldRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun postInit() {
|
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(
|
chunkShader = Shader(
|
||||||
renderWindow = renderWindow,
|
renderWindow = renderWindow,
|
||||||
resourceLocation = ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "chunk"),
|
resourceLocation = ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "chunk"),
|
||||||
|
@ -162,6 +162,10 @@ class Shader(
|
|||||||
glUniformBlockBinding(programId, glGetUniformBlockIndex(programId, uniformName), bindingIndex)
|
glUniformBlockBinding(programId, glGetUniformBlockIndex(programId, uniformName), bindingIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLog(): String {
|
||||||
|
return glGetShaderInfoLog(programId)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val DEFAULT_DEFINES: Map<String, (renderWindow: RenderWindow) -> Any?> = mapOf(
|
private val DEFAULT_DEFINES: Map<String, (renderWindow: RenderWindow) -> Any?> = mapOf(
|
||||||
@ -173,7 +177,7 @@ class Shader(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ANIMATED_TEXTURE_COUNT" to {
|
"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
|
private var currentShaderInUse: Shader? = null // ToDo: This is not safe todo
|
||||||
|
@ -27,7 +27,7 @@ import java.io.FileNotFoundException
|
|||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
|
|
||||||
|
|
||||||
class Texture(
|
data class Texture(
|
||||||
val resourceLocation: ResourceLocation,
|
val resourceLocation: ResourceLocation,
|
||||||
) {
|
) {
|
||||||
var arrayId = -1
|
var arrayId = -1
|
||||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.textures
|
|||||||
|
|
||||||
import de.bixilon.minosoft.gui.rendering.textures.properties.AnimationFrame
|
import de.bixilon.minosoft.gui.rendering.textures.properties.AnimationFrame
|
||||||
|
|
||||||
class TextureAnimation(
|
data class TextureAnimation(
|
||||||
val texture: Texture,
|
val texture: Texture,
|
||||||
) {
|
) {
|
||||||
var currentFrameIndex = 0
|
var currentFrameIndex = 0
|
||||||
|
@ -25,9 +25,7 @@ import de.matthiasmann.twl.utils.PNGDecoder
|
|||||||
import glm_.vec2.Vec2
|
import glm_.vec2.Vec2
|
||||||
import glm_.vec2.Vec2i
|
import glm_.vec2.Vec2i
|
||||||
import org.lwjgl.BufferUtils
|
import org.lwjgl.BufferUtils
|
||||||
import org.lwjgl.opengl.GL30.*
|
import org.lwjgl.opengl.GL31.*
|
||||||
import org.lwjgl.opengl.GL31.GL_UNIFORM_BUFFER
|
|
||||||
import org.lwjgl.opengl.GL31.glBindBuffer
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
|
|
||||||
class TextureArray(val allTextures: MutableMap<ResourceLocation, Texture>) {
|
class TextureArray(val allTextures: MutableMap<ResourceLocation, Texture>) {
|
||||||
@ -327,6 +325,7 @@ class TextureArray(val allTextures: MutableMap<ResourceLocation, Texture>) {
|
|||||||
shader.use()
|
shader.use()
|
||||||
|
|
||||||
shader.setUniformBuffer(bufferName, 0)
|
shader.setUniformBuffer(bufferName, 0)
|
||||||
|
glBindBufferBase(GL_UNIFORM_BUFFER, 0, animatedBufferDataId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun uploadAnimatedStorageBuffer() {
|
private fun uploadAnimatedStorageBuffer() {
|
||||||
@ -337,7 +336,7 @@ class TextureArray(val allTextures: MutableMap<ResourceLocation, Texture>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
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
|
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 TEXTURE_MAX_RESOLUTION = 1024
|
||||||
const val MAX_MIPMAP_LEVELS = 5
|
const val MAX_MIPMAP_LEVELS = 5
|
||||||
|
@ -103,6 +103,9 @@ object Log {
|
|||||||
ChatComponent.of(stringWriter.toString(), ignoreJson = true)
|
ChatComponent.of(stringWriter.toString(), ignoreJson = true)
|
||||||
}
|
}
|
||||||
is String -> {
|
is String -> {
|
||||||
|
if (message.isBlank()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (formatting.isNotEmpty()) {
|
if (formatting.isNotEmpty()) {
|
||||||
ChatComponent.of(message.format(*formatting), ignoreJson = true)
|
ChatComponent.of(message.format(*formatting), ignoreJson = true)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user