Trying to draw a textured polygon

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Trying to draw a textured polygon

Post by molul »

I'm trying to have a perspective effect on an image, a reto grid tunnel like this one: https://www.youtube.com/watch?v=IlKsfV2mRR8.

Using a quad I can manage to get the texture repeating, but not the distortion to make the perspective effect.

I was using a shader for this, but the device the app will run on doesn't seem able to display it correctly, so I'm looking for alternatives. Googling a bit, I've seen there was a different way to draw quads before LÖVE 0.9.0, which might have been handy for waht I want to achieve:
love.graphics.quad( mode, x1, y1, x2, y2, x3, y3, x4, y4 )

This was removed in 0.9.0 and now it's recommended to use "polygon" instead. However, polygons don't allow to set a texture like quads (afaik).

Does anyone have any idea on how to achieve this without using shaders? My last option is to draw a looped video, but I'd rather not, as it would make the project so big.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Trying to draw a textured polygon

Post by bartbes »

Note that love.graphics.quad, contrary to what the name might suggest, did not draw Quads at all, it drew quadrilaterals. Anyway, the answer is to use a Mesh. Note that shaders are supported everywhere love is, but on phones/embedded devices the shaders need to be OpenGL ES-compliant too.
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Trying to draw a textured polygon

Post by molul »

I'll take a look at making the shader gles compliant. That might be the key.

I tried with a mesh but setting vertices to make the perspective effect resulted in a weird result (can't post a screenshot now, but I found some topics here with the same issue).


EDIT
I'm using this shader (perspective.lua-textured polygons): viewtopic.php?t=12483

Is it "gles-ready"? I can't seem to find a way to test if it would work on a gles device :-/
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Trying to draw a textured polygon

Post by Nixola »

Nixola wrote: Thu Jun 14, 2018 3:08 pm Try setting the LOVE_GRAPHICS_USE_OPENGLES environment variable to 1 before launching LÖVE; that should be all there is to it.
That is, assuming your computer supports GL ES and the drivers use a stricter compiler. I don't know how to check for that, but trying won't hurt.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Trying to draw a textured polygon

Post by molul »

Thanks :) It does support it and I'm setting that flag already, but I think the LÖVE build I'm currently using (made by a friend of mine because I'm really bad at that) needs some more work. He already told me performance wouldn't be very good yet, so I'm still calm about it.

I just wanted to know it the shader should work fine on a gles device, as I don't really know what to check. It would be cool if there was some online tool for that :)
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests