I'm trying to draw a textured concave polygon. My existing method uses setStencil, and writing to a canvas.
I've attached my code, that uses some static points for polygon vertices, and draws white dots on the screen where they should be.
It seems that setStencil doesn't work with concave polygons as their input.
Am I doing something wrong?
Do I have to decompose my concave poly into a number of convex polys?
Is there a way of doing that?
Using setStencil with a concave poly
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Using setStencil with a concave poly
- Attachments
-
- concave_stencil.love
- Template for drawing a stencil. Has concave poly co-ords.
- (6.45 KiB) Downloaded 54 times
Re: Using setStencil with a concave poly
It's love.graphics.polygon that doesn't do concave polygons. The vertices get passed directly to OpenGL and OpenGL doesn't do any triangulation unless someone would write code to invoke OpenGL 4's tessellator.
You have to do the triangulation yourself in Lua. The HardonCollider uses an algorithm to split up the shapes, I think it's the ear clipping one. You could take a look at that.
You have to do the triangulation yourself in Lua. The HardonCollider uses an algorithm to split up the shapes, I think it's the ear clipping one. You could take a look at that.
Shallow indentations.
Who is online
Users browsing this forum: No registered users and 46 guests