abstract texture data, clean up texture

This commit is contained in:
Bixilon 2023-06-17 01:27:44 +02:00
parent b1f42e5cfe
commit 5b19803823
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
52 changed files with 217 additions and 171 deletions

View File

@ -23,7 +23,7 @@ import de.bixilon.minosoft.gui.rendering.gui.atlas.TexturePart
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMeshCache
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
import org.testng.Assert.assertEquals
class DummyComponentConsumer : GUIVertexConsumer {

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.gui.mesh
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh

View File

@ -18,7 +18,7 @@ import de.bixilon.minosoft.data.text.formatting.color.RGBColor
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMeshCache
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
class GUITestConsumer : GUIVertexConsumer {

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.system.dummy.texture
import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTextureArray
import java.util.*

View File

@ -18,10 +18,10 @@ import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
import de.bixilon.minosoft.gui.rendering.system.base.texture.SpriteAnimator
import de.bixilon.minosoft.gui.rendering.system.base.texture.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureArrayStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.sprite.SpriteAnimator
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
class DummyStaticTextureArray(renderSystem: RenderSystem) : StaticTextureArray {
@ -29,7 +29,7 @@ class DummyStaticTextureArray(renderSystem: RenderSystem) : StaticTextureArray {
override val animator: SpriteAnimator = SpriteAnimator(renderSystem)
override val state: TextureArrayStates = TextureArrayStates.DECLARED
override fun createTexture(resourceLocation: ResourceLocation, mipmaps: Boolean, default: () -> Texture): Texture {
override fun createTexture(resourceLocation: ResourceLocation, mipmaps: Boolean, default: (mipmaps: Boolean) -> Texture): Texture {
return textures.getOrPut(resourceLocation) { DummyTexture() }
}

View File

@ -18,25 +18,21 @@ import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayProperties
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.TextureRenderData
import de.bixilon.minosoft.gui.rendering.textures.properties.ImageProperties
import java.nio.ByteBuffer
class DummyTexture : Texture {
override var textureArrayUV: Vec2 = Vec2(1.0f)
override var atlasSize: Int = 1
override var singlePixelSize: Vec2 = Vec2(1.0f)
override var array = TextureArrayProperties(Vec2(), 1, Vec2())
override var state: TextureStates = TextureStates.DECLARED
override var size: Vec2i = Vec2i(1, 1)
override val transparency: TextureTransparencies get() = TextureTransparencies.OPAQUE
override var properties: ImageProperties = ImageProperties()
override var renderData: TextureRenderData = DummyTextureRenderData
override var data: ByteBuffer? = null
override var mipmapData: Array<ByteBuffer>?
get() = TODO("Not yet implemented")
set(value) {}
override var generateMipMaps: Boolean = false
override lateinit var data: TextureData
override var mipmaps: Boolean = false
override fun load(context: RenderContext) = Unit
}

View File

@ -14,8 +14,8 @@
package de.bixilon.minosoft.gui.rendering.system.dummy.texture
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.texture.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureManager
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTextureArray
class DummyTextureManager(val context: RenderContext) : TextureManager() {

View File

@ -20,7 +20,7 @@ import de.bixilon.minosoft.gui.rendering.font.renderer.component.ChatComponentRe
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMeshCache
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.world.mesh.SingleWorldMesh

View File

@ -31,7 +31,7 @@ class BitmapCodeRenderer(
get() = 1.0f
fun updateArray() {
uvStart = uvStart * texture.textureArrayUV
uvEnd = uvEnd * texture.textureArrayUV
uvStart = uvStart * texture.array.uvEnd
uvEnd = uvEnd * texture.array.uvEnd
}
}

View File

@ -72,7 +72,7 @@ class BitmapFontType(
private fun load(file: ResourceLocation, height: Int, ascent: Int, chars: List<String>, context: RenderContext): BitmapFontType? {
if (chars.isEmpty() || height <= 0) return null
val texture = context.textureManager.staticTextures.createTexture(file)
val texture = context.textureManager.staticTextures.createTexture(file, mipmaps = false)
texture.load(context) // force load it, we need to calculate the width of every char
return load(texture, height, ascent, chars.codePoints())
@ -130,7 +130,7 @@ class BitmapFontType(
val iterator = chars[row].iterator()
for (y in 0 until height) {
texture.data!!.scanLine((row * height) + y, width, start, end)
texture.data.buffer.scanLine((row * height) + y, width, start, end)
}
var column = 0
@ -145,7 +145,7 @@ class BitmapFontType(
offset.x = 0.0f; offset.y += height * pixel.y
}
texture.data!!.rewind()
texture.data.buffer.rewind()
if (renderer.isEmpty()) return null
renderer.trim()

View File

@ -26,7 +26,7 @@ class UnicodeCodeRenderer(
fun updateArray() {
uvStart = uvStart * texture.textureArrayUV
uvEnd = uvEnd * texture.textureArrayUV
uvStart = uvStart * texture.array.uvEnd
uvEnd = uvEnd * texture.array.uvEnd
}
}

View File

@ -25,7 +25,7 @@ import de.bixilon.minosoft.gui.rendering.font.renderer.properties.FontProperties
import de.bixilon.minosoft.gui.rendering.font.types.PostInitFontType
import de.bixilon.minosoft.gui.rendering.font.types.factory.FontTypeFactory
import de.bixilon.minosoft.gui.rendering.font.types.unicode.UnicodeCodeRenderer
import de.bixilon.minosoft.gui.rendering.system.base.texture.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
import de.bixilon.minosoft.util.KUtil.toResourceLocation

View File

@ -20,7 +20,7 @@ import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.skeletal.SkeletalVertexConsumer
import de.bixilon.minosoft.gui.rendering.skeletal.model.SkeletalModel
import de.bixilon.minosoft.gui.rendering.system.base.buffer.vertex.PrimitiveTypes
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap

View File

@ -70,7 +70,7 @@ class WeatherOverlay(private val context: RenderContext) : Overlay {
val offsetMultiplicator = random.nextFloat(0.8f, 1.2f)
val alpha = random.nextFloat(0.8f, 1.0f)
mesh.addZQuad(
Vec2(offset, 0), OVERLAY_Z, Vec2(offset + step, windowSize.y), Vec2(0.0f), texture.textureArrayUV
Vec2(offset, 0), OVERLAY_Z, Vec2(offset + step, windowSize.y), Vec2(0.0f), texture.array.uvEnd
) { position, uv ->
val transformed = Vec2()
transformed.x = position.x / (windowSize.x / 2) - 1.0f

View File

@ -105,7 +105,7 @@ class AtlasManager(private val context: RenderContext) {
fun postInit() {
for (element in elements.values) {
val singePixelSize = element.resolution?.let { Vec2(1.0f) / it / (Vec2(element.texture.atlasSize) / it) } ?: ATLAS_SINGLE_DEFAULT_PIXEL_SIZE
val singePixelSize = element.resolution?.let { Vec2(1.0f) / it / (Vec2(element.texture.array.size) / it) } ?: ATLAS_SINGLE_DEFAULT_PIXEL_SIZE
element.uvStart = singePixelSize * element.start
element.uvEnd = singePixelSize * element.end
}

View File

@ -21,10 +21,10 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.Element
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicStateChangeCallback
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTextureState
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2Util.EMPTY
open class DynamicImageElement(

View File

@ -73,7 +73,7 @@ open class ImageElement(
}
constructor(guiRenderer: GUIRenderer, texture: Texture, uvStart: Vec2i, uvEnd: Vec2i, size: Vec2 = Vec2(texture.size), tint: RGBColor = ChatColors.WHITE) : this(guiRenderer, texture, Vec2(uvStart) * texture.singlePixelSize, Vec2(uvEnd) * texture.singlePixelSize, size, tint)
constructor(guiRenderer: GUIRenderer, texture: Texture, uvStart: Vec2i, uvEnd: Vec2i, size: Vec2 = Vec2(texture.size), tint: RGBColor = ChatColors.WHITE) : this(guiRenderer, texture, Vec2(uvStart) * texture.array.pixel, Vec2(uvEnd) * texture.array.pixel, size, tint)
override fun forceRender(offset: Vec2, consumer: GUIVertexConsumer, options: GUIVertexOptions?) {
consumer.addQuad(offset, offset + size, texture ?: return, uvStart, uvEnd, tint, options)

View File

@ -55,7 +55,7 @@ abstract class WawlaElement(protected val wawla: WawlaHUDElement) : Element(wawl
protected fun createNameElement(translationKey: ResourceLocation?): TextElement {
val name = wawla.context.connection.language.forceTranslate(translationKey)
name.setFallbackColor(ChatColors.WHITE)
return TextElement(guiRenderer, name, background = null, properties = TextRenderProperties(scale = 1.2f))
return TextElement(guiRenderer, name, background = null, properties = TextRenderProperties(scale = 1.25f))
}
protected fun createIdentifierElement(item: Identified): TextElement? {

View File

@ -18,7 +18,7 @@ import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.MeshUtil.buffer
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct

View File

@ -18,7 +18,7 @@ import de.bixilon.kutil.collections.primitive.floats.AbstractFloatList
import de.bixilon.kutil.collections.primitive.floats.HeapArrayFloatList
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2Util.EMPTY
class GUIMeshCache(

View File

@ -19,7 +19,7 @@ import de.bixilon.minosoft.data.text.formatting.color.RGBColor
import de.bixilon.minosoft.gui.rendering.font.renderer.properties.FontProperties
import de.bixilon.minosoft.gui.rendering.font.renderer.properties.FormattingProperties
import de.bixilon.minosoft.gui.rendering.gui.atlas.TexturePart
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderIdentifiable
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
interface GUIVertexConsumer {

View File

@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.kotlinglm.vec3.Vec3
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.MeshUtil.buffer
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.rendering.skeletal
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import de.bixilon.minosoft.gui.rendering.util.mesh.AbstractVertexConsumer
interface SkeletalVertexConsumer : AbstractVertexConsumer {

View File

@ -19,7 +19,7 @@ import de.bixilon.minosoft.gui.rendering.models.unbaked.element.UnbakedElement.C
import de.bixilon.minosoft.gui.rendering.skeletal.SkeletalMesh
import de.bixilon.minosoft.gui.rendering.skeletal.model.SkeletalModel
import de.bixilon.minosoft.gui.rendering.skeletal.model.outliner.SkeletalOutliner
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
import java.util.*

View File

@ -21,7 +21,7 @@ import de.bixilon.minosoft.gui.rendering.skeletal.model.meta.SkeletalMeta
import de.bixilon.minosoft.gui.rendering.skeletal.model.outliner.SkeletalOutliner
import de.bixilon.minosoft.gui.rendering.skeletal.model.resolution.SkeletalResolution
import de.bixilon.minosoft.gui.rendering.skeletal.model.textures.SkeletalTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
data class SkeletalModel(

View File

@ -20,7 +20,7 @@ import de.bixilon.minosoft.gui.rendering.models.unbaked.element.UnbakedElement
import de.bixilon.minosoft.gui.rendering.skeletal.SkeletalVertexConsumer
import de.bixilon.minosoft.gui.rendering.skeletal.model.SkeletalModel
import de.bixilon.minosoft.gui.rendering.skeletal.model.elements.faces.SkeletalFace
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2Util.EMPTY
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.EMPTY
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.ONE

View File

@ -27,7 +27,7 @@ import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel.Compa
import de.bixilon.minosoft.gui.rendering.skeletal.model.SkeletalModel
import de.bixilon.minosoft.gui.rendering.skeletal.model.elements.SkeletalElement
import de.bixilon.minosoft.gui.rendering.system.base.MeshUtil.buffer
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.rotateAssign
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap

View File

@ -34,8 +34,8 @@ class MoonRenderer(
private fun updateUV(phases: MoonPhases) {
val coordinates = PHASE_UV[phases.ordinal]
uvStart = Vec2(1.0f / 4 * coordinates.x, 1.0f / 2 * coordinates.y) * texture.textureArrayUV
uvEnd = Vec2(1.0f / 4 * (coordinates.x + 1), 1.0f / 2 * (coordinates.y + 1)) * texture.textureArrayUV
uvStart = Vec2(1.0f / 4 * coordinates.x, 1.0f / 2 * coordinates.y) * texture.array.uvEnd
uvEnd = Vec2(1.0f / 4 * (coordinates.x + 1), 1.0f / 2 * (coordinates.y + 1)) * texture.array.uvEnd
meshInvalid = true
}

View File

@ -20,6 +20,7 @@ import de.bixilon.minosoft.gui.rendering.RenderConstants
import de.bixilon.minosoft.gui.rendering.gui.atlas.CodeTexturePart
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
import de.bixilon.minosoft.gui.rendering.system.base.shader.ShaderUniforms
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.skin.SkinManager
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture

View File

@ -11,10 +11,11 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.array
import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.system.base.texture.sprite.SpriteAnimator
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.file.PNGTexture
@ -27,7 +28,7 @@ interface StaticTextureArray : TextureArray {
return textures[resourceLocation]
}
fun createTexture(resourceLocation: ResourceLocation, mipmaps: Boolean = true, default: () -> Texture = { PNGTexture(resourceLocation, generateMipMaps = mipmaps) }): Texture
fun createTexture(resourceLocation: ResourceLocation, mipmaps: Boolean = true, default: (mipmaps: Boolean) -> Texture = { PNGTexture(resourceLocation, mipmaps = it) }): Texture
fun preLoad(latch: AbstractLatch)
}

View File

@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.array
import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.minosoft.gui.rendering.shader.Shader

View File

@ -0,0 +1,22 @@
/*
* Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture.array
import de.bixilon.kotlinglm.vec2.Vec2
data class TextureArrayProperties(
val uvEnd: Vec2,
val size: Int,
val pixel: Vec2,
)

View File

@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.array
enum class TextureArrayStates {
DECLARED,

View File

@ -0,0 +1,27 @@
/*
* Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture.data
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.minosoft.gui.rendering.system.opengl.texture.OpenGLTextureUtil
import java.nio.ByteBuffer
open class MipmapTextureData(
size: Vec2i,
buffer: ByteBuffer,
) : TextureData(size, buffer) {
val mipmaps: Array<ByteBuffer> = OpenGLTextureUtil.generateMipMaps(buffer, size)
override fun collect(): Array<ByteBuffer> = mipmaps
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -11,14 +11,22 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.data
import de.bixilon.kotlinglm.vec2.Vec2i
import org.objenesis.ObjenesisStd
import java.nio.ByteBuffer
data class TextureData(
open class TextureData(
val size: Vec2i,
val buffer: ByteBuffer,
val buffer: ByteBuffer
) {
constructor(size: Vec2i, array: ByteArray) : this(size, ByteBuffer.wrap(array))
open fun collect(): Array<ByteBuffer> = arrayOf(buffer)
companion object {
val NULL = ObjenesisStd().newInstance(TextureData::class.java)
}
}

View File

@ -14,7 +14,7 @@
package de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import java.util.*
import java.util.concurrent.atomic.AtomicInteger

View File

@ -13,8 +13,8 @@
package de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.readTexture
import java.io.ByteArrayInputStream
import java.util.*

View File

@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.shader
interface ShaderIdentifiable {
val shaderId: Int

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.shader
import de.bixilon.kotlinglm.vec2.Vec2

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -11,7 +11,7 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.sprite
import de.bixilon.kutil.time.TimeUtil.millis
import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem

View File

@ -11,33 +11,36 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.sprite
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayProperties
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.TextureRenderData
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.memory.MemoryTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.memory.TextureGenerator
import de.bixilon.minosoft.gui.rendering.textures.properties.ImageProperties
import de.matthiasmann.twl.utils.PNGDecoder
import java.nio.ByteBuffer
class SpriteTexture(private val original: Texture) : Texture {
override var textureArrayUV: Vec2 by original::textureArrayUV
override var atlasSize: Int by original::atlasSize
override var singlePixelSize: Vec2 by original::singlePixelSize
override var array: TextureArrayProperties by original::array
override var properties: ImageProperties by original::properties
override var renderData: TextureRenderData by original::renderData
override val transparency: TextureTransparencies by original::transparency
override var generateMipMaps: Boolean = true
override var mipmaps: Boolean = true
override var state: TextureStates = TextureStates.DECLARED
private set
override var data: ByteBuffer? = null
override var mipmapData: Array<ByteBuffer>? = null
override lateinit var data: TextureData
override var size: Vec2i = Vec2i(-1, -1)
private set
var splitTextures: MutableList<MemoryTexture> = mutableListOf()
@ -47,6 +50,7 @@ class SpriteTexture(private val original: Texture) : Texture {
return
}
original.load(context)
val original = original.data.buffer
val animationProperties = properties.animation!!
size = Vec2i(animationProperties.width, animationProperties.height)
@ -55,13 +59,12 @@ class SpriteTexture(private val original: Texture) : Texture {
val bytesPerTexture = size.x * size.y * PNGDecoder.Format.RGBA.numComponents
for (i in 0 until animationProperties.frameCount) {
val splitTexture = MemoryTexture(size)
val buffer = TextureGenerator.allocate(size)
buffer.copyFrom(original, bytesPerTexture * i, 0, bytesPerTexture)
buffer.flip()
val splitTexture = MemoryTexture(size, mipmaps = this.original.mipmaps, buffer = buffer)
splitTexture.data!!.let {
it.copyFrom(original.data!!, bytesPerTexture * i, 0, bytesPerTexture)
it.flip()
splitTexture.mipmapData = splitTexture.generateMipMaps(it)
}
splitTextures += splitTexture
}
state = TextureStates.LOADED

View File

@ -16,17 +16,17 @@ package de.bixilon.minosoft.gui.rendering.system.base.texture.texture
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies
import de.bixilon.minosoft.gui.rendering.system.opengl.texture.OpenGLTextureUtil
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayProperties
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.MipmapTextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
import de.bixilon.minosoft.gui.rendering.textures.properties.ImageProperties
import java.nio.ByteBuffer
interface Texture : ShaderTexture {
var textureArrayUV: Vec2
var atlasSize: Int
var singlePixelSize: Vec2
var array: TextureArrayProperties
val state: TextureStates
val size: Vec2i
val transparency: TextureTransparencies
@ -34,9 +34,8 @@ interface Texture : ShaderTexture {
var renderData: TextureRenderData
var data: ByteBuffer?
var mipmapData: Array<ByteBuffer>?
var generateMipMaps: Boolean
var data: TextureData
val mipmaps: Boolean
fun load(context: RenderContext)
@ -45,14 +44,6 @@ interface Texture : ShaderTexture {
get() = renderData.shaderTextureId
fun generateMipMaps(data: ByteBuffer = this.data!!): Array<ByteBuffer> {
if (!generateMipMaps) {
return arrayOf(data)
}
return OpenGLTextureUtil.generateMipMaps(data, size)
}
override fun transformUV(end: FloatArray?): FloatArray {
return renderData.transformUV(end)
}
@ -61,4 +52,7 @@ interface Texture : ShaderTexture {
return renderData.transformUV(end)
}
fun createData(mipmaps: Boolean = this.mipmaps, size: Vec2i, buffer: ByteBuffer): TextureData {
return if (mipmaps) MipmapTextureData(size, buffer) else TextureData(size, buffer)
}
}

View File

@ -13,13 +13,15 @@
package de.bixilon.minosoft.gui.rendering.system.base.texture.texture.file
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.minosoft.assets.AssetsManager
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.RenderConstants
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayProperties
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.MipmapTextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.TextureRenderData
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.readTexture
import de.bixilon.minosoft.gui.rendering.textures.properties.ImageProperties
@ -27,18 +29,15 @@ import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import java.io.FileNotFoundException
import java.nio.ByteBuffer
class PNGTexture(
override val resourceLocation: ResourceLocation,
override var generateMipMaps: Boolean = true,
override var mipmaps: Boolean = true,
) : FileTexture {
override lateinit var renderData: TextureRenderData
override lateinit var textureArrayUV: Vec2
override lateinit var singlePixelSize: Vec2
override var atlasSize: Int = -1
override lateinit var array: TextureArrayProperties
override var state: TextureStates = TextureStates.DECLARED
private set
override lateinit var size: Vec2i
@ -48,8 +47,7 @@ class PNGTexture(
override lateinit var properties: ImageProperties
override var data: ByteBuffer? = null
override var mipmapData: Array<ByteBuffer>? = null
override lateinit var data: TextureData
@Synchronized
@ -58,7 +56,7 @@ class PNGTexture(
return
}
val (size, data) = try {
var data = try {
assetsManager[resourceLocation].readTexture()
} catch (error: Throwable) {
state = TextureStates.ERRORED
@ -68,11 +66,13 @@ class PNGTexture(
}
assetsManager[RenderConstants.DEBUG_TEXTURE_RESOURCE_LOCATION].readTexture()
}
data.buffer.rewind()
if (mipmaps) data = MipmapTextureData(data.size, data.buffer)
this.size = size
this.size = data.size
transparency = TextureTransparencies.OPAQUE
for (i in 0 until data.limit() / 4) {
val alpha = data[i * 4 + 3].toInt() and 0xFF
for (i in 0 until data.buffer.limit() / 4) {
val alpha = data.buffer[i * 4 + 3].toInt() and 0xFF
if (alpha == 0x00) {
transparency = TextureTransparencies.TRANSPARENT
} else if (alpha < 0xFF) {
@ -80,14 +80,11 @@ class PNGTexture(
break
}
}
data.flip()
this.data = data
this.mipmapData = generateMipMaps(data)
properties.postInit(this)
state = TextureStates.LOADED
}

View File

@ -11,60 +11,33 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture.texture
package de.bixilon.minosoft.gui.rendering.system.base.texture.texture.memory
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayProperties
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.TextureRenderData
import de.bixilon.minosoft.gui.rendering.textures.properties.ImageProperties
import de.matthiasmann.twl.utils.PNGDecoder
import org.lwjgl.BufferUtils
import java.nio.ByteBuffer
class MemoryTexture(
override val size: Vec2i,
override var properties: ImageProperties = ImageProperties(),
override var generateMipMaps: Boolean = true,
generator: ((x: Int, y: Int) -> RGBColor)? = null,
override var mipmaps: Boolean = true,
buffer: ByteBuffer,
) : Texture {
override lateinit var textureArrayUV: Vec2
override lateinit var singlePixelSize: Vec2
override var atlasSize: Int = -1
override lateinit var array: TextureArrayProperties
override lateinit var renderData: TextureRenderData
override var transparency: TextureTransparencies = TextureTransparencies.OPAQUE
private set
override var data: ByteBuffer? = null
override var mipmapData: Array<ByteBuffer>? = null
override var data: TextureData = createData(mipmaps, size, buffer)
init {
val data = BufferUtils.createByteBuffer(size.x * size.y * PNGDecoder.Format.RGBA.numComponents)
this.data = data
generator?.let {
var index = 0
for (x in 0 until size.x) {
for (y in 0 until size.x) {
val pixel = it(x, y)
if (pixel.alpha == 0x00 && transparency != TextureTransparencies.TRANSLUCENT) {
transparency = TextureTransparencies.TRANSPARENT
} else if (pixel.alpha < 0xFF) {
transparency = TextureTransparencies.TRANSLUCENT
}
data.put(index++, pixel.red.toByte())
data.put(index++, pixel.green.toByte())
data.put(index++, pixel.blue.toByte())
data.put(index++, pixel.alpha.toByte())
}
}
this.mipmapData = generateMipMaps(data)
}
this.data = data
if (buffer.limit() != TextureGenerator.getBufferSize(size)) throw IllegalArgumentException("Invalid buffer size: ${buffer.limit()}")
}
override val state: TextureStates = TextureStates.LOADED

View File

@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.gui.rendering.system.base.texture.texture.memory
import de.bixilon.kotlinglm.vec2.Vec2i
import de.matthiasmann.twl.utils.PNGDecoder
import org.lwjgl.BufferUtils
object TextureGenerator {
fun getBufferSize(size: Vec2i) = size.x * size.y * PNGDecoder.Format.RGBA.numComponents
fun allocate(size: Vec2i) = BufferUtils.createByteBuffer(getBufferSize(size))
}

View File

@ -24,11 +24,13 @@ import de.bixilon.minosoft.assets.util.InputStreamUtil.readAsString
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
import de.bixilon.minosoft.gui.rendering.system.base.texture.SpriteAnimator
import de.bixilon.minosoft.gui.rendering.system.base.texture.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureArrayStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.SpriteTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayProperties
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.TextureArrayStates
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.sprite.SpriteAnimator
import de.bixilon.minosoft.gui.rendering.system.base.texture.sprite.SpriteTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.textures.TextureAnimation
import de.bixilon.minosoft.gui.rendering.textures.properties.ImageProperties
@ -58,17 +60,13 @@ class OpenGLTextureArray(
@Synchronized
override fun createTexture(resourceLocation: ResourceLocation, mipmaps: Boolean, default: () -> Texture): Texture {
override fun createTexture(resourceLocation: ResourceLocation, mipmaps: Boolean, default: (mipmaps: Boolean) -> Texture): Texture {
textures[resourceLocation]?.let { return it }
// load .mcmeta
val properties = readImageProperties(resourceLocation) ?: ImageProperties() // TODO: That kills performance
val texture = if (properties.animation == null) {
default()
} else {
SpriteTexture(default().apply { generateMipMaps = false })
}
val texture = if (properties.animation == null) default(mipmaps) else SpriteTexture(default(mipmaps))
texture.properties = properties
textures[resourceLocation] = texture
@ -129,6 +127,7 @@ class OpenGLTextureArray(
Vec2(texture.size) / arrayResolution
}
val singlePixelSize = Vec2(1.0f) / arrayResolution
val array = TextureArrayProperties(uvEnd ?: Vec2(1.0f, 1.0f), arrayResolution, singlePixelSize)
if (texture is SpriteTexture) {
val animationIndex = lastAnimationIndex++
@ -137,7 +136,7 @@ class OpenGLTextureArray(
texture.renderData = OpenGLTextureData(-1, -1, uvEnd, animationIndex)
for (split in texture.splitTextures) {
split.renderData = OpenGLTextureData(arrayId, lastTextureId[arrayId]++, uvEnd, animationIndex)
split.singlePixelSize = singlePixelSize
split.array = array
texturesByResolution[arrayId] += split
}
for (frame in texture.properties.animation!!.frames) {
@ -146,9 +145,7 @@ class OpenGLTextureArray(
} else {
texturesByResolution[arrayId] += texture
texture.renderData = OpenGLTextureData(arrayId, lastTextureId[arrayId]++, uvEnd, -1)
texture.singlePixelSize = singlePixelSize
texture.textureArrayUV = uvEnd ?: Vec2(1.0f, 1.0f)
texture.atlasSize = arrayResolution
texture.array = array
}
}
@ -165,17 +162,14 @@ class OpenGLTextureArray(
}
for (texture in textures) {
val mipMaps = texture.mipmapData ?: throw IllegalStateException("Texture not loaded properly!")
val renderData = texture.renderData as OpenGLTextureData
for ((level, data) in mipMaps.withIndex()) {
for ((level, data) in texture.data.collect().withIndex()) {
val size = texture.size shr level
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.mipmapData = null
texture.data = TextureData.NULL
}
return textureId

View File

@ -15,8 +15,8 @@ package de.bixilon.minosoft.gui.rendering.system.opengl.texture
import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.texture.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureManager
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTextureArray
import de.bixilon.minosoft.gui.rendering.system.opengl.texture.dynamic.OpenGLDynamicTextureArray

View File

@ -19,7 +19,7 @@ import de.bixilon.kutil.latch.AbstractLatch
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
import de.bixilon.minosoft.gui.rendering.system.base.shader.ShaderUniforms
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTextureState
import de.bixilon.minosoft.gui.rendering.system.opengl.OpenGLRenderSystem
@ -90,15 +90,15 @@ class OpenGLDynamicTextureArray(
texture.state = DynamicTextureState.LOADING
fun load() {
val (size, bytes) = data()
val data = data()
if (bytes.limit() > resolution * resolution * 4 || bytes.limit() < resolution * 4) { // allow anything in 1..resolution for y size
if (data.buffer.limit() > resolution * resolution * 4 || data.buffer.limit() < resolution * 4) { // allow anything in 1..resolution for y size
Log.log(LogMessageType.ASSETS, LogLevels.WARN) { "Dynamic texture $texture, has not a size of ${resolution}x${resolution}!" }
}
val mipmaps = OpenGLTextureUtil.generateMipMaps(bytes, size)
val mipmaps = OpenGLTextureUtil.generateMipMaps(data.buffer, data.size)
texture.data = mipmaps
texture.size = size
texture.size = data.size
if (force) {
load(texture, index, mipmaps) // thread check already done
} else {

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.gui.rendering.textures
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.SpriteTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.sprite.SpriteTexture
import de.bixilon.minosoft.gui.rendering.textures.properties.AnimationFrame
data class TextureAnimation(

View File

@ -15,9 +15,9 @@ package de.bixilon.minosoft.gui.rendering.textures
import de.bixilon.kotlinglm.vec2.Vec2i
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.system.base.texture.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies
import de.bixilon.minosoft.gui.rendering.system.base.texture.array.StaticTextureArray
import de.bixilon.minosoft.gui.rendering.system.base.texture.data.TextureData
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.Texture
import de.bixilon.minosoft.gui.rendering.world.mesh.SingleWorldMesh
import de.bixilon.minosoft.gui.rendering.world.mesh.WorldMesh

View File

@ -23,4 +23,9 @@ data class ImageProperties(
fun postInit(texture: Texture) {
animation?.postInit(texture)
}
companion object {
val DEFAULT = ImageProperties()
}
}

View File

@ -20,7 +20,7 @@ import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.RenderContext
import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel
import de.bixilon.minosoft.gui.rendering.skeletal.model.SkeletalModel
import de.bixilon.minosoft.gui.rendering.system.base.texture.ShaderTexture
import de.bixilon.minosoft.gui.rendering.system.base.texture.shader.ShaderTexture
class EntityModels(val context: RenderContext) {
private val unbakedModels: MutableMap<ResourceLocation, SkeletalModel> = mutableMapOf()