Hello, after find how to set a vertex buffer using an offset (my previous post) and spending a whole morning (with C I did it in 5 minutes…) I couldn’t get the VBO running 
My purpose is join all small buffers in a big VBO buffer, and in the render loop only change the indices’s vbo of the current drawn mesh. My app doesn’t crash, but doesn’t draw anything… perhaps I am missing something about nio buffers of something like that.
All of the following code is made after many hours of debug and tests, so it is not optimal at all. I know that there are better methods to perform the following tasks, but I wanted to make all as simple as possible to minimize the problems.
Well, here is where I join all objects (assume that the object’s data is right, because with standard VA all is drawn correctly)
int vertexCount = 0;
for(int i=0;i<m_meshes.length;i++)
vertexCount += m_meshes[i].GetNumberOfVertices();
float vert[] = new float[vertexCount*3];
int index = 0;
int indexOffset = 0;
long offset = 0;
for(int i=0;i<m_meshes.length;i++)
{
float v[] = m_meshes[i].GetVertices();
for(int j=0;j<v.length;j++)
{
vert[index++] = v[j];
}
m_meshes[i].SetOffset(offset);
m_meshes[i].BuildIndexVBO(indexOffset);
offset += m_meshes[i].GetNumberOfVertices() * 3 * 4; //OFFSET IS COMPUTED IN BYTES (3 = xyz, 4 = 4 bytes per float)
indexOffset += m_meshes[i].GetNumberOfVertices();
}
m_vboGeom = new int[1];
FloatBuffer vertices = ByteBuffer.allocateDirect((vertexCount * 3) * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
vertices.put(vert);
gl.glGenBuffers(1, m_vboGeom);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, m_vboGeom[0]);
gl.glBufferData(GL.GL_ARRAY_BUFFER, vertexCount * 3 * 4, vertices, GL.GL_STATIC_DRAW);
the SetOffset function only performs an asignement to an internal field, for later use
BUILDINDEXVBO FUNCTION
public void BuildIndexVBO(int indexoffset)
{
for(int i=0;i<m_indexCount;i++)
m_indices[i] += indexoffset;
IntBuffer buffer = ByteBuffer.allocateDirect(m_indexCount * 4).order(ByteOrder.nativeOrder()).asIntBuffer(); //4 = 4 bytes per int
gl.glGenBuffers(1, m_vboIndex);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, m_vboIndex[0]);
gl.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, m_indexCount * 4, buffer, GL.GL_STATIC_DRAW);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
}
DRAW LOOP
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
for(int i=0;i<m_meshes.length;i++)
{
gl.glPushMatrix();
gl.glMultMatrixf(m_meshes[i].TM);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, m_vboGeom[0]);
ByteBuffer offsetBuffer = BufferUtils.bufferOffset(m_meshes[i].m_vboOffset); //this offset is the value setted with the SetOffset() function
gl.glVertexPointer(3, GL.GL_FLOAT, 0, offsetBuffer);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, m_meshes[i].m_vboIndex[0]);
gl.glDrawElements(GL.GL_TRIANGLES,m_meshes[i].m_indexCount,GL.GL_UNSIGNED_INT,(Buffer) null);
gl.glPopMatrix();
}
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
Any help will be appreciated, I am really lost with this issue 