使用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;
}
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;
}
相关文章推荐
- 关于Actionbar重写的假设
- Android Studio环境搭建
- android之View和SurfaceView
- Android布局之SurfaceView与控件结合
- Android中shape中的属性大全
- Android:Activity组件学习笔记
- 关于android上dpi/screen-size的厘清解释
- Android开发中自定义dialog样式的步骤有哪些?
- liuling师姐程序学习笔记(1)
- android文档笔记(1)
- Jpush设置Alias和Tags问题
- 当ListView有Header时,onItemClick里的position不正确
- android动画中fillBefore以及fillAfter在xml中设置无效的问题
- Android开发者的Git&Github(一)
- Android Service检查Wifi状态并用notification通知
- android虚拟机adb不能启动情况汇总
- [Android] PorterDuff使用实例----实现新浪微博图片下载效果
- viewPager控制滑动速度和时间:利用反射机制实现
- android 记录
- Introduction into Android Development