mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
render system: print errors
This commit is contained in:
parent
99febe97be
commit
794a6da851
@ -56,4 +56,6 @@ object RenderConstants {
|
||||
const val UV_ADD = 0.001f
|
||||
|
||||
const val DISABLE_GUI_CACHE = false
|
||||
|
||||
const val OPENGL_DEBUG_MODE = false
|
||||
}
|
||||
|
@ -260,6 +260,10 @@ class RenderWindow(
|
||||
RenderingStates.SLOW -> Thread.sleep(100L)
|
||||
RenderingStates.STOPPED -> window.close()
|
||||
}
|
||||
|
||||
for (error in renderSystem.getErrors()) {
|
||||
connection.util.sendDebugMessage(error.printMessage)
|
||||
}
|
||||
renderStats.endFrame()
|
||||
|
||||
if (RenderConstants.SHOW_FPS_IN_WINDOW_TITLE) {
|
||||
|
@ -99,4 +99,6 @@ interface RenderSystem {
|
||||
fun createTextureManager(): TextureManager
|
||||
|
||||
fun clear(vararg buffers: IntegratedBufferTypes)
|
||||
|
||||
fun getErrors(): List<RenderSystemError>
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.system.base
|
||||
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
|
||||
interface RenderSystemError {
|
||||
val printMessage: ChatComponent
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package de.bixilon.minosoft.gui.rendering.system.opengl
|
||||
|
||||
import de.bixilon.kutil.enums.EnumUtil
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.RenderSystemError
|
||||
import org.lwjgl.opengl.GL11.*
|
||||
import org.lwjgl.opengl.GL30.GL_INVALID_FRAMEBUFFER_OPERATION
|
||||
import org.lwjgl.opengl.GL45.GL_CONTEXT_LOST
|
||||
|
||||
class OpenGLError(
|
||||
val id: Int,
|
||||
) : RenderSystemError {
|
||||
val type = OpenGLErrors.CODES[id]
|
||||
override val printMessage = ChatComponent.of("§cOpenGL error: §e$id ($type)")
|
||||
|
||||
enum class OpenGLErrors(val code: Int) {
|
||||
INVALID_ENUM(GL_INVALID_ENUM),
|
||||
INVALID_VALUE(GL_INVALID_VALUE),
|
||||
INVALID_OPERATION(GL_INVALID_OPERATION),
|
||||
STACK_OVERFLOW(GL_STACK_OVERFLOW),
|
||||
STACK_UNDERFLOW(GL_STACK_UNDERFLOW),
|
||||
OUT_OF_MEMORY(GL_OUT_OF_MEMORY),
|
||||
INVALID_FRAMEBUFFER_OPERATION(GL_INVALID_FRAMEBUFFER_OPERATION),
|
||||
CONTEXT_LOST(GL_CONTEXT_LOST),
|
||||
;
|
||||
|
||||
companion object : ValuesEnum<OpenGLErrors> {
|
||||
override val VALUES: Array<OpenGLErrors> = values()
|
||||
override val NAME_MAP: Map<String, OpenGLErrors> = EnumUtil.getEnumValues(VALUES)
|
||||
val CODES: Map<Int, OpenGLErrors>
|
||||
|
||||
init {
|
||||
val codes: MutableMap<Int, OpenGLErrors> = mutableMapOf()
|
||||
|
||||
for (value in VALUES) {
|
||||
codes[value.code] = value
|
||||
}
|
||||
this.CODES = codes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.Colors
|
||||
import de.bixilon.minosoft.data.text.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.*
|
||||
@ -36,10 +37,15 @@ import de.bixilon.minosoft.gui.rendering.system.opengl.vendor.*
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh
|
||||
import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct
|
||||
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
import glm_.vec2.Vec2i
|
||||
import org.lwjgl.BufferUtils
|
||||
import org.lwjgl.opengl.GL
|
||||
import org.lwjgl.opengl.GL30.*
|
||||
import org.lwjgl.opengl.GL43.GL_DEBUG_OUTPUT
|
||||
import org.lwjgl.opengl.GL43.glDebugMessageCallback
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.FloatBuffer
|
||||
|
||||
@ -121,6 +127,12 @@ class OpenGLRenderSystem(
|
||||
glViewport(0, 0, it.size.x, it.size.y)
|
||||
}
|
||||
})
|
||||
if (RenderConstants.OPENGL_DEBUG_MODE) {
|
||||
glEnable(GL_DEBUG_OUTPUT)
|
||||
glDebugMessageCallback({ source, type, id, severity, length, message, userParameter ->
|
||||
Log.log(LogMessageType.RENDERING_GENERAL, LogLevels.VERBOSE) { "OpenGL error: source=$source, type=$type, id=$id, severity=$severity,length=$length,message=$message,userParameter=$userParameter" }
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun enable(capability: RenderingCapabilities) {
|
||||
@ -256,6 +268,16 @@ class OpenGLRenderSystem(
|
||||
glClear(bits)
|
||||
}
|
||||
|
||||
override fun getErrors(): List<OpenGLError> {
|
||||
val errors: MutableList<OpenGLError> = mutableListOf()
|
||||
var error: Int = glGetError()
|
||||
while (error != GL_NO_ERROR) {
|
||||
errors += OpenGLError(error)
|
||||
error = glGetError()
|
||||
}
|
||||
return errors
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val RenderingCapabilities.gl: Int
|
||||
get() {
|
||||
|
@ -5,6 +5,9 @@ import de.bixilon.minosoft.data.text.ChatColors
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
||||
import de.bixilon.minosoft.modding.event.events.InternalMessageReceiveEvent
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
class ConnectionUtil(
|
||||
private val connection: PlayConnection,
|
||||
@ -12,5 +15,6 @@ class ConnectionUtil(
|
||||
|
||||
fun sendDebugMessage(message: Any) {
|
||||
connection.fireEvent(InternalMessageReceiveEvent(connection, BaseComponent(RenderConstants.DEBUG_MESSAGES_PREFIX, ChatComponent.of(message).apply { applyDefaultColor(ChatColors.BLUE) })))
|
||||
Log.log(LogMessageType.CHAT_IN, LogLevels.INFO) { message }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user