您的位置:首页 > 移动开发 > Android开发

使用android OpenGL时出现的java.lang.IllegalArgumentException: Must use a native order direct Buffer错误问题解决

2015-07-08 07:52 946 查看
public TestRenderer() {

triangleDataBuffer = triangleData;

rectDataBuffer = rectData;

rectDataBuffer2 = rectData2;

pentacleColorBuffer = pentacle;

triangleColorBuffer = bufferUtil(triangleColor);

rectColorBuffer = bufferUtil(rectColor);

}

修改为

public TestRenderer() {

triangleDataBuffer = bufferUtil(triangleData);

rectDataBuffer = bufferUtil(rectData);

rectDataBuffer2 = bufferUtil(rectData2);

pentacleColorBuffer = bufferUtil(pentacle);

triangleColorBuffer = bufferUtil(triangleColor);

rectColorBuffer = bufferUtil(rectColor);

}

public IntBuffer bufferUtil(int[] arr) {

IntBuffer buffer;

ByteBuffer qbb = ByteBuffer.allocateDirect(arr.length * 4);

qbb.order(ByteOrder.nativeOrder());

buffer = qbb.asIntBuffer();

buffer.put(arr);

buffer.position(0);

return buffer;

}

public FloatBuffer bufferUtil(float[] arr) {

FloatBuffer buffer;

ByteBuffer qbb = ByteBuffer.allocateDirect(arr.length * 4);

qbb.order(ByteOrder.nativeOrder());

buffer = qbb.asFloatBuffer();

buffer.put(arr);

buffer.position(0);

return buffer;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: