Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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? –  Jonathan Apr 7 '11 at 21:36
    
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. –  Corillian Apr 7 '11 at 21:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.