Drawing triangles in XRender provides irregular output

Viewed 60

I am trying to use the XRender extensions to the X11 Window System to draw a series of triangles that form a pentagon. However, when I try to use the Triangles request to draw the triangles, they form some kind of weird pseudo-pentagon.

Weird pseudo-pentagon

Although I guess this is a pentagon, I'm trying to draw a symmetrical pentagon.

Here are the triangles I am trying to draw:

[
  [(100, 100), (200, 150), (0, 150)],
  [(0, 150), (200, 150), (50, 200)],
  [(200, 150), (150, 200), (50, 200)],
]

Here is the request that I send to the server, according to xtruss. It seems consistent with the triangles I am trying to draw. I have also tried using the Src operation and making mask-format the window's visual format, to no avail.

RenderTriangles(op=Over, src=pc#06000003, src-x=0, src-y=0, dst=pc#06000002, mask-format=None, triangles[0]={p1.x=100.00000, p1.y=100.00000, p2.x=200.00000, p2.y=150.00000, p3.x=0.00000, p3.y=150.00000}, triangles[1]={p1.x=0.00000, p1.y=150.00000, p2.x=200.00000, p2.y=150.00000, p3.x=50.00000, p3.y=200.00000}, ...)

Drawing is accomplished by first creating the window, then creating a Picture, and then drawing to the picture on Expose. I create the picture with the same visual format as the window that I create it with. Before I draw the triangles, I use the FillRectangles request to color the background white.

Over the course of debugging, I have tried only drawing one triangle at a time. The first and second triangles draw without issue, but the third triangle doesn't seem to render to the screen at all.

I have also read the XRender reference, but I can't seem to find anything that suggests that behavior I am experiencing.

1 Answers

I believe what causes this is your source picture is a linear gradient filled in a way that it stops past left 60-ish degree slope border. Here is what I get when source picture is Render.CreateSolidFill(pictSolid, 0.2, 0.2, 0.2, 1);.

enter image description here

Can you show what is used as source picture in your Triangles request?

Related