Page 1 of 1

Trying to draw a textured polygon

Posted: Sat Jun 23, 2018 8:19 am
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.

Re: Trying to draw a textured polygon

Posted: Sat Jun 23, 2018 8:51 am
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.

Re: Trying to draw a textured polygon

Posted: Sat Jun 23, 2018 2:18 pm
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 :-/

Re: Trying to draw a textured polygon

Posted: Sat Jun 23, 2018 3:08 pm
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.

Re: Trying to draw a textured polygon

Posted: Sat Jun 23, 2018 5:14 pm
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 :)