Textured Polygon

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.
tiby312
Prole
Posts: 2
Joined: Fri Jul 29, 2011 7:23 pm

Textured Polygon

Post 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.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Textured Polygon

Post by thelinx »

It's not possible.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Textured Polygon

Post by bartbes »

thelinx wrote:It's not possible.
.. at the moment.
tiby312
Prole
Posts: 2
Joined: Fri Jul 29, 2011 7:23 pm

Re: Textured Polygon

Post 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?
User avatar
slime
Solid Snayke
Posts: 3160
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Textured Polygon

Post 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.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Textured Polygon

Post 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.
When I write def I mean function.
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: Textured Polygon

Post by kraftman »

User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Textured Polygon

Post 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
Attachments
TexturedPolygon.love
(3.84 KiB) Downloaded 563 times
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Textured Polygon

Post by thelinx »

Well, uh, holy shit!
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Textured Polygon

Post by Jasoco »

Now, if you can get it to distort, we'd have the makings for creating a 3D engine.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests