0
매번 정점, 색상, 조명 등에 대해 ByteBuffer
메모리를 할당하려면 다음 작업을 수행해야합니다.ByteBuffer 할당을위한 하나의 도우미 기능 만들기 android OpenGL ES
ByteBuffer bBuff=ByteBuffer.allocateDirect(vertices.length*4);
bBuff.order(ByteOrder.nativeOrder());
vertBuff=bBuff.asFloatBuffer();
vertBuff.put(vertices);
vertBuff.position(0);
ByteBuffer bColorBuff=ByteBuffer.allocateDirect(colorVals.length*4);
bColorBuff.order(ByteOrder.nativeOrder());
colorBuff=bColorBuff.asFloatBuffer();
colorBuff.put(colorVals);
colorBuff.position(0);
.......
그래서 이런 식으로 도우미 기능을 만들려고했습니다.
private void fBFromFA(float array[], int size, FloatBuffer theBuff){
ByteBuffer bBuff=ByteBuffer.allocateDirect(array.length*size);
bBuff.order(ByteOrder.nativeOrder());
theBuff=bBuff.asFloatBuffer();
theBuff.put(array);
theBuff.position(0);
}
하지만 작동하지 않았습니다. 그것은 내게 java.lang.NullPointerException
소스를 gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertBuff);
draw(GL10 gl)
방법 안에 가리 키도록했다.