# mesh on round objects

I had to use triangulate(points) in order to see the mesh rendering in color - its a circle I pre-calculated myself. How can avoid using this function? Reason: When triangulating, I cannot outline my mesh with line() anymore, because each tri gets its own outline and it looks zig-zaged and outlined … just a mess…

There are probably smarter ways, but the 2 that come to mind are

1. Pre-render a ellipse with a stroke and set the mesh texture to it
2. Make a slightly bigger mesh behind it that’s the stroke colour

I made it differently. Pre-calculated ellipse with modified version of Simeon’s code for star-mesh. Drawn the mesh with those vertices. On top, drawn an (out-)line, by using mesh’s every third coordinate - that are the exact coordinates for outline.

Two same meshes is nonsense. double data to load every frame… Thanks anyway.

You can ‘save’ them as an image using image() so you render two meshes as one image

I was just throwing some ideas around, no need to be rude about it.

@Luatee yes, I thought about that, but this would take away the possibility to change colors, etc, at runntime. thank you for that idea)
@colincapurso, I’m really sorry about that. excuse me please! And thank you all for the fresh ideas!

I think Ive solved it, It works, currently. If somebody has an idea how to compute automatic sides cound on circle - comments are welcome! currently I do: (radiusX + radiusY) / 2
but this is too havy yet.

Hello @se24vad. Is your circular mesh made up of triangles, each with one vertex at the centre and the other two on the circumference? You could set the uv coordinates and use a simple fragment shader so as to render a line between the vertices on the circumference.

``````
function setup()
myMesh = mesh()
local ver = {}
local uv = {}
local n = 60
local da = 2 * math.pi / n
local r = math.min(WIDTH / 2, HEIGHT / 2)
for i = 0, n - 1 do
local a = da * i
ver[i * 3 + 1] = vec2(r * math.cos(a), r * math.sin(a))
ver[i * 3 + 2] = vec2(r * math.cos(a + da),
r * math.sin(a + da))
ver[i * 3 + 3] = vec2(0, 0)
uv[i * 3 + 1] = vec2(0, 0)
uv[i * 3 + 2] = vec2(1, 0)
uv[i * 3 + 3] = vec2(0.5, 1)
end
myMesh.vertices = ver
myMesh.texCoords = uv
end

function draw()
background(0)
translate(WIDTH / 2, HEIGHT / 2)
myMesh:draw()
end

outerEdge = {
uniform mat4 modelViewProjection;

attribute vec4 position;
attribute vec2 texCoord;

varying highp vec2 vTexCoord;

void main() {
vTexCoord = texCoord;
gl_Position = modelViewProjection * position;
}
]],