1
\$\begingroup\$

I am using OpenGL ES 1.x/2.x

I have 2 attributes to be passed to the GPU(one is colors, one is vertices, one color per vertex).

I use indices. Both attributes will use the same indices array

This is not a big issue but I was wondering if there is a way to tell the GPU that both attributes use the same indices array so that it is not transfered to the gpu twice, or maybe it does not matter because the GPU uses the RAM?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

If you are using indices then all of those attributes are already using the same index array. Each entry in your index array is an index into the vertex buffer that is currently being used for drawing. If you are using an interleaved vertex buffer then each vertex is represented by a single block of memory (in code usually defined by a struct) that contains all of the associated vertex attributes. The other method is to use multiple vertex arrays where each array contains a different attribute. Regardless of the method used for storing vertex data the current index pulled from your array of indices will point to the same data.

To summarize, if I understand your question correctly, it sounds like you're already doing the right thing.

\$\endgroup\$
2
  • \$\begingroup\$ Okay I should've checked it out a bit before asking.. but then how do I have an attribute that uses a different index array? \$\endgroup\$
    – Jonathan
    Commented Apr 7, 2011 at 21:36
  • \$\begingroup\$ You will have to issue a different draw call and swap in/out attribute arrays whenever you need to use a different index buffer. Scenarios where you need to do this are ideal for using non-interleaved vertex arrays instead of interleaved vertex buffers. \$\endgroup\$
    – Corillian
    Commented Apr 7, 2011 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .