Gl.mesh: "Line_loop" behaves different from "polygon"?

MakePatchesNotWar's icon

Hello,

Ami missing something here? Shouldn't switching to "polygon" show the same shape as "line_loop" but filled?

Shape with "line_loop"

Shape with "polygon". All vertices appear to point to vertex[0]?

Max Patch
Copy patch and select New From Clipboard in Max.

(Bang the jit.noise again after loading the patch)

TFL's icon

TIL OpenGL polygon draw mode can only draw convex polygons, as stated in the gl3 doc.

In your case, you'll mostly get concave polygons, ie. which have at least one angle toward the inside of the polygon, if that makes sense. Hence the "wrong", but expected, drawing you get.

TFL's icon

Here is an example about how to use @draw_mode triangles instead of polygon, and use an index matrix into the jit.gl.mesh rightmost inlet to tell it which vertices to use to draw triangles.

I limited the inital jit.noise to a dim of 3, which means you have a matrix of dim 6 1 for your line_loop, and an index matrix of dim 12 1, because we need 4 triangles to draw our polygon.

Now you need to adapt the logic for X number of points in your initial line.

Max Patch
Copy patch and select New From Clipboard in Max.

MakePatchesNotWar's icon

Ah thanks, i was not aware of this! Was losing my head over it...