lg.plygon gone wild [solved]

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
pakoskyfrog
Citizen
Posts: 62
Joined: Mon Feb 04, 2013 12:54 pm
Location: France

lg.plygon gone wild [solved]

Post by pakoskyfrog »

In one of my projects, i use the command love.graphics.polygon('fill', pointList) and the filling is a bit off...
To verify, i make my code to do both 'line' and 'fill' :
Capture-gone.PNG
Capture-gone.PNG (10.93 KiB) Viewed 2390 times
And, as you can see, both commands don't show the same results !
Any particular reasons why the filling doesn't follow the outer line ?
Something to do with convexity ?
Last edited by pakoskyfrog on Sun Feb 24, 2013 6:41 pm, edited 1 time in total.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: lg.plygon gone wild

Post by Nixola »

Yes, the fill mode needs the polygon to be simple and convex or the results may be buggy: love.graphics.polygon, 4th line
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
pakoskyfrog
Citizen
Posts: 62
Joined: Mon Feb 04, 2013 12:54 pm
Location: France

Re: lg.plygon gone wild [Answered]

Post by pakoskyfrog »

How did i missed that line ...
Okay... lg.polygon just became from quite useful to almost useless...
Now, i "just" have to write my own >.<
spectralcanine
Citizen
Posts: 65
Joined: Sat Dec 22, 2012 8:17 am

Re: lg.plygon gone wild

Post by spectralcanine »

You can write an algorithm to split it to convex polygons.
The easiest way is to split it to triangles, because that requires no computations whatsoever, but you get the gist.

By the way, this isn't really related to Love2D but rather to OpenGL. That's why polygons were removed ages ago.
User avatar
pakoskyfrog
Citizen
Posts: 62
Joined: Mon Feb 04, 2013 12:54 pm
Location: France

Re: lg.plygon gone wild

Post by pakoskyfrog »

I suspected openGL ^^
But since i just want to draw what's underneath my floor, i made a quadrature. Seems to work fine without much perf decrease.
Triangular meshing is not for now xD
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests