[orx-view-box] Add shouldDraw function

This commit is contained in:
Edwin Jakobs
2022-12-21 22:10:32 +01:00
parent 58359b9bab
commit bf2614ebc6
2 changed files with 56 additions and 28 deletions

View File

@@ -1,5 +1,6 @@
import org.openrndr.application
import org.openrndr.draw.BufferMultisample
import org.openrndr.draw.DrawPrimitive
import org.openrndr.extensions.Screenshots
import org.openrndr.extra.camera.Camera2D
@@ -19,7 +20,9 @@ fun main() {
program {
val vbx = viewBox(Rectangle(0.0, 0.0, 200.0, 800.0)) {
extend(Screenshots())
extend(Camera2D())
extend(Camera2D()).also {
shouldDraw = { it.hasChanged }
}
extend {
drawer.rectangle(20.0, 20.0, 100.0, 100.0)
}
@@ -41,8 +44,12 @@ fun main() {
}
}
val vbx3d = viewBox(Rectangle(400.0, 0.0, 400.0, 800.0)) {
extend(Orbital())
val vbx3d = viewBox(Rectangle(400.0, 0.0, 400.0, 800.0), multisample = BufferMultisample.SampleCount(8)) {
extend(Orbital()).also {
this.shouldDraw = {
it.hasChanged
}
}
val cube = boxMesh()
extend {
drawer.vertexBuffer(cube, DrawPrimitive.TRIANGLES)