Using setStencil with a concave poly

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Using setStencil with a concave poly

Post by kexisse »

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?
Attachments
concave_stencil.love
Template for drawing a stencil. Has concave poly co-ords.
(6.45 KiB) Downloaded 54 times
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Using setStencil with a concave poly

Post by Boolsheet »

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.
Shallow indentations.
Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests