4
\$\begingroup\$

I am creating a game using Box2D and OpenGL ES 1.1.

I am taking the b2PolygonShape vertices and converting them into an OpenGL ES 1.1 GL_LINE_LOOP. The debugging view looks great, but now I want to apply textures to the inside of the line loop.

Is this possible? I used line loop instead of triangles because I am not sure how to handle complex polygons using triangles.

\$\endgroup\$

2 Answers 2

6
\$\begingroup\$

No.

Only rendered primitives get rasterized and shaded, and when you render using GL_LINE_LOOP your primitives are just the lines themselves, not the area enclosed by the lines.

If you want to rasterize and shade the area within the line, you have to render using a solid primitive like GL_TRIANGLES. If you have complex polygons you will first need to break them down into triangles using some kind of triangulation technique (you can also search this site for other questions about polygon triangulation if you get stuck).

\$\endgroup\$
2
  • 1
    \$\begingroup\$ shouldn't (a convex) line loop be trivially convertible to triangle fan? \$\endgroup\$
    – Jimmy
    Jul 11, 2013 at 19:05
  • 1
    \$\begingroup\$ If its convex, yes. \$\endgroup\$
    – user1430
    Jul 11, 2013 at 19:22
0
\$\begingroup\$

I know this question is pretty old, but I just had exactly the same question ...

And now I found out that everything works fine if one replaces GL_LINE_LOOP by GL_POLYGON. Nevertheless you have to consider the fact that the tesselation solution is much more efficient.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for answer, however the questions says "inside a GL_LINE_LOOP" and your answer is not to use GL_LINE_LOOP. The answer is clearly no, since GL_LINE_LOOP does not render anything except from the edges of an object. \$\endgroup\$ Jun 21, 2018 at 16:02
  • \$\begingroup\$ By the way: An other problem are concave polygons. \$\endgroup\$
    – K. S.
    Jun 21, 2018 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .