关闭

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

标签: OpenGLandroid
184人阅读 评论(0) 收藏 举报
分类:

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;
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2075次
    • 积分:84
    • 等级:
    • 排名:千里之外
    • 原创:6篇
    • 转载:2篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档