Textured Polygons for All!
Re: Textured Polygons for All!
I'm running the Love 0.9.0 build:
Boolsheet-love_winbin-3a210b37dc82
Boolsheet-love_winbin-3a210b37dc82
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Textured Polygons for All!
I had to comment some lines in order to get the example from before working. So how do I apply an image to this? Can I apply an image to it? All I see so far is gradients. Warping images to odd shapes is what I'm really interested in. Especially if it's slightly faster than this library which is sadly a bit of a speed bottleneck. But it works great for now.slime wrote: Here is an OS X build from today: https://dl.dropboxusercontent.com/u/421 ... sx-pre.zip
Nearly every existing love game won't work with 0.9.0 without some function call name changes, partly because the window functions in love.graphics got moved to love.window yesterday.
There are still some issues with Geometries that may or may not be solved by the time 0.9.0 is released: in order to support concave polygons, it performs polygon triangulation internally to convert the polygon into individual triangles, but as a result the color and texture coordinate interpolation might not always behave as expected.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Textured Polygons for All!
The tables in the table given as an argument to love.graphics.newGeometry require at least x,y position coordinates and u,v texture coordinates. The position coordinates are where the corners (vertices) are drawn, and the uv texture coordinates are what part of the drawn image is at that corner. Position coordinates are in pixels, and uv coordinates are a number in the range of [0..1] (or more, if you want wrapping).Jasoco wrote:So how do I apply an image to this? Can I apply an image to it? All I see so far is gradients.
For example, a standard boring 100x100 quad can be created like this (although love.graphics.newQuad still exists, to make this particular case simpler):
Code: Select all
function love.load()
image = love.graphics.newImage("foo.png")
local geominfo = {
{0, 0, 0, 0}, -- x, y, u, v
{100, 0, 1, 0},
{100, 100, 1, 1},
{0, 100, 0, 1},
}
geom = love.graphics.newGeometry(geominfo)
end
function love.draw()
love.graphics.drawg(image, geom, 0, 0)
end
Currently Geometries can be concave, but as I mentioned earlier that's causing some problems, so it might be limited to convex polygons by the time 0.9.0 is released (although you can draw multiple convex Geometries to create what looks like a concave textured shape.)
EDIT: Convex-only as of today.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Textured Polygons for All!
Does the current version of 0.9.0 use LuaJIT or just regular Lua?
Re: Textured Polygons for All!
Good question.Jasoco wrote:Does the current version of 0.9.0 use LuaJIT or just regular Lua?
Was under the impression that it would use LuaJIT.
Anyone know?
Jasoco, have you had any luck with Geometry & images.
Seems to be working for me.
Be interested to see what you have so far.
- Attachments
-
- geoimage9.love
- Sine wave surface distortion using Love 0.9.0
- (262.13 KiB) Downloaded 385 times
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Textured Polygons for All!
Right now it uses standard Lua 5.1, but I believe the plan is to switch to LuaJIT by default before release.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Textured Polygons for All!
Ref, your example also still love.graphics.setMode incorrectly. And it uses setCaption which also doesn't work the way it used to. I don't know how they work for you, but over here it just errors.
I'm still not sure how to use this. Like at all.
If I have a set of coordinates, say the following:
And this image:
How would I make it look exactly like this: (The image on the right, with the point coordinates represented by the polygon on the left.)
I'm still not sure how to use this. Like at all.
If I have a set of coordinates, say the following:
Code: Select all
100, 100,
250, 130,
325, 320,
80, 290
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Textured Polygons for All!
Code: Select all
100, 100,
250, 130,
325, 320,
80, 290
Code: Select all
{
{0, 0, 0, 0},
{150, 30, 1, 0},
{225, 220, 1, 1},
{-20, 190, 0, 1},
}
Those changes were made just yesterday, or the day before, I believe, so he probably has an older version.Jasoco wrote:Ref, your example also still love.graphics.setMode incorrectly. And it uses setCaption which also doesn't work the way it used to. I don't know how they work for you, but over here it just errors.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Textured Polygons for All!
It works! Awesome. Can't wait for it to be integrated with LuaJIT so I can do some real tests. I'm hoping this is faster than the PixelEffect version. I'll do some benchmarking later comparing the speed of this library with the official Geometry in the current 0.9.0. Really wish 0.9.0 was done. If it had LuaJIT right now I'd start porting my project and use it for prototyping right now.bartbes wrote:If we want to drawn it from the top-left corner, the geometry will be made from something like..Code: Select all
100, 100, 250, 130, 325, 320, 80, 290
Code: Select all
{ {0, 0, 0, 0}, {150, 30, 1, 0}, {225, 220, 1, 1}, {-20, 190, 0, 1}, }
Makes sense.Those changes were made just yesterday, or the day before, I believe, so he probably has an older version.Jasoco wrote:Ref, your example also still love.graphics.setMode incorrectly. And it uses setCaption which also doesn't work the way it used to. I don't know how they work for you, but over here it just errors.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Textured Polygons for All!
That example will have visual problems due to the lack of perspective-correct interpolation (because there is no real z-coordinate or 'perspective'.)bartbes wrote:If we want to drawn it from the top-left corner, the geometry will be made from something like..Code: Select all
100, 100, 250, 130, 325, 320, 80, 290
Code: Select all
{ {0, 0, 0, 0}, {150, 30, 1, 0}, {225, 220, 1, 1}, {-20, 190, 0, 1}, }
I somewhat corrected for it manually (in that particular image's case with those particular coordinates, at least):
Code: Select all
{95, 95, 0.5, 0.5},
{0, 0, 0, 0},
{150, 30, 1, 0},
{225, 220, 1, 1},
{-20, 190, 0, 1},
{0, 0, 0, 0}
Who is online
Users browsing this forum: No registered users and 2 guests