Merge pull request #2 from CodeCox/fix-null-issue1

NoClear() Extension : fixes NPE Issue #1
This commit is contained in:
Edwin Jakobs
2018-11-22 19:22:54 +01:00
committed by GitHub

View File

@@ -15,20 +15,22 @@ class NoClear : Extension {
override fun beforeDraw(drawer: Drawer, program: Program) {
if (renderTarget == null || renderTarget?.width != program.width || renderTarget?.height != program.height) {
renderTarget?.let {
it.colorBuffer(0).destroy()
it.detachColorBuffers()
it.destroy()
}
renderTarget = renderTarget(program.width, program.height) {
colorBuffer()
depthBuffer()
}
if (program.width > 0 && program.height > 0) { // only if the window is not minimised
if (renderTarget == null || renderTarget?.width != program.width || renderTarget?.height != program.height) {
renderTarget?.let {
it.colorBuffer(0).destroy()
it.detachColorBuffers()
it.destroy()
}
renderTarget = renderTarget(program.width, program.height) {
colorBuffer()
depthBuffer()
}
renderTarget?.let {
drawer.withTarget(it) {
background(program.backgroundColor ?: ColorRGBa.TRANSPARENT)
renderTarget?.let {
drawer.withTarget(it) {
background(program.backgroundColor ?: ColorRGBa.TRANSPARENT)
}
}
}
}