OpenGL ES - How to Draw a filled Polygon?

前端 未结 6 1461
小蘑菇
小蘑菇 2020-12-28 22:22

I tried googling and searching on stack but I didn\'t find anything :-(
( Mapping irregular shapes or other polygons (cartoons, sprites) to triangles in OpenGL ES )

6条回答
  •  隐瞒了意图╮
    2020-12-28 23:00

    I haven't tried using OpenGL ES, but judging from a quick look in the documentation you should be able to draw a convex polygon using e.g. a "triangle fan":

    glVertexPointer(2, ..., arrayOfCoordinates)
    ...
    glDrawElements(GL_TRIANGLE_FAN, ... , arrayOfIndices);
    

    You can think of a "triangle fan" as the spokes of a bicycle-wheel dividing the area of the wheel into "triangles" (the outer edge of a bicycle wheel is of course round, but I hope you get the idea).

    UPDATE: I found a small diagram on the web:http://www.cse.msu.edu/~cse472/step6_stuff/step6.1.gif

提交回复
热议问题