Hi! I think there’s something I’m missing about render targets.
I have simplified my problem to the following example where I try to draw a triangle:
In this first program without using render target a triangle is drawn as expected:
fun main() = application {
configure {
width = 800
height = 800
windowResizable = true
}
program {
extend {
val c = contour {
moveTo(Vector2(width / 2.0 - 120.0, height / 2.0 - 120.00))
lineTo(cursor + Vector2(240.0, 0.0))
lineTo(cursor + Vector2(0.0, 240.0))
lineTo(anchor)
close()
}
drawer.clear(ColorRGBa.BLACK)
drawer.fill = ColorRGBa.PINK
drawer.strokeWeight = 4.0
drawer.stroke = ColorRGBa.WHITE
drawer.contour(c)
}
}
}
Now I modify the program to draw to a render target and then draw that to the screen as an image and in this case the result is a pink filled rectangle (the stroke is correctly drawn as a triangle):
fun main() = application {
configure {
width = 800
height = 800
windowResizable = true
}
program {
val rt = renderTarget(width, height) {
colorBuffer()
depthBuffer()
}
extend {
val c = contour {
moveTo(Vector2(width / 2.0 - 120.0, height / 2.0 - 120.00))
lineTo(cursor + Vector2(240.0, 0.0))
lineTo(cursor + Vector2(0.0, 240.0))
lineTo(anchor)
close()
}
drawer.isolatedWithTarget(rt) {
clear(ColorRGBa.BLACK)
fill = ColorRGBa.PINK
strokeWeight = 4.0
stroke = ColorRGBa.WHITE
contour(c)
}
drawer.image(rt.colorBuffer(0))
}
}
}
I believe I am using the latest openrndr-template.
This happens with any contour I draw, not just triangles. Could someone help me understand what is happening and how I could fix it? Thanks!!