Skip to content

Commit

Permalink
fixes NPE Issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeCox committed Nov 22, 2018
1 parent 97e2447 commit ebd5a81
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions orx-no-clear/src/main/kotlin/NoClear.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit ebd5a81

Please sign in to comment.