如何在opengl es 2.0中为顶点设置颜色?
现在我使用颜色数组:
float[] TriangleColors = new float[]{
1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
};
GL.EnableVertexAttribArray((int)GLKVertexAttrib.Color);
GL.VertexAttribPointer((int)GLKVertexAttrib.Color,
3, VertexAttribPointerType.Float,
false, 0, 0);
GL.GenBuffers(1, out colorBuffer);
GL.BindBuffer(BufferTarget.ArrayBuffer, colorBuffer);
GL.BufferData (BufferTarget.ArrayBuffer,
(IntPtr)(TriangleColors.Length * sizeof(float)),
TriangleColors,
BufferUsage.StaticDraw);
这段代码对我不起作用。