# Contour fills as rectangle when drawing to render target

**URL:** <https://openrndr.discourse.group/t/contour-fills-as-rectangle-when-drawing-to-render-target/675>\
**Category:** OPENRNDR\
**Created:** [August 28, 2024, 1:58pm UTC](https://openrndr.discourse.group/t/contour-fills-as-rectangle-when-drawing-to-render-target/675 "2024-08-28T13:58:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joekhan](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/joekhan/32/687_2.png) [@joekhan](https://openrndr.discourse.group/u/joekhan)\
**Post date:** [August 28, 2024, 1:58pm UTC](https://openrndr.discourse.group/t/contour-fills-as-rectangle-when-drawing-to-render-target/675/1 "2024-08-28T13:58:15Z")

</div>

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:

```auto
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)
        }
    }
}

```

 ![Screenshot 2024-08-28 at 10.57.41 PM](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/217bf8a4627a43f74b3c88fb98807d4cd2c95f18.png)

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):

```auto
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))
        }
    }
}

```

 ![Screenshot 2024-08-28 at 10.57.08 PM](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/2b5f5b7b258268d6fbd906b4934c5138158f63fc.png)

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!!

---

<div class="post-metadata">

**Author:** ![bluehut](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/bluehut/32/675_2.png) [@bluehut](https://openrndr.discourse.group/u/bluehut)\
**Post date:** [August 28, 2024, 5:07pm UTC](https://openrndr.discourse.group/t/contour-fills-as-rectangle-when-drawing-to-render-target/675/2 "2024-08-28T17:07:12Z")

</div>

I tried your render target version on openrndr/orx 0.4.4 and a development build from a couple of weeks back, and your example works fine for me on Linux

---

<div class="post-metadata">

**Author:** ![joekhan](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/joekhan/32/687_2.png) [@joekhan](https://openrndr.discourse.group/u/joekhan)\
**Post date:** [August 28, 2024, 5:45pm UTC](https://openrndr.discourse.group/t/contour-fills-as-rectangle-when-drawing-to-render-target/675/3 "2024-08-28T17:45:52Z")

</div>

Oh thanks! Forgot to say I’m on macOS on an M2 MacBook. Will try on linux!

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [August 28, 2024, 5:46pm UTC](https://openrndr.discourse.group/t/contour-fills-as-rectangle-when-drawing-to-render-target/675/4 "2024-08-28T17:46:49Z")

</div>

Same for me: works fine. I wonder if it’s something related to the depth buffer.

Ah good point about the M2. I’ll mention this in Slack, maybe it’s related to the platform used.

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [August 28, 2024, 5:53pm UTC](https://openrndr.discourse.group/t/contour-fills-as-rectangle-when-drawing-to-render-target/675/5 "2024-08-28T17:53:14Z")

</div>

Could you pls try the `next-version` branch of `openrndr-template` ? Maybe that fixes it.

That branch will be updated in the coming days to use `0.4.5-alpha6` instead of `0.4.5-alpha5`, which may bring further improvements. AFAIK @edwin has been working a lot recently on making things very smooth on Mac computers, including compute shader support 🙂

---

<div class="post-metadata">

**Author:** ![joekhan](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/joekhan/32/687_2.png) [@joekhan](https://openrndr.discourse.group/u/joekhan)\
**Post date:** [August 28, 2024, 6:33pm UTC](https://openrndr.discourse.group/t/contour-fills-as-rectangle-when-drawing-to-render-target/675/6 "2024-08-28T18:33:02Z")

</div>

Works fine on the next-version branch! Thank you so much 🙂
