Page 1 of 2

Textured Polygon

Posted: Wed Aug 31, 2011 5:42 pm
by tiby312
Quick question:
Is it possible to draw a 2d polygon and fill it with a repeating texture with the love2d api? I can't find any methods to do this.

Re: Textured Polygon

Posted: Wed Aug 31, 2011 6:08 pm
by thelinx
It's not possible.

Re: Textured Polygon

Posted: Wed Aug 31, 2011 6:08 pm
by bartbes
thelinx wrote:It's not possible.
.. at the moment.

Re: Textured Polygon

Posted: Wed Aug 31, 2011 6:17 pm
by tiby312
Okay :(

I wonder if there could be a way to emulate it though, with the functions we stuck with.

Since the common use for such a thing would be terrain and map making (think soldat), we could just render it to a sprite and then treat it as a sprite.

What if, I somehow drew the polygon in white using the built in functions and onto a black sprite and then used that as an alpha mask or something?

Re: Textured Polygon

Posted: Wed Aug 31, 2011 7:20 pm
by slime
You will be able to do stuff with Pixel Effects (fragment shaders) and/or image masks in 0.8.0 to possibly achieve something similar.

Re: Textured Polygon

Posted: Wed Aug 31, 2011 7:54 pm
by kikito
well, you could generate it with an imagedata, copying the background image repeatedly on it, and then "erasing out" the pixels outside the polygon by maxing their alpha individually. not pretty or fast, buy feasible at the beginning of each level.

Re: Textured Polygon

Posted: Thu Sep 01, 2011 7:33 am
by kraftman

Re: Textured Polygon

Posted: Thu Sep 01, 2011 10:15 am
by miko
bartbes wrote:
thelinx wrote:It's not possible.
.. at the moment.
...and now it is! Check the attachment, or the source code at GitHub: https://github.com/miko/Love2d-samples/ ... redPolygon

Re: Textured Polygon

Posted: Thu Sep 01, 2011 3:39 pm
by thelinx
Well, uh, holy shit!

Re: Textured Polygon

Posted: Thu Sep 01, 2011 10:23 pm
by Jasoco
Now, if you can get it to distort, we'd have the makings for creating a 3D engine.