float coords[] = {
-1.0f, 1.0f, 0.0f, // 0, Top Left
-1.0f, -1.0f, 0.0f, // 1, Bottom Left
1.0f, -1.0f, 0.0f, // 2, Bottom Right
1.0f, 1.0f, 0.0f, // 3, Top Right
};
float texCoords[] = {
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
};
on draw:
gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, coords.length/dimension);
draw n开发者_开发百科ormally, but
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, coords.length/dimension);
this only draw the half square, why?
For this to work the order of the points should be: TL, BL, TR, BR.
When you specify a fan, the points go around the very first point. Each triangle is composed from that very first point, the next point on the list and the last point from the previous triangle.
With the strip it's different. Strip triangles are using last two points from the previous triangle and the new one on the list. This has a side effect: every triangle has the opposite winding (CW than CCW, then CW again and so on).
精彩评论