Hi,
I was wondering if it is possible to use newMesh to draw
1) lines
and
2) polygons
The only "MeshDrawModes" available are for triangles.
When the polygons are filled with a texture it does not really make any difference whether they are many triangles or a single polygon, but for lines (like wireframe) or unfilled polygons it does.
Cheers
newMesh and polygons
Re: newMesh and polygons
(Antialiased) lines, no. Polygons, yes, with a bit of effort; see love.math.triangulate.
-
- Prole
- Posts: 15
- Joined: Sat Jul 26, 2014 7:28 pm
Re: newMesh and polygons
And aliased lines?
Is this a limitation of newMesh or of OpenGL?
Is this a limitation of newMesh or of OpenGL?
Re: newMesh and polygons
I don't know if there's another way, maybe someone else wants to weigh in, but for aliased lines, I guess you can make every line a thin rectangle.
Re: newMesh and polygons
LOVE renders its default anti-aliased lines by creating a mesh in a shape of a line, with solid quadrilateral core and solid-to-transparent gradient colored 1-pixel padding to create an anti-aliased look without actually using hardware anti-aliasing (which is usually disabled in 2d). You can render lines in a batch by simply rendering rectangles but these will not have anti-aliasing, or you can render rectangles with gradient transparency at the edges to give them anti-aliased look. That said, love version 11 and higher should be able to auto-batch the rendering of built-in lines.
OpenGL doesn't support drawing lines. It does however supports drawing wireframe geometry, but that's only good for mesh debugging purposes.
OpenGL doesn't support drawing lines. It does however supports drawing wireframe geometry, but that's only good for mesh debugging purposes.
-
- Prole
- Posts: 15
- Joined: Sat Jul 26, 2014 7:28 pm
Re: newMesh and polygons
I have tried something as trivial as adding 3 new mesh draw modes
(see https://bitbucket.org/audetto/love/comm ... 372271c29a)
and it does behave as expected.
Moreover adding
in Graphics::draw() allows to change the size. (this is not in the code linked above)
Got no idea how many more things I broke, but it looks something OpenGL would easily handle out of the box.
(see https://bitbucket.org/audetto/love/comm ... 372271c29a)
and it does behave as expected.
Moreover adding
Code: Select all
glLineWidth(2);
glEnable(GL_LINE_SMOOTH);
Got no idea how many more things I broke, but it looks something OpenGL would easily handle out of the box.
- slime
- Solid Snayke
- Posts: 3161
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: newMesh and polygons
Variable width line primitives aren't something modern GPUs have hardware for anymore, and modern OpenGL versions (which love uses when the graphics driver supports them) have deprecated glLineWidth and will cause an OpenGL error to be produced if you call it. GL_LINE_SMOOTH is also something GPUs don't have hardware for, and it isn't supported by modern GL versions either.
Aside from only supporting 1 pixel width lines on modern systems, OpenGL lines also have inconsistent implementations on different drivers in general. There are good reasons why love.graphics.line and friends moved away from GL_LINES and have a custom geometry-based implementation instead.
In terms of the most efficient way to draw lots of static lines, it depends a bit on your use-case but if love.graphics.line/polygon is too slow, either a custom Mesh or Spritebatch with an image scaled to look like a line, or a Canvas that has love.graphics.line primitives pre-drawn to it, are a couple decent alternatives.
Aside from only supporting 1 pixel width lines on modern systems, OpenGL lines also have inconsistent implementations on different drivers in general. There are good reasons why love.graphics.line and friends moved away from GL_LINES and have a custom geometry-based implementation instead.
In terms of the most efficient way to draw lots of static lines, it depends a bit on your use-case but if love.graphics.line/polygon is too slow, either a custom Mesh or Spritebatch with an image scaled to look like a line, or a Canvas that has love.graphics.line primitives pre-drawn to it, are a couple decent alternatives.
-
- Prole
- Posts: 15
- Joined: Sat Jul 26, 2014 7:28 pm
Re: newMesh and polygons
I am trying to draw 3d shapes with a custom shader applying a perspective transformation.
I am not sure how this would work with love.graphics.line / polygon.
Probably the only solution is to draw a thin parallelepiped or a non-culled set of triangles.
I can read elsewhere of the issues around GL_LINES and for a better rendering they should be avoided. "Lines" don't really exist in the real world anyway.
On the other hand, it might be useful at times to have a super simple (maybe not pixel perfect, but working) way to draw lines, a bit like a wireframe feature.
A bit like it happens for "points"?
I am not sure how this would work with love.graphics.line / polygon.
Probably the only solution is to draw a thin parallelepiped or a non-culled set of triangles.
I can read elsewhere of the issues around GL_LINES and for a better rendering they should be avoided. "Lines" don't really exist in the real world anyway.
On the other hand, it might be useful at times to have a super simple (maybe not pixel perfect, but working) way to draw lines, a bit like a wireframe feature.
A bit like it happens for "points"?
- slime
- Solid Snayke
- Posts: 3161
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: newMesh and polygons
There is love.graphics.setWireframe, which toggles a wireframe mode for anything drawn when it's enabled. As the wiki page mentions though, it doesn't work on mobile devices.
-
- Prole
- Posts: 15
- Joined: Sat Jul 26, 2014 7:28 pm
Re: newMesh and polygons
So I guess this means there is no interest to add support for GL_LINES.
They can be useful to draw directions, normals without having to create half a dozen of triangles...
They can be useful to draw directions, normals without having to create half a dozen of triangles...
Who is online
Users browsing this forum: No registered users and 1 guest