Ethan Smith
Ethan Smith

Reputation: 122

What are indices in GLSL?

I am going through the OpenGL tutorials on learnopengl.com and feel I have a pretty solid grasp of what I have learned thus far. The only thing that I am having trouble with, is the indices in GLSL. All I know so far is that they are for transferring data between shaders, and between buffers and the vertex shader. I would like to understand the following:

  1. What physical device contains these indices? (is it in RAM or memory on GPU?)
  2. Why are there only 16 indices?
  3. Why do I have to enable them before I can use them on the client side of the program with glEnableVertexAttribute(n)?

Thank you for taking the time to help me out!

Upvotes: 0

Views: 268

Answers (1)

user133495
user133495

Reputation: 106

Vertex data is stored (or rather buffered - the CPU may process it but it all gets sent to the GPU) in the GPU memory. Here's a picture: enter image description here

16 is the minimum number of attributes that OpenGL will guarantee. As mentioned in the tutorial (in the beginning of the shaders section) and in the OpenGL documentation, the number of vertex attributes is limited by the graphics hardware. Each additional vertex attribute means one more thing for your GPU to process per vertex. Disabling all the vertex attributes by default and requiring the programmer to enable the attributes he/she needs allows your code to run efficiently.

Upvotes: 2

Related Questions