opengl: print out current state on error (buffers)

This commit is contained in:
Bixilon 2022-09-14 10:50:19 +02:00
parent c1dfc10ea2
commit 4aee5d15ae
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 8 additions and 7 deletions

View File

@ -50,7 +50,7 @@ abstract class OpenGLRenderableBuffer(
}
override fun unload() {
check(state == RenderableBufferStates.UPLOADED) { "Can not unload $state buffer!" }
check(state == RenderableBufferStates.UPLOADED) { "Buffer is not uploaded: $state" }
glDeleteBuffers(id)
if (renderSystem.boundBuffer == id) {
renderSystem.boundBuffer = -1

View File

@ -53,12 +53,13 @@ class OpenGLFramebuffer(var size: Vec2i) : Framebuffer {
//depthTexture.init()
//attach(depthTexture)
check(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) { "Framebuffer is incomplete!" }
state = FramebufferState.COMPLETE
val state = glCheckFramebufferStatus(GL_FRAMEBUFFER)
check(state == GL_FRAMEBUFFER_COMPLETE) { "Framebuffer is incomplete: $state" }
this.state = FramebufferState.COMPLETE
}
fun bind() {
check(state == FramebufferState.COMPLETE) { "Framebuffer is incomplete!" }
check(state == FramebufferState.COMPLETE) { "Framebuffer is incomplete: $state" }
unsafeBind()
}
@ -80,14 +81,14 @@ class OpenGLFramebuffer(var size: Vec2i) : Framebuffer {
}
override fun delete() {
check(state == FramebufferState.COMPLETE) { "Framebuffer is incomplete!" }
check(state == FramebufferState.COMPLETE) { "Framebuffer is incomplete: $state" }
glDeleteFramebuffers(id)
id = -1
state = FramebufferState.DELETED
}
override fun bindTexture() {
check(state == FramebufferState.COMPLETE) { "Framebuffer is incomplete!" }
check(state == FramebufferState.COMPLETE) { "Framebuffer is incomplete: $state" }
colorTexture.bind(0)
if (this::depthTexture.isInitialized) {
depthTexture.bind(1)

View File

@ -73,7 +73,7 @@ class FloatOpenGLVertexBuffer(
}
override fun draw() {
check(state == RenderableBufferStates.UPLOADED) { "Can not draw $state vertex buffer!" }
check(state == RenderableBufferStates.UPLOADED) { "Vertex buffer is not uploaded: $state" }
bindVao()
glDrawArrays(primitiveType.gl, 0, vertices)
}