나는이 내가 LINE_STRIP 사용하는 경우 내가 일련의 수평선을 그리는 방법은 무엇입니까? 내가 운동을 배우는는 OpenGL에 새로운 오전
을 가지고 무엇을 정점 위치
를 포함 MXN 매트릭스의 그리드에서 수평 라인의 집합을 그릴하기로 결정
코드 조각 큰 것 정점 배열과 인덱스를 사용하여, 나는 많은 감사합니다 내가보고 코드 예제 어떤 도움을 플레이 할 필요가 교과서에서 불과 개념을 얻을 수있을 것 캔트 !
@Thomas 는
points.beginUpdateVertices();
for (int n = 0; n < totalPoints; n++) {
points.updateVertex(n, pointsPos[indices[n]].x, pointsPos[indices[n]].y, pointsPos[indices[n]].z);
}
points.endUpdateVertices();
이 작업을 수행하여 다음과 같은 코드를 다음
totalPoints = GRID_ROWS * 2 * (GRID_COLUMNS - 1);
indices = new int[totalPoints];
points = new GLModel(this, totalPoints, LINES, GLModel.DYNAMIC);
int n = 0;
points.beginUpdateVertices();
for (int row = 0; row < GRID_ROWS; row++) {
for (int col = 0; col < GRID_COLUMNS - 1; col++) {
int rowoffset = row * GRID_COLUMNS;
int n0 = rowoffset + col;
int n1 = rowoffset + col + 1;
points.updateVertex(n, pointsPos[n0].x, pointsPos[n0].y, pointsPos[n0].z);
indices[n] = n0;
n++;
points.updateVertex(n, pointsPos[n1].x, pointsPos[n1].y, pointsPos[n1].z);
indices[n] = n1;
n++;
}
}
points.endUpdateVertices();
I 업데이트하고 그릴과 결과
for (int col = 0; col < GRID_COLUMNS; col++) {
for (int row = 0; row < GRID_ROWS - 1; row++) {
int offset = col * GRID_ROWS;
int n0 = offset + row;
int n1 = offset + row + 1;
indices[n++] = n0;
indices[n++] = n1;
}
}
의 중첩을 변경하여
수정이 지금은
감사 agin 행과 열의 수에는 제한이 없습니다!
고마워요 매력처럼 작동하지만 nxn 격자에서 작동합니다. mxn과 작동하지 않습니다. 행 수가 열의 수와 다른 경우 도면이 지저분 해집니다. –
이것은 n x m에서도 작동합니다. 예를 들어, numcols가 5 일 경우 rowoffset은 0, 5, 10, 15가되어야합니다. 계산 또는 정점 배열에 문제가 있다고 의심됩니다. 질문에 코드를 추가 할 수 있습니까? – Thomas