Posted by
vslash on
Mar 05, 2013; 10:07am
URL: https://forum.jogamp.org/GL2ES2-glEnableClientState-GL2ES2-GL-VERTEX-ARRAY-issue-tp4028490p4028492.html
// -----
// Using ... :
// -----
private static final float triangleVertices[] =
{
-0.5f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.5f, 0.0f, 0.0f
};
private static final short triangleIndices[] = {0,3,6};
// ... and ...
private static final String vshTriangleSource =
"attribute vec3 a_vertex; \n" +
"void main() \n" +
"{ gl_Position = vec4(a_vertex, 1.0); }";
private static final String fshTriangleSource =
"void main() \n" +
"{ gl_FragColor = vec4 (1.0, 1.0, 1.0, 1.0); }";
// -----
// Settings : no compile, link error ; debug/trace don't show any errors on VBO creation ; VBO exists when binded.
// i use ByteBuffer(from Array..) with nativeOrder and put it to VBO.
// -----
// -----
// Displaying, following this sequence ;
// -----
gl.glUseProgram(programId);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, objectIds[0]);
gl.glVertexAttribPointer(attributes[A_VERTEX], 3 , GL2ES2.GL_FLOAT, false, 0, 0L); // Call to VAttribPointer make really VBO as a source
gl.glEnableVertexAttribArray(attributes[A_VERTEX]); //Enable our VertexAttribPointer set above
// VertexAttribPointer reads a global variable from VBO and stores it in the VAO,
gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, objectIds[1]);
// Draws the triangles, starting by the index 0 in the IBO.
gl.glDrawElements(GL2ES2.GL_TRIANGLES, triangleIndices.length, GL2ES2.GL_UNSIGNED_SHORT, 0);
gl.glFlush();
drawable.swapBuffers(); // i don't use autodrawable here
gl.glDisableVertexAttribArray(attributes[A_VERTEX]); // Disable our Pointer
gl.glBindBuffer(GL2ES2.GL_ELEMENT_ARRAY_BUFFER, 0);
gl.glBindBuffer(GL2ES2.GL_ARRAY_BUFFER, 0);
// Lead to a black screen !
// I must say that glClear + color work well.
My comments : as said here (
http://www.opengl.org/wiki/VBO#Vertex_Buffer_Object) :
"Note: The GL_ARRAY_BUFFER​ binding is NOT part of the VAO's state! I know that's confusing, but that's the way it is."
Conclusion : calling gl.glEnableVertexAttribArray make VBO as a part of VAO ? (so, w/o using glEnableClientState) ?
Thanks,