当我使用 glDrawArrays 时,我在显示一个盒子的顶点时遇到问题,一个一个渲染顶点可以正常工作,请帮忙。
public class Box {
public void draw (GL2 gl, float x, float y, float z, float side)
{
FloatBuffer points;
float[] pointsData = {
-side, side, -side, //A0
side, side, -side, //A1
side, side, side, //A2
-side, side, side, //A3
-side, -side, -side, //B0
side, -side, -side, //B1
side, -side, side, //B2
-side, -side, side, //B3
};
//FloatBuffer colors;
//float[] colorsData;
int pointsDataLength = pointsData.length;
points = FloatBuffer.allocate(pointsDataLength);
points.put( pointsData, 0, pointsDataLength );
points.rewind();
gl.glTranslatef(x, y, z);
/*
gl.glBegin( GL.GL_POINTS );
for( int i=0; i < pointsDataLength/3; i++ )
{
gl.glVertex3fv( pointsData, i*3 );
}
gl.glEnd();
*/
gl.glVertexPointer( 3, GL.GL_FLOAT, 0, points );
//gl.glColor3f( 1f, 0f, 0f );
gl.glDrawArrays( GL.GL_POINTS, 0, pointsDataLength/3 );
}