openGl ES开发 的native buffer问题

异常:Must use a native order direct Buffer

java.lang.IllegalArgumentException: Must use a native order direct Buffer.




public Buffer intBuffer(int[] data){  
    IntBuffer intBuffer ; 
    ByteBuffer bbuffer = ByteBuffer.allocateDirect(data.length * 4);  //int和float均占用4字节
    bbuffer.order(ByteOrder.nativeOrder());          
    intBuffer = bbuffer.asIntBuffer(); 
    intBuffer.put(data); 
    intBuffer.position(0); 
    return intBuffer ; 
    } 
  
public Buffer bufferUtilf(float[] data){ 
    FloatBuffer fBuffer ; 
    ByteBuffer bbuffer= ByteBuffer.allocateDirect(data.length * 4);
    bbuffer.order(ByteOrder.nativeOrder());  
    fBuffer = bbuffer.asFloatBuffer();
    fBuffer.put(data); 
    fBuffer.position(0); 
    return fBuffer; 
    }

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, floatBuffer(triangleData));
gl.glColorPointer(4, GL10.GL_FIXED, 0, intBuffer(triangleColor));




参见:http://hi.baidu.com/timestrider/item/b95574723f3603376dc37cee





你可能感兴趣的:(android,openGL ES)