I’m trying to send the object data to the GPU cache using an openGL ES book. In the last line the app crashes without error, just closes.
ByteBuffer byteBuf = ByteBuffer.allocateDirect(vertices.length * 4);
byteBuf.order(ByteOrder.nativeOrder());
mVertexBuffer = byteBuf.asFloatBuffer();
mVertexBuffer.put(vertices);
mVertexBuffer.position(0);
mIndexBuffer = ByteBuffer.allocateDirect(indices.length);
mIndexBuffer.put(indices);
mIndexBuffer.position(0);
m_NormalData = makeFloatBuffer(normalData);
ByteBuffer byteBuf2 = ByteBuffer.allocateDirect(textdata.length*4);
byteBuf2.order(ByteOrder.nativeOrder());
mtextdata = byteBuf2.asFloatBuffer();
mtextdata.put(textdata);
mtextdata.position(0);
final int vboID[]=new int[1];
float data[]=new float[mVertexBuffer.capacity() + mIndexBuffer.capacity() + m_NormalData.capacity() + mtextdata.capacity()];
int i,j=0;
for(i=0;i<mVertexBuffer.capacity();i++)data[i]=mVertexBuffer.get();
j=i;
for(i=0;i<mIndexBuffer.capacity();i++)data[i+j]=mIndexBuffer.get();
j+=i;
for(i=0;i<m_NormalData.capacity();i++)data[i+j]=m_NormalData.get();
j+=i;
for(i=0;i<mtextdata.capacity();i++)data[i+j]=mtextdata.get();
FloatBuffer m_data=makeFloatBuffer(data);
mVertexBuffer.position(0);
mIndexBuffer.position(0);
m_NormalData.position(0);
mtextdata.position(0);
GLES11.glGenBuffers(1, vboID, 0);
GLES11.glBindBuffer(GL11.GL_ARRAY_BUFFER, vboID[0]);
GLES11.glBufferData(GLES11.GL_ARRAY_BUFFER, m_data.capacity()*4, m_data, GLES11.GL_STATIC_DRAW); //It crashes right here
if in the last line I change 4 for 24 (like this) GLES11.glBufferData(GLES11.GL_ARRAY_BUFFER, m_data.capacity()*24, m_data, GLES11.GL_STATIC_DRAW);
Then I get an error in glBufferData(native method) -> java.lang.IllegalArgumentException: remaining() < size
Thanks in advance.