mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 15:29:20 -04:00
disallow binding of texture array if unloaded + fix
Its simply impossible. Shaders can not be loaded/used when its not loaded. This fixes and INVALID_OPERATION opengl error
This commit is contained in:
parent
b36e8f7f6a
commit
1f11a66fae
@ -66,10 +66,10 @@ internal object MinosoftSIT {
|
||||
|
||||
val worker = TaskWorker()
|
||||
MinosoftBoot.register(worker)
|
||||
worker.minusAssign(BootTasks.PROFILES)
|
||||
worker.minusAssign(BootTasks.LAN_SERVERS)
|
||||
worker.minusAssign(BootTasks.MODS)
|
||||
worker.minusAssign(BootTasks.CLI)
|
||||
worker -= BootTasks.PROFILES
|
||||
worker -= BootTasks.LAN_SERVERS
|
||||
worker -= BootTasks.MODS
|
||||
worker -= BootTasks.CLI
|
||||
worker.work(MinosoftBoot.LATCH)
|
||||
MinosoftBoot.LATCH.dec()
|
||||
MinosoftBoot.LATCH.await()
|
||||
|
@ -57,13 +57,13 @@ class WorldBorderRenderer(
|
||||
|
||||
override fun init(latch: AbstractLatch) {
|
||||
shader.native.defines["MAX_DISTANCE"] = MAX_DISTANCE
|
||||
shader.load()
|
||||
|
||||
texture = context.textures.static.create(TEXTURE)
|
||||
context.camera.offset::offset.observe(this) { reload = true }
|
||||
}
|
||||
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
shader.load()
|
||||
context.textures.static.use(shader)
|
||||
shader.textureIndexLayer = texture.renderData.shaderTextureId
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ class FramebufferManager(
|
||||
fun init() {
|
||||
world.init()
|
||||
gui.init()
|
||||
for (error in context.system.getErrors()) {
|
||||
println()
|
||||
}
|
||||
|
||||
context.connection.events.listen<ResizeWindowEvent> {
|
||||
world.framebuffer.resize(it.size)
|
||||
@ -39,6 +42,9 @@ class FramebufferManager(
|
||||
}
|
||||
|
||||
fun postInit() {
|
||||
for (error in context.system.getErrors()) {
|
||||
println()
|
||||
}
|
||||
world.postInit()
|
||||
gui.postInit()
|
||||
}
|
||||
|
@ -86,11 +86,8 @@ class WeatherOverlay(private val context: RenderContext) : Overlay {
|
||||
mesh.load()
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
shader.load()
|
||||
}
|
||||
|
||||
override fun postInit() {
|
||||
shader.load()
|
||||
shader.use()
|
||||
context.textures.static.use(shader)
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ class OpenGLFontTextureArray(
|
||||
|
||||
override fun upload(latch: AbstractLatch?) {
|
||||
this.handle = OpenGLTextureUtil.createTextureArray(0)
|
||||
// glTexParameteriv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_RGBA, intArrayOf(GL_LUMINANCE, GL_LUMINANCE, GL_LUMINANCE, GL_LUMINANCE)) // TODO: not working?
|
||||
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_LUMINANCE_ALPHA, RESOLUTION, RESOLUTION, textures.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, null as ByteBuffer?)
|
||||
|
||||
for (texture in textures) {
|
||||
@ -62,6 +64,7 @@ class OpenGLFontTextureArray(
|
||||
}
|
||||
|
||||
override fun use(shader: NativeShader, name: String) {
|
||||
if (state != TextureArrayStates.UPLOADED) throw IllegalStateException("Texture array is not uploaded yet! Are you trying to load a shader in the init phase?")
|
||||
shader.use()
|
||||
activate()
|
||||
|
||||
|
@ -53,7 +53,7 @@ class OpenGLTextureArray(
|
||||
|
||||
|
||||
private fun upload(resolution: Int, textures: List<Texture>): Int {
|
||||
val textureId = OpenGLTextureUtil.createTextureArray(mipmaps)
|
||||
val handle = OpenGLTextureUtil.createTextureArray(mipmaps)
|
||||
|
||||
for (level in 0..mipmaps) {
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA8, resolution shr level, resolution shr level, textures.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, null as ByteBuffer?)
|
||||
@ -70,7 +70,7 @@ class OpenGLTextureArray(
|
||||
texture.data = TextureData.NULL
|
||||
}
|
||||
|
||||
return textureId
|
||||
return handle
|
||||
}
|
||||
|
||||
|
||||
@ -98,6 +98,7 @@ class OpenGLTextureArray(
|
||||
}
|
||||
|
||||
override fun use(shader: NativeShader, name: String) {
|
||||
if (state != TextureArrayStates.UPLOADED) throw IllegalStateException("Texture array is not uploaded yet! Are you trying to load a shader in the init phase?")
|
||||
shader.use()
|
||||
activate()
|
||||
|
||||
|
@ -96,6 +96,7 @@ class OpenGLDynamicTextureArray(
|
||||
}
|
||||
|
||||
override fun unsafeUse(shader: NativeShader, name: String) {
|
||||
if (handle <= 0) throw IllegalStateException("Texture array is not uploaded yet! Are you trying to load a shader in the init phase?")
|
||||
shader.use()
|
||||
activate()
|
||||
shader.setTexture("$name[$index]", index)
|
||||
|
@ -15,7 +15,6 @@ package de.bixilon.minosoft.protocol.packets.s2c.play.sign
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.data.entities.block.sign.SignBlockEntity
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
|
||||
@ -30,17 +29,9 @@ class SignTextS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
} else {
|
||||
buffer.readBlockPosition()
|
||||
}
|
||||
val lines: Array<ChatComponent>
|
||||
val lines = Array(SignBlockEntity.LINES) { buffer.readChatComponent() }
|
||||
|
||||
|
||||
init {
|
||||
val lines: MutableList<ChatComponent> = mutableListOf()
|
||||
for (i in 0 until SignBlockEntity.LINES) {
|
||||
lines.add(buffer.readChatComponent())
|
||||
}
|
||||
this.lines = lines.toTypedArray()
|
||||
}
|
||||
|
||||
override fun handle(connection: PlayConnection) {
|
||||
val entity = connection.world.getBlockEntity(position)?.unsafeCast<SignBlockEntity>() ?: SignBlockEntity(connection)
|
||||
|
||||
|
@ -359,7 +359,7 @@ object KUtil {
|
||||
}
|
||||
|
||||
@Deprecated("kutil 1.25")
|
||||
fun TaskWorker.minusAssign(identifier: Any) {
|
||||
operator fun TaskWorker.minusAssign(identifier: Any) {
|
||||
this::class.java.getDeclaredField("tasks").apply { isAccessible = true }.get(this).unsafeCast<MutableMap<Any, WorkerTask>>().remove(identifier)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user