@Famous - that’s very difficult to say without seeing the code and/or replicating the problem (and although we try to be very helpful here, I’m not sure if anyone will want to sit and wait for 20 minutes!).
I see there is a shader involved, which complicates things a bit.
I also note that the draw function creates a new temporary mesh at each draw, and these may only get discarded every minute or so when Codea does garbage collection. If the problem is that all the discarded meshes are piling up, I might try adding these lines under m:draw() in the arc function, which force immediate garbage collection.
m=nil
collectgarbage()
It’s not elegant or efficient, but it may tell you where the problem lies.
Thanks Ignatz. The code is exactly what is in the forum where mpilgrem posts “Below is a Codea version 1.5 suggestion, making use of an example shader:”
I added in your garbage collection suggestion and I’m running now.
I have the trace from codea crash. It references an OpenGLES call which I’m googling
Other than trace from the crash reporter how else might I diagnose?
The reason I have gone with codea is because I’m a windows PC user with an Ipad, so I can’t bust out Xcode and debug.
Thanks LoopSpace. I did see that code, but it looked very complex compared to the arc code I’m using.
1 hour of mesh draws and the app is still running pretty so I hope the GC has fixed my problem.
Thanks all.
.@Famous - try this code, which only has one permanent mesh. See comments in the code.
supportedOrientations(LANDSCAPE_ANY)
function setup()
cx, cy = WIDTH / 2, HEIGHT / 2
stroke(118, 223, 25)
--NEW added callback function to update mesh if changed
parameter.integer("width", 1, 100, 40,ChangeSettings)
parameter.integer("radius", 100, WIDTH / 2, 200,ChangeSettings)
parameter.integer("startAngle", -180, 180, -130,ChangeSettings)
parameter.integer("endAngle", -180, 180, 130,ChangeSettings)
m = mesh()
m.shader = shader("Patterns:Arc")
m:addRect(cx,cy,radius,radius)
m.shader.color = color(stroke())
end
function ChangeSettings()
--as parameters will call this function when setting up, before the mesh is created
--this code prevents an error
if not m then return end
--the "1" in setRect is the rectangle's index (ie first rectangle in the mesh)
m:setRect(1,cx,cy,radius*2,radius*2)
m.shader.a1 = math.rad(startAngle)
m.shader.a2 = math.rad(endAngle)
m.shader.size = (1 - strokeWidth()/radius) * 0.5
end
function draw()
--it should be sufficient to run ChangeSettings once at the end of setup
--but this doesn't work for some reason. It seems to have to run a couple of times
--before anything draws, which is odd
--So this code makes it run a few times at the start. Strange.
if ElapsedTime<0.20 then ChangeSettings() end
background(64)
strokeWidth(width)
m:draw()
end