【发布时间】:2019-08-13 02:36:17
【问题描述】:
我想画一个这样的描边圆:
我尝试过使用普通的顶点着色器和片段着色器,例如 google samples,顶点坐标为 364 点:
vertices = new float[364 * 3];
vertices[0] = 0;
vertices[1] = 0;
vertices[2] = 0;
for (int i =1; i <364; i++){
vertices[(i * 3)+ 0] = (float) (0.5 * Math.cos((3.14/180) * (float)i ));
vertices[(i * 3)+ 1] = (float) (0.5 * Math.sin((3.14/180) * (float)i ));
vertices[(i * 3)+ 2] = 0;
}
然后使用:
int COORDS_PER_VERTEX = 3;
int vertexCount = 364 * 3 / COORDS_PER_VERTEX;
int vertexStride = COORDS_PER_VERTEX * 4; // 4 bytes per vertex
GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
GLES20.glDrawArrays(GLES20.GL_LINE_LOOP, 1, vertexCount - 1);
但结果并不如预期,我的圈子里有4个缺失的部分。
我怎样才能像上面的例子一样画一个描边的圆圈?
【问题讨论】:
标签: android opengl-es opengl-es-2.0