Vertices, Texture coordinates, Normals and Colors have a 1 to 1 to 1
to 1 relationship.  That means that for any given vertex, you can
define:

The vertex's location
The texture coordinate
The normal
The color

If you define 4 vertices (with or without any of the other attributes,
doesn't matter), you can draw 2 triangles using drawElements.

Let's say that your verts define the following for a 2d square:

top left, top right, bottom right, bottom left

Easy enough, clockwise rotation.

Your indices would look like:  0,1,2, 0,2,3

let's say you put that into a directly-allocated ShortBuffer called
indexBuffer.
You'd then just call glDrawElements(GL10.GL_TRIANGLES, 6,
indexBuffer);
which says, "draw triangles using 6 points indexed by this index
buffer"

Make sense?


On Mar 23, 6:09 pm, Perty <pertyj...@gmail.com> wrote:
> Hi,
>
> If I use a glColorPointer together with a glVertexPointer and a
> glNormalPointer the vertex is all in the same position in the array
> (taking into accont the stride).
>
> Thats working fine.
>
> But if I want to use the glDrawElement to save some memory
> (performance?) I do not understand how I should map
>  the normals and the colors.
>
> How does the vertexIndex lookup table relates to the colors and
> normals?
>
> The glDrawElements is rendering the triangles fine but the normals and
> colors is all messed up. So I manually traverse the the index and
> creates a vertexArray now.
>
> It feels like I have just made a simple error.
>
> /Regards Perty

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to