Re: Textured Polygons for All!
Posted: Sat May 11, 2013 10:30 pm
I'm running the Love 0.9.0 build:
Boolsheet-love_winbin-3a210b37dc82
Boolsheet-love_winbin-3a210b37dc82
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.
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.
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
Good question.Jasoco wrote:Does the current version of 0.9.0 use LuaJIT or just regular Lua?
Code: Select all
100, 100,
250, 130,
325, 320,
80, 290
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.
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.
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}, }
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}