![]() Disable the client state before leaving Gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3) Gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer) Gl.glEnableClientState(GL10.GL_VERTEX_ARRAY) ** The draw method for the square with the GL context */ set the cursor position to the beginning of the buffer fill the vertexBuffer with the vertices VertexBuffer = vertexByteBuffer.asFloatBuffer() allocates the memory from the byte buffer VertexByteBuffer.order(ByteOrder.nativeOrder()) a float has 4 bytes so we allocate for each coordinate 4 bytesīyteBuffer vertexByteBuffer = ByteBuffer.allocateDirect(vertices.length * 4) Private FloatBuffer vertexBuffer // buffer holding the vertices If you compare the Square class with the Triangle class, you will notice just one difference: ![]() Grab the project from the previous article and create a new class called Square. This also has benefits: we eliminate redundant data from the memory. It draws the first triangle using the vertices in order, then it takes the last vertex from the previous triangle and uses the last side of the triangle as the basis for the new triangle.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |