Re: GL2ES2 : glEnableClientState(GL2ES2.GL_VERTEX_ARRAY) issue
Posted by vslash on Mar 05, 2013; 2:39pm
URL: https://forum.jogamp.org/GL2ES2-glEnableClientState-GL2ES2-GL-VERTEX-ARRAY-issue-tp4028490p4028507.html
Ok, this sequence - ie VBO w/o element VBO - work :
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, objectIds[0]);
gl.glVertexAttribPointer(attributes[A_VERTEX], 3 , GL2ES2.GL_FLOAT, false, 0, 0L);
gl.glEnableVertexAttribArray(attributes[A_VERTEX]);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, 0); // or at the end, no matter.
gl.glDrawArrays(GL2ES2.GL_TRIANGLES, 0, triangleIndices.length);
gl.glFlush();
swapBuffers();
gl.glDisableVertexAttribArray(attributes[A_VERTEX]);
but this one - ie VBO w/ element VBO - don't :
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, objectIds[0]);
gl.glVertexAttribPointer(attributes[A_VERTEX], 3 , GL2ES2.GL_FLOAT, false, 0, 0L);
gl.glEnableVertexAttribArray(attributes[A_VERTEX]);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, 0); // or at the end, no matter.
gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, objectIds[1]);
gl.glDrawElements(GL2ES2.GL_TRIANGLES, triangleIndices.length, GL2ES2.GL_SHORT, 0);
gl.glFlush();
swapBuffers();
gl.glDisableVertexAttribArray(attributes[A_VERTEX]);
gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, 0);
Note : VBO and ElementVBO created the same way. Element VBO is simply {0,3,6} ; check against VBO binding always done.
In our last case, the way JMonkey use glDrawElements is :
gl.glDrawElements(elMode, elementLength, fmt, indexBuf.getData());
where indexBuf is a JMonkey VertexBuffer, and getData() is a Java Buffer.
So, they use
glDrawElements() with a pointer to vertices data and an element-VBO,
OR,
glDrawArray() with a VBO,
but - IMHO -
they don't use glDrawElements() with VBO (ie GL_ARRAY_BUFFER) + element-VBO (ie GL_ELEMENT_ARRAY_BUFFER) together.
Any idea ? I don't want to take your time here, if your don't have any Jogl solutions, it will be ok with me, findind out another solutions.
Anyway, thank you for your help,
v/