OpenGl에서 OpenGL -ES- 스트립에서 삼각형의 색상 변화
문제
OpenGL에서 glbegin () 및 glend ()를 사용하면 각 glvertex3f () 사이에서 색상을 설정하고 변경할 수 있습니다. 정점 배열 및 gldrawarrays ()를 사용할 때 어떻게이 동작을 재현 할 수 있습니까? 여기에는 일반 OpenGL에 있습니다.
for(angle = 0.0f; angle < (2.0f*GL_PI); angle += (GL_PI/8.0f))
{
// Calculate x and y position of the next vertex
x = 50.0f*sin(angle);
y = 50.0f*cos(angle);
// Alternate color between red and green
if((iPivot %2) == 0)
glColor3f(0.0f, 1.0f, 0.0f);
else
glColor3f(1.0f, 0.0f, 0.0f);
// Increment pivot to change color next time
iPivot++;
// Specify the next vertex for the triangle fan
glVertex2f(x, y);
}
해결책
glDrawArrays를 사용하면 glvertexpointer가 정점 데이터를 설정할 수 있도록해야합니다.
같은 방식으로 색상에 대한 클라이언트 메모리 포인터를 설정할 수도 있습니다.
이 전화로 요약됩니다.
glEnableClientState (GL_VERTEX_ARRAY);
glEnableClientState (GL_COLOR_ARRAY); // enables the color-array.
glVertexPointer (... // set your vertex-coordinates here..
glColorPointer (... // set your color-coorinates here..
glDrawArrays (... // draw your triangles
BTW- 텍스처 좌표는 같은 방식으로 처리됩니다. gl_texcoord_array 및 gltexcoordpointer를 사용하면이를 사용하십시오.
제휴하지 않습니다 StackOverflow